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 5bbbee0
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/regressions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,22 @@ jobs:
run: ./build.sh build_latest ${{ matrix.repo }} ${{ github.event.inputs.to_upgrade }}
- name: Compare sites
run: ./build.sh compare ${{ matrix.repo }}

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
36 changes: 36 additions & 0 deletions coverage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import collections
import csv
import os
from pathlib import Path

usages = collections.defaultdict(list)
for f in sorted(Path(__file__).parent.glob("projects/*/requirements.in")):
for requirement in f.read_text().splitlines():
if not requirement or " " in requirement:
continue
usages[requirement].append(f.parent.name.replace('--', '/'))

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"{len(usages[install_id]):3} {install_id}")
for line in lines:
print(f" {line}")
if os.environ.get("GITHUB_ACTIONS"):
if usages[install_id]:
print(f" Used by {', '.join(usages[install_id])}")
print("::endgroup::")

0 comments on commit 5bbbee0

Please sign in to comment.