Skip to content

Commit 94d47f1

Browse files
author
Codex Test
committed
ci: poll Labs for release qualification status in Actions
1 parent e26689e commit 94d47f1

2 files changed

Lines changed: 93 additions & 5 deletions

File tree

.github/workflows/release-qualification-dispatch.yml

Lines changed: 90 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ concurrency:
2020

2121
jobs:
2222
dispatch-release-qualification:
23+
name: Release Qualification
2324
if: github.event.pull_request.head.repo.full_name == github.repository
2425
runs-on: ubuntu-latest
26+
timeout-minutes: 10
2527
steps:
2628
- name: Build dispatch payload
2729
env:
@@ -95,6 +97,7 @@ jobs:
9597
9698
RUN_ID="$(jq -r '.run.runId // empty' "${RESPONSE_FILE}")"
9799
RUN_STATUS="$(jq -r '.run.status // empty' "${RESPONSE_FILE}")"
100+
RUN_STATUS_MESSAGE="$(jq -r '.run.statusMessage // empty' "${RESPONSE_FILE}")"
98101
CREATED="$(jq -r '.created // false' "${RESPONSE_FILE}")"
99102
100103
if [[ -z "${RUN_ID}" || -z "${RUN_STATUS}" ]]; then
@@ -103,14 +106,98 @@ jobs:
103106
exit 1
104107
fi
105108
109+
RUN_STATUS_URL="${LABS_RELEASE_QUALIFICATION_URL%/}/${RUN_ID}"
110+
106111
echo "run_id=${RUN_ID}" >> "${GITHUB_OUTPUT}"
107112
echo "run_status=${RUN_STATUS}" >> "${GITHUB_OUTPUT}"
113+
echo "run_status_message=${RUN_STATUS_MESSAGE}" >> "${GITHUB_OUTPUT}"
114+
echo "run_status_url=${RUN_STATUS_URL}" >> "${GITHUB_OUTPUT}"
108115
echo "created=${CREATED}" >> "${GITHUB_OUTPUT}"
109116
117+
- name: Wait for Labs release qualification result
118+
id: await
119+
env:
120+
INITIAL_RUN_STATUS: ${{ steps.dispatch.outputs.run_status }}
121+
INITIAL_RUN_STATUS_MESSAGE: ${{ steps.dispatch.outputs.run_status_message }}
122+
LABS_RELEASE_QUALIFICATION_TOKEN: ${{ secrets.LABS_RELEASE_QUALIFICATION_TOKEN }}
123+
RUN_STATUS_URL: ${{ steps.dispatch.outputs.run_status_url }}
124+
run: |
125+
set -euo pipefail
126+
127+
RUN_STATUS="${INITIAL_RUN_STATUS}"
128+
RUN_STATUS_MESSAGE="${INITIAL_RUN_STATUS_MESSAGE}"
129+
130+
while [[ "${RUN_STATUS}" == "queued" || "${RUN_STATUS}" == "in_progress" ]]; do
131+
RESPONSE_FILE="$(mktemp)"
132+
set +e
133+
HTTP_STATUS="$(curl \
134+
--fail-with-body \
135+
--silent \
136+
--show-error \
137+
--output "${RESPONSE_FILE}" \
138+
--write-out '%{http_code}' \
139+
-H "x-labs-internal-token: ${LABS_RELEASE_QUALIFICATION_TOKEN}" \
140+
"${RUN_STATUS_URL}")"
141+
CURL_EXIT=$?
142+
set -e
143+
144+
if [[ "${CURL_EXIT}" -ne 0 ]]; then
145+
cat "${RESPONSE_FILE}"
146+
exit "${CURL_EXIT}"
147+
fi
148+
149+
if [[ "${HTTP_STATUS}" -lt 200 || "${HTTP_STATUS}" -ge 300 ]]; then
150+
cat "${RESPONSE_FILE}"
151+
exit 1
152+
fi
153+
154+
RUN_STATUS="$(jq -r '.run.status // empty' "${RESPONSE_FILE}")"
155+
RUN_STATUS_MESSAGE="$(jq -r '.run.statusMessage // empty' "${RESPONSE_FILE}")"
156+
157+
if [[ -z "${RUN_STATUS}" ]]; then
158+
cat "${RESPONSE_FILE}"
159+
echo "Labs run lookup did not include a terminal status." >&2
160+
exit 1
161+
fi
162+
163+
if [[ "${RUN_STATUS}" == "queued" || "${RUN_STATUS}" == "in_progress" ]]; then
164+
sleep 10
165+
fi
166+
done
167+
168+
echo "run_status=${RUN_STATUS}" >> "${GITHUB_OUTPUT}"
169+
echo "run_status_message=${RUN_STATUS_MESSAGE}" >> "${GITHUB_OUTPUT}"
170+
171+
- name: Enforce Labs release qualification result
172+
env:
173+
FINAL_RUN_STATUS: ${{ steps.await.outputs.run_status }}
174+
FINAL_RUN_STATUS_MESSAGE: ${{ steps.await.outputs.run_status_message }}
175+
run: |
176+
set -euo pipefail
177+
178+
case "${FINAL_RUN_STATUS}" in
179+
succeeded)
180+
exit 0
181+
;;
182+
superseded)
183+
echo "${FINAL_RUN_STATUS_MESSAGE:-Release qualification was superseded by a newer run.}"
184+
exit 0
185+
;;
186+
failed|action_required)
187+
echo "${FINAL_RUN_STATUS_MESSAGE:-Release qualification failed.}" >&2
188+
exit 1
189+
;;
190+
*)
191+
echo "Unexpected Labs release qualification status: ${FINAL_RUN_STATUS}" >&2
192+
exit 1
193+
;;
194+
esac
195+
110196
- name: Write workflow summary
197+
if: always()
111198
run: |
112199
{
113-
echo "### Release Qualification Dispatch"
200+
echo "### Release Qualification"
114201
echo
115202
echo "| Field | Value |"
116203
echo "| --- | --- |"
@@ -119,6 +206,7 @@ jobs:
119206
echo "| Head branch | \`${{ github.event.pull_request.head.ref }}\` |"
120207
echo "| Head SHA | \`${{ github.event.pull_request.head.sha }}\` |"
121208
echo "| Labs run | \`${{ steps.dispatch.outputs.run_id }}\` |"
122-
echo "| Labs status | \`${{ steps.dispatch.outputs.run_status }}\` |"
209+
echo "| Labs status | \`${{ steps.await.outputs.run_status }}\` |"
210+
echo "| Labs status message | ${{ steps.await.outputs.run_status_message || 'n/a' }} |"
123211
echo "| New run created | \`${{ steps.dispatch.outputs.created }}\` |"
124212
} >> "${GITHUB_STEP_SUMMARY}"

cicd.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ main (next) → stable (latest) → X.x (maintenance)
8888
**Actions**:
8989

9090
- Sends the PR head SHA and branch metadata to the Labs release-orchestrator service
91-
- Lets Labs create a generic GitHub check run on that SHA
92-
- Does not wait on or expose any private Labs details in the repository
91+
- Polls Labs for the terminal release-qualification state
92+
- Uses the GitHub Actions job itself as the required public status check
9393
- Re-triggers automatically when new commits are pushed to the PR branch
9494

9595
Only same-repository PRs dispatch to Labs. Forked PRs are intentionally skipped so private Labs credentials are never exposed to untrusted branches.
@@ -229,7 +229,7 @@ These skip semantic-release entirely — useful for re-publishing a failed platf
229229

230230
1. Run "Promote to Stable" workflow
231231
2. Review the generated PR from the candidate branch into `stable`
232-
3. Labs receives the PR head SHA and creates the `Release Qualification` GitHub check run
232+
3. Labs receives the PR head SHA, records the qualification run, and the workflow job polls Labs for the terminal result
233233
4. If needed, resolve merge conflicts on the candidate branch and push fixes
234234
5. Re-run or wait for qualification on the new PR head SHA
235235
6. Merge the PR into `stable`

0 commit comments

Comments
 (0)