File tree Expand file tree Collapse file tree 2 files changed +43
-1
lines changed Expand file tree Collapse file tree 2 files changed +43
-1
lines changed Original file line number Diff line number Diff line change 35
35
# SKIP_BUILD=true bundle exec rake test
36
36
# NOTE: サイトが仕上がったら、上記テストを走らせると自動検知できる。
37
37
# ただ初期は自動検知の通知が多すぎるので手動で実行するのが吉。
38
+ python test-directory-structure.py
38
39
39
40
# Deploy job is triggered only pushed to main branch && CI passed
40
41
deploy :
86
87
with :
87
88
personal_token : ${{ secrets.GITHUB_TOKEN }}
88
89
publish_dir : ./_site
89
-
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/python
2
+ from pathlib import Path
3
+
4
+ """
5
+ すべてのページが index.html として生成されているか検査するスクリプト
6
+
7
+ foobar/baz/index.html
8
+ -> /foobar/baz/ と /foobar/baz の双方がルーティングできる
9
+
10
+ foobar/baz.html
11
+ -> /foobar/baz/ がルーティングできない
12
+ """
13
+
14
+
15
+ def main () -> int :
16
+ allowed_names = ["index.html" , "404.html" ]
17
+ errors = list [str ]()
18
+
19
+ for cwd , _dirs , files in Path ("_site" ).walk ():
20
+ for file in files :
21
+ if not file .endswith (".html" ):
22
+ continue
23
+
24
+ if file in allowed_names :
25
+ continue
26
+
27
+ path = cwd .joinpath (file ).as_posix ()
28
+ errors .append (path )
29
+
30
+ if 0 < len (errors ):
31
+ print ("index.html でない HTML ファイルが生成されました:" )
32
+ for i in errors :
33
+ print (f"- { i } " )
34
+ return 1
35
+
36
+ return 0
37
+
38
+
39
+ if __name__ == "__main__" :
40
+ import sys
41
+
42
+ sys .exit (main ())
You can’t perform that action at this time.
0 commit comments