Skip to content

Commit fe1445f

Browse files
committed
tests: Add check-site-paths
1 parent 7f3becb commit fe1445f

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed

_config.yml

+1
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,4 @@ exclude:
8888
- .editorconfig
8989
- .gitattributes
9090
- .git-blame-ignore-revs
91+
- tests/
+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/bin/bash
2+
#
3+
# usage:
4+
# ./$0 "jekyll root" "html root"
5+
#
6+
# for use in CI to ensure some predetermined paths still exist
7+
8+
set -e # exit on any error
9+
10+
if [[ -z "$1" || -z "$2" ]]; then
11+
echo "Usage: $0 JEKYLL_ROOT HTML_ROOT"
12+
exit 127
13+
fi
14+
15+
JEKYLL_ROOT="$1"
16+
HTML_ROOT="$2"
17+
18+
# associative array for Jekyll -> HTML mapping
19+
declare -A JEKYLL_FOLDERS_TO_AUTODETECT
20+
JEKYLL_FOLDERS_TO_AUTODETECT["_wiki"]="Wiki"
21+
22+
# array of expected files in addition to what we'll autodetect
23+
HARD_DEFINES=(
24+
"Plugins.html"
25+
"Tablets.html"
26+
"Wiki.html"
27+
"favicon.ico"
28+
"Wiki/Install/Windows.html"
29+
"Wiki/Install/Linux.html"
30+
"Wiki/Install/MacOS.html"
31+
"Wiki/FAQ/Windows.html"
32+
"Wiki/FAQ/Linux.html"
33+
"Wiki/FAQ/MacOS.html"
34+
)
35+
36+
# sanity checks
37+
if [ ! -f "$JEKYLL_ROOT"/_config.yml ]; then
38+
echo "Missing Jekyll config in '$1'"
39+
exit 1
40+
fi
41+
42+
if [ ! -f "$HTML_ROOT"/index.html ]; then
43+
echo "Missing index file in '$2'. You must build the site yourself first."
44+
exit 1
45+
fi
46+
47+
# function definitions
48+
fileExists() {
49+
local file="$1"
50+
51+
if [ ! -f "$file" ]; then
52+
echo -e "FAIL\nFile '$file' does not exist"
53+
exit 1
54+
fi
55+
}
56+
57+
# hard defines
58+
printf "Checking ${#HARD_DEFINES[@]} hard defines... "
59+
60+
for file in "${HARD_DEFINES[@]}"; do
61+
fileExists "$HTML_ROOT"/"$file"
62+
done
63+
64+
echo OK
65+
66+
# mapping
67+
68+
for folderKey in "${!JEKYLL_FOLDERS_TO_AUTODETECT[@]}"; do
69+
jekyllSubFolder="$folderKey"
70+
htmlFolder="${JEKYLL_FOLDERS_TO_AUTODETECT[$folderKey]}"
71+
72+
# get new name based off old names
73+
cd "$JEKYLL_ROOT"/"$jekyllSubFolder"
74+
mapfile -t htmlFiles < <(find * -type f -iname "*.md" | sed 's/\.md$/.html/')
75+
cd - > /dev/null
76+
printf "Probing ${#htmlFiles[@]} files in Jekyll folder '$jekyllSubFolder'... "
77+
78+
for file in "${htmlFiles[@]}"; do
79+
fileExists "$HTML_ROOT"/"$htmlFolder"/"$file"
80+
done
81+
echo "OK"
82+
done
83+
84+
echo "All OK"

0 commit comments

Comments
 (0)