Skip to content

Commit

Permalink
Add a project coverage script
Browse files Browse the repository at this point in the history
  • Loading branch information
oprypin committed Nov 10, 2023
1 parent 087593a commit f08bf4e
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Project coverage

on:
push:
pull_request:

jobs:
coverage:
runs-on: ubuntu-latest
steps:
- name: Checkout regressions
uses: actions/checkout@v4
with:
path: mkdocs-regressions
- name: Checkout catalog
uses: actions/checkout@v4
with:
repository: mkdocs/catalog
path: mkdocs-catalog
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Print project coverage
run: python mkdocs-regressions/coverage.py
31 changes: 31 additions & 0 deletions coverage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import collections
import csv
import os
from pathlib import Path

usage_counter = collections.Counter()
for f in Path(__file__).parent.glob("projects/*/requirements.in"):
usage_counter.update(line for line in f.read_text().splitlines() if line and " " not in line)

history_projects = (
Path(__file__).parent.joinpath("..", "mkdocs-catalog").glob("history/*_projects.csv")
)
with open(sorted(history_projects)[-1]) as f:
for p in csv.DictReader(f):
if p["pypi_id"] or p["github_id"]:
install_id = p["pypi_id"] or "git+https://github.com/{github_id}".format_map(p)
lines = []
if themes := p["mkdocs_theme"]:
lines.append(f"theme: {themes}")
if plugins := p["mkdocs_plugin"]:
lines.append(f"plugins: {plugins}")
if extensions := p["markdown_extension"]:
lines.append(f"markdown_extensions: {extensions}")
if lines:
if os.environ.get("GITHUB_ACTIONS"):
print("::group::", end="")
print(f"{usage_counter[install_id]:3} {install_id}")
for line in lines:
print(f" {line}")
if os.environ.get("GITHUB_ACTIONS"):
print("::endgroup::")

0 comments on commit f08bf4e

Please sign in to comment.