Skip to content

Commit c9d0891

Browse files
[github-actions] Add reports deployment health checks (#70) (#112)
* [github-actions] Add reports deployment health checks (#70) * Update wiki submodule pointer for PR #112 --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 188714f commit c9d0891

3 files changed

Lines changed: 100 additions & 2 deletions

File tree

.github/wiki

Submodule wiki updated from e70f1b7 to 3f20b41

.github/workflows/reports.yml

Lines changed: 97 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,106 @@ jobs:
123123
keep_files: false
124124
force_orphan: false
125125

126+
verify_main_reports:
127+
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && !(github.event_name == 'workflow_dispatch' && inputs.cleanup-previews)
128+
name: Verify Main Reports Deployment
129+
needs: reports
130+
runs-on: ubuntu-latest
131+
132+
steps:
133+
- name: Health check deployed reports
134+
env:
135+
BASE_URL: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}
136+
run: |
137+
check_url() {
138+
url="$1"
139+
label="$2"
140+
attempts=6
141+
delay=5
142+
143+
for attempt in $(seq 1 "${attempts}"); do
144+
echo "Checking ${label}: ${url} (attempt ${attempt}/${attempts})"
145+
146+
http_status="$(curl --silent --show-error --output /dev/null --location --write-out '%{http_code}' "${url}" 2>/tmp/curl-error.log || true)"
147+
148+
if [ "${http_status}" -ge 200 ] && [ "${http_status}" -lt 400 ]; then
149+
echo "${label} is reachable (${http_status})."
150+
return 0
151+
fi
152+
153+
curl_error="$(cat /tmp/curl-error.log)"
154+
155+
if [ -n "${curl_error}" ]; then
156+
echo "Attempt ${attempt} failed for ${label}: ${url} (curl error: ${curl_error})"
157+
else
158+
echo "Attempt ${attempt} failed for ${label}: ${url} (HTTP ${http_status})"
159+
fi
160+
161+
if [ "${attempt}" -lt "${attempts}" ]; then
162+
sleep "${delay}"
163+
fi
164+
done
165+
166+
echo "::error title=Reports health check failed::${label} is not reachable at ${url}. Last HTTP status: ${http_status}${curl_error:+; curl error: ${curl_error}}"
167+
return 1
168+
}
169+
170+
check_url "${BASE_URL}/" "Reports index"
171+
check_url "${BASE_URL}/coverage/" "Coverage report"
172+
173+
verify_preview_reports:
174+
if: github.event_name == 'pull_request' && github.event.action != 'closed'
175+
name: Verify Pull Request Reports Preview
176+
needs: reports
177+
runs-on: ubuntu-latest
178+
179+
steps:
180+
- name: Health check deployed preview
181+
env:
182+
BASE_URL: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/previews/pr-${{ github.event.pull_request.number }}
183+
run: |
184+
check_url() {
185+
url="$1"
186+
label="$2"
187+
attempts=6
188+
delay=5
189+
190+
for attempt in $(seq 1 "${attempts}"); do
191+
echo "Checking ${label}: ${url} (attempt ${attempt}/${attempts})"
192+
193+
http_status="$(curl --silent --show-error --output /dev/null --location --write-out '%{http_code}' "${url}" 2>/tmp/curl-error.log || true)"
194+
195+
if [ "${http_status}" -ge 200 ] && [ "${http_status}" -lt 400 ]; then
196+
echo "${label} is reachable (${http_status})."
197+
return 0
198+
fi
199+
200+
curl_error="$(cat /tmp/curl-error.log)"
201+
202+
if [ -n "${curl_error}" ]; then
203+
echo "Attempt ${attempt} failed for ${label}: ${url} (curl error: ${curl_error})"
204+
else
205+
echo "Attempt ${attempt} failed for ${label}: ${url} (HTTP ${http_status})"
206+
fi
207+
208+
if [ "${attempt}" -lt "${attempts}" ]; then
209+
sleep "${delay}"
210+
fi
211+
done
212+
213+
echo "::error title=Preview health check failed::${label} is not reachable at ${url}. Last HTTP status: ${http_status}${curl_error:+; curl error: ${curl_error}}"
214+
return 1
215+
}
216+
217+
check_url "${BASE_URL}/" "Preview reports index"
218+
check_url "${BASE_URL}/coverage/" "Preview coverage report"
219+
126220
comment_preview:
127221
if: github.event_name == 'pull_request' && github.event.action != 'closed'
128222
name: Comment Pull Request Preview URLs
129-
needs: reports
223+
needs:
224+
- reports
225+
- verify_preview_reports
130226
runs-on: ubuntu-latest
131227
permissions:
132228
pull-requests: write

docs/usage/github-actions.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ The ``reports.yml`` workflow is responsible for generating technical documentati
3333

3434
**Behavior:**
3535
* **Main Branch**: Runs all checks and deploys the final reports to the root of the ``gh-pages`` branch.
36+
* Runs a post-deploy health check against the published reports index and coverage URLs with retry/backoff to account for Pages propagation.
3637
* **Pull Requests**:
3738
* Generates a **Preview** of the documentation, coverage, and metrics.
3839
* Deploys the preview to ``gh-pages`` under ``previews/pr-{number}/``.
40+
* Verifies the preview index and coverage URLs after deployment before posting preview links.
3941
* Posts a **Sticky Comment** on the PR with links to the live preview, coverage report, and metrics site.
4042
* **Cleanup**: When a PR is closed, the workflow automatically removes the preview directory from the ``gh-pages`` branch to keep the repository clean.
4143
* **Concurrency**: New pushes to the same PR cancel older in-progress preview runs without affecting other PRs.

0 commit comments

Comments
 (0)