-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
"""ensure all headers have the same format""" | ||
|
||
import os | ||
import re | ||
|
||
# test for two <a tags (for header and rss feed) | ||
# <header> | ||
# <a href="./"> | ||
# <h1>alifeee's blog</h1> | ||
# </a> | ||
# <a id="rss" href="./feed.xml"> | ||
# <img alt="_RSS_" src="./icons/rss.svg" /> | ||
# </a> | ||
# </header> | ||
|
||
HEADER_REGEX = r"<header>[.\n\s\S]*<a[.\n\s\S]*<a[.\n\s\S]*<\/header>" | ||
|
||
|
||
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}") |