diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e463410f..89da35f1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -35,7 +35,7 @@ jobs: PYTHONWARNINGS: default - run: | make coverage_report - make github_pages + make github_pages REPO=${{ github.repository }} SHA=${{ github.sha }} if: github.ref_name == 'master' && matrix.python-version == '3.12' - uses: actions/upload-pages-artifact@v2 if: github.ref_name == 'master' && matrix.python-version == '3.12' diff --git a/Makefile b/Makefile index 5d52f200..7ca5dfcb 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,8 @@ # Run "make test" to run tests # Run "make clean" to remove automatically generated files +REPO ?= tatuylonen/wiktextract +SHA ?= HEAD + test: python -m unittest discover -b -s tests test_coverage: @@ -11,7 +14,7 @@ coverage_report: github_pages: python tools/generate_schema.py cp json_schema/*.json _site - python tools/github_pages.py + python tools/github_pages.py $(REPO) $(SHA) clean: python -m coverage erase rm -rf __pycache__ _site diff --git a/tools/github_pages.py b/tools/github_pages.py index 967eb38a..64720749 100644 --- a/tools/github_pages.py +++ b/tools/github_pages.py @@ -1,3 +1,4 @@ +import argparse import json from pathlib import Path @@ -6,6 +7,11 @@ def main(): """ Generate a simple HTML page to list files in the `_site` folder. """ + parser = argparse.ArgumentParser() + parser.add_argument("repo", help="The owner and repository name.") + parser.add_argument("sha", help="The commit SHA.") + args = parser.parse_args() + html = """ @@ -21,6 +27,7 @@ def main(): + """ @@ -37,6 +44,10 @@ def main(): schema_data = json.load(f) schema_list_html += f"
  • {schema_data.get('title')}
  • " html = html.replace("", schema_list_html) + + commit_sha = f"

    Commit: {args.sha[:7]}

    " + html = html.replace("", commit_sha) + with open("_site/index.html", "w", encoding="utf-8") as f: f.write(html)