diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..c8c8c41 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -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 diff --git a/coverage.py b/coverage.py new file mode 100644 index 0000000..23a25d9 --- /dev/null +++ b/coverage.py @@ -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::")