-
Notifications
You must be signed in to change notification settings - Fork 3
300 lines (258 loc) · 10.1 KB
/
docs.yml
File metadata and controls
300 lines (258 loc) · 10.1 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
name: Build and Deploy Documentation
"on":
push:
branches: [ "master", "main" ]
pull_request:
branches: [ "master", "main" ]
types: [opened, synchronize]
# Allow manual trigger
workflow_dispatch: {}
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
build-docs:
runs-on: ubuntu-latest
name: Build Documentation
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive # Include helios-core submodule for doc assets
fetch-depth: 0 # Fetch full history including tags
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y graphviz wget
# Install Doxygen 1.13.2 from source to match local build
# Different Doxygen versions generate different anchor hashes, breaking search links
wget https://www.doxygen.nl/files/doxygen-1.13.2.linux.bin.tar.gz
tar -xzf doxygen-1.13.2.linux.bin.tar.gz
sudo cp doxygen-1.13.2/bin/doxygen /usr/local/bin/
sudo chmod +x /usr/local/bin/doxygen
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install doxypypy
pip install -r requirements.txt
pip install -e .
- name: Verify Doxygen installation
run: |
doxygen --version
doxypypy --help
- name: Sync version to Doxygen config
run: |
# Get version from git tags (remove 'v' prefix if present)
VERSION=$(git describe --tags --abbrev=0 2>/dev/null | sed 's/^v//' || echo "unknown")
if [ "$VERSION" = "unknown" ]; then
echo "Warning: Could not determine version from git tags, using fallback"
# Fallback to setuptools-scm if available
VERSION=$(python -c "import setuptools_scm; print(setuptools_scm.get_version())" 2>/dev/null | sed 's/^v//' || echo "dev")
fi
echo "Updating Doxygen PROJECT_NUMBER to: $VERSION"
sed -i "s/^PROJECT_NUMBER.*$/PROJECT_NUMBER = $VERSION/" docs/Doxyfile.python
- name: Build documentation
run: |
# Create output directory
mkdir -p docs/generated
# Build documentation with Doxygen
doxygen docs/Doxyfile.python
# Create .nojekyll file to disable Jekyll processing on GitHub Pages
# This is critical because Jekyll ignores files starting with underscores
# which breaks Doxygen navigation (many generated files start with _)
touch docs/generated/html/.nojekyll
# Verify documentation was generated
ls -la docs/generated/html/
echo "✓ Documentation built successfully"
- name: Validate Doxygen artifacts
run: |
echo "=== Doxygen Documentation Validation ==="
VALIDATION_FAILED=0
DOC_DIR="docs/generated/html"
# 1. Check critical files
echo ""
echo "[1/5] Checking critical files..."
REQUIRED_FILES=(
"index.html"
"doxygen-awesome.css"
".nojekyll"
"search/search.js"
)
for file in "${REQUIRED_FILES[@]}"; do
if [ ! -f "$DOC_DIR/$file" ]; then
echo " ERROR: MISSING: $file"
VALIDATION_FAILED=1
else
size=$(stat -c%s "$DOC_DIR/$file" 2>/dev/null)
echo " OK: $file (${size} bytes)"
fi
done
# 2. Validate index.html structure
echo ""
echo "[2/5] Validating index.html structure..."
if [ -f "$DOC_DIR/index.html" ]; then
if grep -q "<title>" "$DOC_DIR/index.html" && \
grep -q "</body>" "$DOC_DIR/index.html"; then
echo " OK: index.html appears well-formed"
else
echo " ERROR: index.html appears malformed"
VALIDATION_FAILED=1
fi
fi
# 3. Check for underscore files (should work with .nojekyll)
echo ""
echo "[3/5] Checking for Doxygen underscore files..."
UNDERSCORE_COUNT=$(find "$DOC_DIR" -name "_*.js" -o -name "_*.html" | wc -l)
if [ "$UNDERSCORE_COUNT" -gt 0 ]; then
echo " OK: Found $UNDERSCORE_COUNT underscore files (normal for Doxygen)"
if [ ! -f "$DOC_DIR/.nojekyll" ]; then
echo " ERROR: .nojekyll missing - these files will be ignored by Jekyll!"
VALIDATION_FAILED=1
fi
fi
# 4. Verify directory structure
echo ""
echo "[4/5] Checking directory structure..."
for dir in "search" "classes" "files"; do
if [ -d "$DOC_DIR/$dir" ]; then
count=$(find "$DOC_DIR/$dir" -type f | wc -l)
echo " OK: $dir/ ($count files)"
fi
done
# 5. Size check (GitHub Pages limit: 1GB recommended, 10GB max)
echo ""
echo "[5/5] Checking total size..."
TOTAL_SIZE=$(du -sk "$DOC_DIR" | cut -f1)
TOTAL_MB=$((TOTAL_SIZE / 1024))
echo " Total size: ${TOTAL_MB} MB"
if [ "$TOTAL_SIZE" -gt 1048576 ]; then # 1GB in KB
echo " WARNING: Size exceeds 1GB (GitHub Pages recommended limit)"
elif [ "$TOTAL_SIZE" -gt 10485760 ]; then # 10GB in KB
echo " ERROR: Size exceeds 10GB (GitHub Pages absolute limit)"
VALIDATION_FAILED=1
else
echo " OK: Size within limits"
fi
# Final verdict
echo ""
echo "=== Validation Complete ==="
if [ $VALIDATION_FAILED -eq 1 ]; then
echo "VALIDATION FAILED"
exit 1
else
echo "ALL CHECKS PASSED"
fi
- name: Setup Pages
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'
uses: actions/configure-pages@v4
- name: Upload artifact
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'
uses: actions/upload-pages-artifact@v3
with:
path: docs/generated/html/
deploy-docs:
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'
outputs:
page_url: ${{ steps.deployment.outputs.page_url }}
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build-docs
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
verify-deployment:
name: Verify Deployment
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: deploy-docs
steps:
- name: Wait for GitHub Pages propagation and verify
timeout-minutes: 10
continue-on-error: true
id: verify
run: |
SITE_URL="${{ needs.deploy-docs.outputs.page_url }}"
echo "=== GitHub Pages Deployment Verification ==="
echo "Target URL: $SITE_URL"
echo ""
MAX_ATTEMPTS=15
RETRY_DELAY=30
ATTEMPT=0
echo "Note: GitHub Pages CDN propagation typically takes 1-10 minutes"
echo "Will retry up to $MAX_ATTEMPTS times with ${RETRY_DELAY}s delays"
echo ""
while [ $ATTEMPT -lt $MAX_ATTEMPTS ]; do
ATTEMPT=$((ATTEMPT + 1))
echo "[$ATTEMPT/$MAX_ATTEMPTS] Checking site accessibility..."
# Attempt to fetch the site
HTTP_CODE=$(curl -s -o /tmp/page.html -w "%{http_code}" \
--connect-timeout 10 \
--max-time 30 \
"$SITE_URL" || echo "000")
case "$HTTP_CODE" in
200)
echo " OK: Site returned HTTP 200"
# Verify it's actually our documentation
if grep -q "doxygen" /tmp/page.html || grep -q "PyHelios" /tmp/page.html; then
echo " OK: Content verified (PyHelios documentation detected)"
# Check for common Doxygen elements
if grep -q "search" /tmp/page.html; then
echo " OK: Search functionality present"
fi
echo ""
echo "DEPLOYMENT VERIFIED SUCCESSFULLY"
exit 0
else
echo " WARNING: Page returned 200 but doesn't appear to be PyHelios docs"
echo " Continuing retries..."
fi
;;
404)
echo " Site not found (HTTP 404) - waiting for propagation..."
;;
000)
echo " Connection failed - waiting for deployment..."
;;
*)
echo " Received HTTP $HTTP_CODE - waiting..."
;;
esac
if [ $ATTEMPT -lt $MAX_ATTEMPTS ]; then
echo " Waiting ${RETRY_DELAY}s before retry..."
echo ""
sleep $RETRY_DELAY
fi
done
echo ""
echo "VERIFICATION FAILED"
echo "Site did not become accessible after $MAX_ATTEMPTS attempts"
echo ""
echo "This may indicate:"
echo " - Deployment is still propagating (can take up to 20-30 minutes)"
echo " - GitHub Pages service issues"
echo " - Intermittent CDN problems (try re-running the workflow)"
echo ""
echo "Manual verification recommended: $SITE_URL"
exit 1
- name: Report verification result
if: always()
run: |
if [ "${{ steps.verify.outcome }}" == "success" ]; then
echo "::notice::Documentation successfully deployed and verified at ${{ needs.deploy-docs.outputs.page_url }}"
else
echo "::warning::Deployment verification failed or timed out. Site may still be propagating. Manual check: ${{ needs.deploy-docs.outputs.page_url }}"
fi