Skip to content

Commit 8deeca8

Browse files
committed
Add a project coverage script
1 parent 087593a commit 8deeca8

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

.github/workflows/regressions.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,22 @@ jobs:
4949
run: ./build.sh build_latest ${{ matrix.repo }} ${{ github.event.inputs.to_upgrade }}
5050
- name: Compare sites
5151
run: ./build.sh compare ${{ matrix.repo }}
52+
53+
coverage:
54+
runs-on: ubuntu-latest
55+
steps:
56+
- name: Checkout regressions
57+
uses: actions/checkout@v4
58+
with:
59+
path: mkdocs-regressions
60+
- name: Checkout catalog
61+
uses: actions/checkout@v4
62+
with:
63+
repository: mkdocs/catalog
64+
path: mkdocs-catalog
65+
- name: Set up Python
66+
uses: actions/setup-python@v4
67+
with:
68+
python-version: '3.11'
69+
- name: Print project coverage
70+
run: python mkdocs-regressions/coverage.py

coverage.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import collections
2+
import csv
3+
import os
4+
from pathlib import Path
5+
6+
usages = collections.defaultdict(list)
7+
for f in sorted(Path(__file__).parent.glob("projects/*/requirements.in")):
8+
for requirement in f.read_text().splitlines():
9+
if not requirement or " " in requirement:
10+
continue
11+
usages[requirement].append(f.parent.name.replace("--", "/"))
12+
13+
history_projects = (
14+
Path(__file__).parent.joinpath("..", "mkdocs-catalog").glob("history/*_projects.csv")
15+
)
16+
with open(sorted(history_projects)[-1]) as f:
17+
for p in csv.DictReader(f):
18+
if p["pypi_id"] or p["github_id"]:
19+
install_id = p["pypi_id"] or "git+https://github.com/{github_id}".format_map(p)
20+
lines = []
21+
if themes := p["mkdocs_theme"]:
22+
lines.append(f"theme: {themes}")
23+
if plugins := p["mkdocs_plugin"]:
24+
lines.append(f"plugins: {plugins}")
25+
if extensions := p["markdown_extension"]:
26+
lines.append(f"markdown_extensions: {extensions}")
27+
if lines:
28+
if os.environ.get("GITHUB_ACTIONS"):
29+
print("::group::", end="")
30+
print(f"{len(usages[install_id]):3} {install_id}")
31+
for line in lines:
32+
print(f" {line}")
33+
if os.environ.get("GITHUB_ACTIONS"):
34+
if usages[install_id]:
35+
print(f" Used by {', '.join(usages[install_id])}")
36+
print("::endgroup::")

0 commit comments

Comments
 (0)