mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-09-30 11:33:14 +00:00
* Align workflows with Sea Haven CI/CD handbook Bring the workflow suite in line with the handbook: bump actions/checkout to v7 (Node 24 runtime, already standardized), kebab-case the two snake_case workflow filenames, and add the org-standard Labeler caller and Dependency Review gate so vulnerable or disallowed-license deps and unlabeled PRs are caught automatically. File renames only — job/check display names are unchanged, so the promotion gate's REQUIRED_CHECKS and branch-protection required checks are unaffected. Refs: INFRA-115 * Drop Agent prefix from CI workflow + job names The handbook names workflows for what they do (CI, Deploy, Labeler), not the component they run, matching .github and afterhours-shift-manager. Rename the suite to CI and its jobs to Lint / Format check / Unit tests, and keep the promotion gate's REQUIRED_CHECKS in sync. Refs: INFRA-115 --------- Co-authored-by: seahaven-openswe[bot] <296972425+seahaven-openswe[bot]@users.noreply.github.com>
85 lines
3.3 KiB
Bash
Executable file
85 lines
3.3 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Promotion gate: refuse to promote a dev HEAD that is not fully green.
|
|
#
|
|
# Reads check-runs on stdin — one
|
|
# name<US>status<US>conclusion<US>details_url
|
|
# per line, fields separated by ASCII Unit Separator (0x1F) — so it is unit-testable
|
|
# WITHOUT GitHub. promote-dev-to-prod.yml pipes the live `gh api .../check-runs`
|
|
# output in. 0x1F (not TAB) is used deliberately: TAB is IFS-whitespace, so an empty
|
|
# conclusion (every in_progress check has a null conclusion) would collapse and shift
|
|
# the columns — which would make the promote run fail to exclude itself. 0x1F is
|
|
# non-whitespace, so `read` preserves empty fields and the columns stay aligned.
|
|
#
|
|
# A dev HEAD is promotable ONLY when BOTH hold:
|
|
# 1. every present check-run is completed with a passing conclusion
|
|
# (success/neutral/skipped); any pending/failed/cancelled/timed_out check BLOCKS.
|
|
# 2. every check named in REQUIRED_CHECKS is present AND concluded "success".
|
|
# This positive allow-list is what stops a partial-signal promotion — e.g. a
|
|
# commit pushed with [skip ci] (no CI check-runs) that still carries one
|
|
# unrelated green check, or a required check silently renamed/dropped. The gate
|
|
# FAILS SAFE: a missing required check blocks rather than promotes.
|
|
#
|
|
# Self-exclusion: the promotion workflow's OWN in-progress check-run is dropped by
|
|
# EXCLUDE_RUN_ID (its github.run_id, matched in the check-run details_url) — an
|
|
# unforgeable identity, NOT a mutable check name. A check that merely happens to be
|
|
# named "promote" can no longer hide a real failing/required check.
|
|
set -euo pipefail
|
|
|
|
EXCLUDE_RUN_ID="${EXCLUDE_RUN_ID:-}"
|
|
# Mandatory checks (one per line). Defaults to the CI suite, which runs on
|
|
# every push to dev (see ci.yml). Keep in sync with those job names; if a name
|
|
# drifts the gate blocks (fails safe) until the list is updated.
|
|
REQUIRED_CHECKS="${REQUIRED_CHECKS:-Lint
|
|
Format check
|
|
Unit tests
|
|
Playwright E2E}"
|
|
|
|
declare -A GREEN
|
|
seen=0
|
|
bad=0
|
|
while IFS=$'\037' read -r name status conclusion details_url; do
|
|
[ -n "${name:-}" ] || continue
|
|
# drop the promotion run's own check-run by run id (never by name).
|
|
if [ -n "${EXCLUDE_RUN_ID}" ] && \
|
|
[ "${details_url}" != "${details_url#*/runs/${EXCLUDE_RUN_ID}/}" ]; then
|
|
continue
|
|
fi
|
|
seen=$((seen + 1))
|
|
if [ "${status}" != "completed" ]; then
|
|
echo "BLOCK: check '${name}' is '${status}' (not completed)" >&2
|
|
bad=1
|
|
continue
|
|
fi
|
|
case "${conclusion}" in
|
|
success)
|
|
GREEN["${name}"]=1
|
|
echo "ok: ${name} (success)" ;;
|
|
neutral | skipped)
|
|
echo "ok: ${name} (${conclusion})" ;;
|
|
*)
|
|
echo "BLOCK: check '${name}' concluded '${conclusion:-<none>}'" >&2
|
|
bad=1 ;;
|
|
esac
|
|
done
|
|
|
|
if [ "${seen}" -eq 0 ]; then
|
|
echo "BLOCK: no check-runs found for this commit — refusing to promote an unverified dev HEAD" >&2
|
|
exit 1
|
|
fi
|
|
|
|
missing=0
|
|
while IFS= read -r req; do
|
|
[ -n "${req}" ] || continue
|
|
if [ -z "${GREEN[${req}]:-}" ]; then
|
|
echo "BLOCK: required check '${req}' is missing or not successful on dev HEAD" >&2
|
|
missing=1
|
|
fi
|
|
done <<EOF
|
|
${REQUIRED_CHECKS}
|
|
EOF
|
|
|
|
if [ "${bad}" -ne 0 ] || [ "${missing}" -ne 0 ]; then
|
|
echo "BLOCK: dev HEAD is not promotable (see reasons above)" >&2
|
|
exit 1
|
|
fi
|
|
echo "PASS: ${seen} check(s) present, all green; all required checks present + successful."
|