Skip to content

Commit

Permalink
Add header confirmation CI
Browse files Browse the repository at this point in the history
  • Loading branch information
HideakiImamura committed May 17, 2024
1 parent c6eb631 commit 52e5420
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/header-confirm.yaml
Original file line number Diff line number Diff line change
@@ -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
24 changes: 24 additions & 0 deletions optunahub-registry/header_confirm.py
Original file line number Diff line number Diff line change
@@ -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")

0 comments on commit 52e5420

Please sign in to comment.