diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..052375a --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,31 @@ +name: Verify page formatting + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Install Python + uses: actions/setup-python@v2 + with: + python-version: 3.11 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + + - name: Verify header + run: | + python ./utilities.py/header.py diff --git a/utilities.py/header.py b/utilities.py/header.py new file mode 100644 index 0000000..5a08935 --- /dev/null +++ b/utilities.py/header.py @@ -0,0 +1,33 @@ +"""ensure all headers have the same format""" + +import os +import re + +# test for two +# +#

alifeee's blog

+#
+# +# _RSS_ +# +# + +HEADER_REGEX = r"
[.\n\s\S]*" + + +def get_all_html_files(): + """get all html files recursively""" + html_files = [] + for root, _, files in os.walk("."): + for foile in files: + if foile.endswith(".html"): + html_files.append(os.path.join(root, foile)) + return html_files + + +for file in get_all_html_files(): + with open(file, "r", encoding="utf-8") as f: + content = f.read() + if not re.search(HEADER_REGEX, content): + raise AssertionError(f"Header not found in {file}")