From 52e5420ebda6076a070e9cb9580d3cfa07a880af Mon Sep 17 00:00:00 2001 From: mamu Date: Fri, 17 May 2024 19:29:40 +0900 Subject: [PATCH] Add header confirmation CI --- .github/workflows/header-confirm.yaml | 20 ++++++++++++++++++++ optunahub-registry/header_confirm.py | 24 ++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 .github/workflows/header-confirm.yaml create mode 100644 optunahub-registry/header_confirm.py diff --git a/.github/workflows/header-confirm.yaml b/.github/workflows/header-confirm.yaml new file mode 100644 index 00000000..f7eef2f2 --- /dev/null +++ b/.github/workflows/header-confirm.yaml @@ -0,0 +1,20 @@ +name: Header Confirmation + +on: + push: + branches: + - main + pull_request: {} + +jobs: + header-confirm: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.11' + - name: Install dependencies + run: pip install python-frontmatter + - name: Confirm headers + run: python optunahub-registry/header_confirm.py diff --git a/optunahub-registry/header_confirm.py b/optunahub-registry/header_confirm.py new file mode 100644 index 00000000..f96735bc --- /dev/null +++ b/optunahub-registry/header_confirm.py @@ -0,0 +1,24 @@ +import os + +import frontmatter + + +def header_confirm(path: str) -> None: + post = frontmatter.load(path) + assert "author" in post.keys(), f"author is not found in {path}" + assert "title" in post.keys(), f"title is not found in {path}" + assert "description" in post.keys(), f"description is not found in {path}" + assert "tags" in post.keys(), f"tags is not found in {path}" + assert "optuna_versions" in post.keys(), f"optuna_versions is not found in {path}" + assert "license" in post.keys(), f"license is not found in {path}" + + +if __name__ == "__main__": + # Check all README files under the `package` directory. + for root, dirs, files in os.walk("package"): + for file in files: + if file == "README.md": + header_confirm(os.path.join(root, file)) + + # Check the template file. + header_confirm("template/README.md")