Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
# SKIP_BUILD=true bundle exec rake test
# NOTE: サイトが仕上がったら、上記テストを走らせると自動検知できる。
# ただ初期は自動検知の通知が多すぎるので手動で実行するのが吉。
python test-directory-structure.py

# Deploy job is triggered only pushed to main branch && CI passed
deploy:
Expand Down Expand Up @@ -86,4 +87,3 @@ jobs:
with:
personal_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./_site

42 changes: 42 additions & 0 deletions test-directory-structure.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/python
from pathlib import Path

"""
すべてのページが index.html として生成されているか検査するスクリプト

foobar/baz/index.html
-> /foobar/baz/ と /foobar/baz の双方がルーティングできる

foobar/baz.html
-> /foobar/baz/ がルーティングできない
"""


def main() -> int:
allowed_names = ["index.html", "404.html"]
errors = list[str]()

for cwd, _dirs, files in Path("_site").walk():
for file in files:
if not file.endswith(".html"):
continue

if file in allowed_names:
continue

path = cwd.joinpath(file).as_posix()
errors.append(path)

if 0 < len(errors):
print("index.html でない HTML ファイルが生成されました:")
for i in errors:
print(f"- {i}")
return 1

return 0


if __name__ == "__main__":
import sys

sys.exit(main())