-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (119 loc) · 4.65 KB
/
Copy pathbuild-test.yml
File metadata and controls
145 lines (119 loc) · 4.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: build-test
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
permissions:
contents: read
# Ensure only one run per branch at a time
concurrency:
group: "build-test-${{ github.ref }}"
cancel-in-progress: false
defaults:
run:
shell: bash
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
submodules: recursive
fetch-depth: 0
- name: Read Hugo version
run: |
HUGO_VERSION="$(tr -d '[:space:]' < .hugo-version)"
if [[ ! "$HUGO_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::Invalid Hugo version in .hugo-version: $HUGO_VERSION"
exit 1
fi
echo "HUGO_VERSION=$HUGO_VERSION" >> "$GITHUB_ENV"
- name: Install Hugo CLI
run: |
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
- name: Verify Hugo Version
run: hugo version
- name: Enforce Hugo minimum version
run: python3 scripts/check-hugo-version.py
- name: Install Dart Sass
run: sudo snap install dart-sass
- name: Check Dart Sass Version
run: dart-sass --version
- name: Build site (production settings)
env:
HUGO_ENVIRONMENT: production
HUGO_ENV: production
run: |
hugo \
--gc \
--minify
# ------------------------
# BEGIN PAGE VALIDATION
# ------------------------
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: "3.x"
- name: Install html5validator
run: pip install --no-cache-dir html5validator
- name: Validate generated HTML with html5validator
run: html5validator --root public --also-check-css --also-check-svg --log-level ERROR
# ------------------------
# SPELL CHECK
# ------------------------
- name: Setup Node.js for cspell
uses: actions/setup-node@v7
with:
node-version: "24"
- name: Install cspell
run: npm install -g cspell@latest
- name: Run spell check on content (skip drafts)
run: |
# Find all markdown files that are NOT drafts
FILES_TO_CHECK=$(find content -name "*.md" -exec grep -L "^draft = true" {} \; | grep -v "_TEMPLATE.md" || true)
if [ -z "$FILES_TO_CHECK" ]; then
echo "No non-draft files to check"
exit 0
fi
echo "Checking files:"
echo "$FILES_TO_CHECK"
# Run cspell and capture output (don't fail on errors)
CSPELL_OUTPUT=$(echo "$FILES_TO_CHECK" | xargs cspell --config .cspell.json 2>&1) || true
# Check if there are any spelling issues
if echo "$CSPELL_OUTPUT" | grep -q "Unknown word"; then
echo "## 📝 Spelling Issues Found" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "The following words were not recognized. Add them to \`.cspell.json\` if they're valid." >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| File | Location | Word |" >> $GITHUB_STEP_SUMMARY
echo "|------|----------|------|" >> $GITHUB_STEP_SUMMARY
# Parse cspell output: "file:line:col - Unknown word (word)"
echo "$CSPELL_OUTPUT" | grep "Unknown word" | while read -r line; do
# Extract file path, location, and word
FILE=$(echo "$line" | cut -d':' -f1)
LINE_NUM=$(echo "$line" | cut -d':' -f2)
COL=$(echo "$line" | cut -d':' -f3 | cut -d' ' -f1)
WORD=$(echo "$line" | grep -oP '\(.*?\)' | tr -d '()')
echo "| \`$FILE\` | $LINE_NUM:$COL | \`$WORD\` |" >> $GITHUB_STEP_SUMMARY
done
echo "" >> $GITHUB_STEP_SUMMARY
ISSUE_COUNT=$(echo "$CSPELL_OUTPUT" | grep -c "Unknown word" || echo "0")
echo "**Total: $ISSUE_COUNT issue(s)**" >> $GITHUB_STEP_SUMMARY
else
echo "✅ No spelling issues found" >> $GITHUB_STEP_SUMMARY
fi
# Always exit successfully - spelling issues are informational only
exit 0
# Optionally upload the generated site as an artifact for debugging
- name: Upload built site artifact
uses: actions/upload-artifact@v7
with:
name: built-site
path: public
if-no-files-found: ignore