From 383efbc837dd08ee2a65f60514dd1c28261a3291 Mon Sep 17 00:00:00 2001 From: Guess-Who-sec Date: Fri, 30 Oct 2026 23:29:20 +0000 Subject: [PATCH 1/3] ci(release): publish preflight and CI trigger fixes (M3, #922) - build_release.yml: a first "Publish preflight" job refuses to publish unless every workflow in PUBLISH_REQUIRED_LANES (Go Build CI, Gigapipe CI Cluster) passed on the commit being released. Lanes are matched by workflow name because job names are not unique (two jobs are "build"). - go.yml: also run on pushes to master, so unit tests run on the merged commit and the preflight has a result to check. - node-clickhouse-cluster.js.yml: stop ignoring '**.yml' changes, so workflow and compose edits run the cluster lane. --- .github/scripts/publish-preflight.sh | 59 +++++++++++++++++++ .github/workflows/build_release.yml | 23 ++++++++ .github/workflows/go.yml | 2 + .../workflows/node-clickhouse-cluster.js.yml | 2 - 4 files changed, 84 insertions(+), 2 deletions(-) create mode 100755 .github/scripts/publish-preflight.sh diff --git a/.github/scripts/publish-preflight.sh b/.github/scripts/publish-preflight.sh new file mode 100755 index 00000000..401f0af6 --- /dev/null +++ b/.github/scripts/publish-preflight.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash +# Publish preflight (#922): refuse to release a commit unless every required +# lane passed on it. +# +# A lane is a workflow, named as GitHub shows it (e.g. "Go Build CI"). Workflow +# names are used rather than job names because job names are not unique: both +# go.yml and the cluster lane have a job called "build". +# +# For each lane, the most recent run of that workflow on SHA must have +# completed with conclusion "success". A lane with no run on SHA, a run still +# in progress, or any other conclusion refuses the release. +# +# REPO owner/name, e.g. metrico/gigapipe +# SHA the commit being released +# PUBLISH_REQUIRED_LANES workflow names, one per line +# GH_TOKEN token for the GitHub API (actions: read) +set -euo pipefail + +: "${REPO:?}" "${SHA:?}" "${PUBLISH_REQUIRED_LANES:?no lanes configured}" + +runs=$(gh api --paginate "repos/${REPO}/actions/runs?head_sha=${SHA}&per_page=100" \ + --jq '.workflow_runs[] | {name, status, conclusion, created_at, html_url}' | jq -s .) + +failed=0 +checked=0 +while IFS= read -r lane; do + lane="${lane#"${lane%%[![:space:]]*}"}" + lane="${lane%"${lane##*[![:space:]]}"}" + [ -z "$lane" ] && continue + checked=$((checked + 1)) + + latest=$(jq -c --arg lane "$lane" \ + '[.[] | select(.name == $lane)] | sort_by(.created_at) | last' <<<"$runs") + if [ "$latest" = "null" ]; then + echo "::error::lane \"$lane\" has no run on ${SHA}" + failed=1 + continue + fi + + status=$(jq -r .status <<<"$latest") + conclusion=$(jq -r .conclusion <<<"$latest") + url=$(jq -r .html_url <<<"$latest") + if [ "$status" != "completed" ] || [ "$conclusion" != "success" ]; then + echo "::error::lane \"$lane\" did not pass on ${SHA} (status=${status}, conclusion=${conclusion}): ${url}" + failed=1 + continue + fi + echo "lane \"$lane\" passed on ${SHA}: ${url}" +done <<<"$PUBLISH_REQUIRED_LANES" + +if [ "$checked" -eq 0 ]; then + echo "::error::refusing to publish ${SHA}: no lanes configured" + exit 1 +fi +if [ "$failed" -ne 0 ]; then + echo "::error::refusing to publish ${SHA}: required lanes did not pass" + exit 1 +fi +echo "all required lanes passed on ${SHA}" diff --git a/.github/workflows/build_release.yml b/.github/workflows/build_release.yml index 63e42487..5650b42e 100644 --- a/.github/workflows/build_release.yml +++ b/.github/workflows/build_release.yml @@ -18,7 +18,30 @@ on: types: [created] jobs: + # Refuses to publish unless every lane in PUBLISH_REQUIRED_LANES passed on + # the commit being released. Lanes are workflow names. + preflight: + runs-on: ubuntu-latest + name: 'Publish preflight' + permissions: + actions: read + contents: read + env: + PUBLISH_REQUIRED_LANES: | + Go Build CI + Gigapipe CI Cluster + steps: + - uses: actions/checkout@v4.1.1 + with: + ref: ${{ (github.event_name == 'workflow_dispatch') && github.event.inputs.branch || github.ref }} + - name: Check required lanes on the released commit + env: + GH_TOKEN: ${{ github.token }} + REPO: ${{ github.repository }} + run: SHA=$(git rev-parse HEAD) .github/scripts/publish-preflight.sh + validate_module_path: + needs: preflight runs-on: ubuntu-latest name: 'Validate go.mod major version' steps: diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index e0228152..400db825 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -1,6 +1,8 @@ name: Go Build CI on: + push: + branches: [ "master" ] pull_request: branches: [ "master" ] diff --git a/.github/workflows/node-clickhouse-cluster.js.yml b/.github/workflows/node-clickhouse-cluster.js.yml index 97fa3e58..c7bb5c18 100644 --- a/.github/workflows/node-clickhouse-cluster.js.yml +++ b/.github/workflows/node-clickhouse-cluster.js.yml @@ -7,13 +7,11 @@ on: branches: [ master, beta ] paths-ignore: - '**.md' - - '**.yml' - '**.yaml' pull_request: branches: [ master, beta ] paths-ignore: - '**.md' - - '**.yml' - '**.yaml' jobs: From 8feca6bc9476f60b6f1a35d6ba4c3d33d82b162b Mon Sep 17 00:00:00 2001 From: Guess-Who-sec Date: Sat, 31 Oct 2026 13:00:36 +0000 Subject: [PATCH 2/3] ci(release): wait for running lanes in the publish preflight Releases are usually created right after a merge, while that merge's lanes are still running: v5.6.0 started at 13:36:24 and the cluster lane on the same commit finished at 13:38:56. Instead of refusing a lane that has not finished, check it again every PREFLIGHT_POLL_SECONDS (30) for up to PREFLIGHT_WAIT_SECONDS (1800). A missing or failed lane still refuses at once. --- .github/scripts/publish-preflight.sh | 96 ++++++++++++++++++---------- 1 file changed, 62 insertions(+), 34 deletions(-) diff --git a/.github/scripts/publish-preflight.sh b/.github/scripts/publish-preflight.sh index 401f0af6..21b8006e 100755 --- a/.github/scripts/publish-preflight.sh +++ b/.github/scripts/publish-preflight.sh @@ -7,53 +7,81 @@ # go.yml and the cluster lane have a job called "build". # # For each lane, the most recent run of that workflow on SHA must have -# completed with conclusion "success". A lane with no run on SHA, a run still -# in progress, or any other conclusion refuses the release. +# completed with conclusion "success". A lane with no run on SHA, or with any +# other conclusion, refuses the release. A lane still running is waited for, +# since releases are usually created right after the merge whose lanes are +# still running; if it has not finished within PREFLIGHT_WAIT_SECONDS the +# release is refused. # # REPO owner/name, e.g. metrico/gigapipe # SHA the commit being released # PUBLISH_REQUIRED_LANES workflow names, one per line # GH_TOKEN token for the GitHub API (actions: read) +# PREFLIGHT_WAIT_SECONDS how long to wait for running lanes (default 1800) +# PREFLIGHT_POLL_SECONDS how often to check them (default 30) set -euo pipefail : "${REPO:?}" "${SHA:?}" "${PUBLISH_REQUIRED_LANES:?no lanes configured}" +wait_seconds="${PREFLIGHT_WAIT_SECONDS:-1800}" +poll_seconds="${PREFLIGHT_POLL_SECONDS:-30}" -runs=$(gh api --paginate "repos/${REPO}/actions/runs?head_sha=${SHA}&per_page=100" \ - --jq '.workflow_runs[] | {name, status, conclusion, created_at, html_url}' | jq -s .) - -failed=0 -checked=0 +lanes=() while IFS= read -r lane; do lane="${lane#"${lane%%[![:space:]]*}"}" lane="${lane%"${lane##*[![:space:]]}"}" - [ -z "$lane" ] && continue - checked=$((checked + 1)) - - latest=$(jq -c --arg lane "$lane" \ - '[.[] | select(.name == $lane)] | sort_by(.created_at) | last' <<<"$runs") - if [ "$latest" = "null" ]; then - echo "::error::lane \"$lane\" has no run on ${SHA}" - failed=1 - continue - fi - - status=$(jq -r .status <<<"$latest") - conclusion=$(jq -r .conclusion <<<"$latest") - url=$(jq -r .html_url <<<"$latest") - if [ "$status" != "completed" ] || [ "$conclusion" != "success" ]; then - echo "::error::lane \"$lane\" did not pass on ${SHA} (status=${status}, conclusion=${conclusion}): ${url}" - failed=1 - continue - fi - echo "lane \"$lane\" passed on ${SHA}: ${url}" + [ -n "$lane" ] && lanes+=("$lane") done <<<"$PUBLISH_REQUIRED_LANES" - -if [ "$checked" -eq 0 ]; then +if [ "${#lanes[@]}" -eq 0 ]; then echo "::error::refusing to publish ${SHA}: no lanes configured" exit 1 fi -if [ "$failed" -ne 0 ]; then - echo "::error::refusing to publish ${SHA}: required lanes did not pass" - exit 1 -fi -echo "all required lanes passed on ${SHA}" + +# check_lanes prints one line per lane and sets failed (a lane is missing or +# did not pass) and running (a lane has not finished yet). +check_lanes() { + local runs latest status conclusion url + runs=$(gh api --paginate "repos/${REPO}/actions/runs?head_sha=${SHA}&per_page=100" \ + --jq '.workflow_runs[] | {name, status, conclusion, created_at, html_url}' | jq -s .) + failed=0 + running=0 + for lane in "${lanes[@]}"; do + latest=$(jq -c --arg lane "$lane" \ + '[.[] | select(.name == $lane)] | sort_by(.created_at) | last' <<<"$runs") + if [ "$latest" = "null" ]; then + echo "::error::lane \"$lane\" has no run on ${SHA}" + failed=1 + continue + fi + status=$(jq -r .status <<<"$latest") + conclusion=$(jq -r .conclusion <<<"$latest") + url=$(jq -r .html_url <<<"$latest") + if [ "$status" != "completed" ]; then + echo "lane \"$lane\" is still running on ${SHA} (status=${status}): ${url}" + running=1 + elif [ "$conclusion" != "success" ]; then + echo "::error::lane \"$lane\" did not pass on ${SHA} (conclusion=${conclusion}): ${url}" + failed=1 + else + echo "lane \"$lane\" passed on ${SHA}: ${url}" + fi + done +} + +deadline=$((SECONDS + wait_seconds)) +while true; do + check_lanes + if [ "$failed" -ne 0 ]; then + echo "::error::refusing to publish ${SHA}: required lanes did not pass" + exit 1 + fi + if [ "$running" -eq 0 ]; then + echo "all required lanes passed on ${SHA}" + exit 0 + fi + if [ "$SECONDS" -ge "$deadline" ]; then + echo "::error::refusing to publish ${SHA}: required lanes still running after ${wait_seconds}s" + exit 1 + fi + echo "waiting ${poll_seconds}s for running lanes..." + sleep "$poll_seconds" +done From 7f54cc9d40f90bb5cd2556c939e1283239defd65 Mon Sep 17 00:00:00 2001 From: Guess-Who-sec Date: Wed, 18 Nov 2026 16:49:35 +0000 Subject: [PATCH 3/3] ci(release): release-gate skeleton for the heavy lanes (M3, #922) The cluster e2e lane and the k6 lane now start on every PR but only run their job on a push to master, nightly, a manual run or a PR from a release/* branch. On any other PR the job is skipped, which shows as skipped and counts as passing. Push runs share a concurrency group without cancelling the running one, so rapid merges queue at most one more run; nightly, manual and PR runs are never replaced by a push. The publish preflight passes over a run whose job was skipped and decides on an older run of the lane, and says how to start a lane by hand when it has no run that ran, or its run was cancelled. --- .github/scripts/publish-preflight.sh | 37 +++++++++++++++---- .github/workflows/k6_test.yml | 16 ++++++++ .../workflows/node-clickhouse-cluster.js.yml | 17 +++++++++ docs/contributing.md | 8 ++++ 4 files changed, 70 insertions(+), 8 deletions(-) diff --git a/.github/scripts/publish-preflight.sh b/.github/scripts/publish-preflight.sh index 21b8006e..ad6ece18 100755 --- a/.github/scripts/publish-preflight.sh +++ b/.github/scripts/publish-preflight.sh @@ -6,8 +6,10 @@ # names are used rather than job names because job names are not unique: both # go.yml and the cluster lane have a job called "build". # -# For each lane, the most recent run of that workflow on SHA must have -# completed with conclusion "success". A lane with no run on SHA, or with any +# For each lane, the most recent run of that workflow on SHA that actually ran +# its jobs must have completed with conclusion "success". Release-gate lanes +# skip their job on ordinary PRs, so a run with a skipped job is passed over +# and an older run on SHA decides. A lane with no such run on SHA, or with any # other conclusion, refuses the release. A lane still running is waited for, # since releases are usually created right after the merge whose lanes are # still running; if it has not finished within PREFLIGHT_WAIT_SECONDS the @@ -39,16 +41,31 @@ fi # check_lanes prints one line per lane and sets failed (a lane is missing or # did not pass) and running (a lane has not finished yet). check_lanes() { - local runs latest status conclusion url + local runs lane_runs latest run status conclusion url skipped runs=$(gh api --paginate "repos/${REPO}/actions/runs?head_sha=${SHA}&per_page=100" \ - --jq '.workflow_runs[] | {name, status, conclusion, created_at, html_url}' | jq -s .) + --jq '.workflow_runs[] | {id, name, status, conclusion, created_at, html_url}' | jq -s .) failed=0 running=0 for lane in "${lanes[@]}"; do - latest=$(jq -c --arg lane "$lane" \ - '[.[] | select(.name == $lane)] | sort_by(.created_at) | last' <<<"$runs") - if [ "$latest" = "null" ]; then - echo "::error::lane \"$lane\" has no run on ${SHA}" + # Newest first; the first run that isn't a skipped no-op decides. + lane_runs=$(jq -c --arg lane "$lane" \ + '[.[] | select(.name == $lane)] | sort_by(.created_at) | reverse | .[]' <<<"$runs") + latest="" + while IFS= read -r run; do + [ -n "$run" ] || continue + if [ "$(jq -r .status <<<"$run")" = "completed" ]; then + skipped=$(gh api --paginate "repos/${REPO}/actions/runs/$(jq -r .id <<<"$run")/jobs?per_page=100" \ + --jq '.jobs[] | select(.conclusion == "skipped") | .name' | wc -l) + if [ "$skipped" -gt 0 ]; then + echo "lane \"$lane\": skipping $(jq -r .html_url <<<"$run") (its job was skipped, not run)" + continue + fi + fi + latest=$run + break + done <<<"$lane_runs" + if [ -z "$latest" ]; then + echo "::error::lane \"$lane\" has no run on ${SHA} that ran its jobs; start it by hand (Actions, \"$lane\", Run workflow) on the released branch" failed=1 continue fi @@ -58,6 +75,10 @@ check_lanes() { if [ "$status" != "completed" ]; then echo "lane \"$lane\" is still running on ${SHA} (status=${status}): ${url}" running=1 + elif [ "$conclusion" = "cancelled" ]; then + # A push run that a newer push replaced while it waited ends cancelled. + echo "::error::lane \"$lane\" was cancelled on ${SHA}, so it never ran; start it by hand (Actions, \"$lane\", Run workflow) on the released branch: ${url}" + failed=1 elif [ "$conclusion" != "success" ]; then echo "::error::lane \"$lane\" did not pass on ${SHA} (conclusion=${conclusion}): ${url}" failed=1 diff --git a/.github/workflows/k6_test.yml b/.github/workflows/k6_test.yml index 04b728a4..1abb9233 100644 --- a/.github/workflows/k6_test.yml +++ b/.github/workflows/k6_test.yml @@ -1,4 +1,10 @@ # TODO! Change the way gigapipe runs +# +# Release-gate lane (#922): it starts on every PR but only does its work on a +# push to master, the nightly run, a manual run or a PR from a release/* branch. +# On any other PR the job below is skipped: the check shows as skipped, which +# counts as passing for required checks. The publish preflight doesn't accept +# a run whose job was skipped. name: K6 Test metrico/gigapipe on: push: @@ -24,9 +30,19 @@ on: clickhouse_image: description: 'Image for ClickHouse (clickhouse/clickhouse-server)' required: false + schedule: + - cron: '47 2 * * *' + +# Pushes queue instead of piling up: one push run runs, the newest waits, and a +# newer push replaces the waiting one. Every other run has its own group, so a +# push never cancels a nightly, manual or PR run. +concurrency: + group: ${{ github.workflow }}-${{ github.event_name == 'push' && github.ref || github.run_id }} + cancel-in-progress: false jobs: build: + if: github.event_name != 'pull_request' || startsWith(github.head_ref, 'release/') name: Run k6 on qryn:latest runs-on: ubuntu-latest continue-on-error: true diff --git a/.github/workflows/node-clickhouse-cluster.js.yml b/.github/workflows/node-clickhouse-cluster.js.yml index c7bb5c18..0047e33d 100644 --- a/.github/workflows/node-clickhouse-cluster.js.yml +++ b/.github/workflows/node-clickhouse-cluster.js.yml @@ -1,4 +1,10 @@ # This workflow will validate gigapipe using nodejs + clickhouse +# +# Release-gate lane (#922): it starts on every PR but only does its work on a +# push to master, the nightly run, a manual run or a PR from a release/* branch. +# On any other PR the job below is skipped: the check shows as skipped, which +# counts as passing for required checks. The publish preflight doesn't accept +# a run whose job was skipped. name: Gigapipe CI Cluster @@ -13,9 +19,20 @@ on: paths-ignore: - '**.md' - '**.yaml' + schedule: + - cron: '17 2 * * *' + workflow_dispatch: + +# Pushes queue instead of piling up: one push run runs, the newest waits, and a +# newer push replaces the waiting one. Every other run has its own group, so a +# push never cancels a nightly, manual or PR run. +concurrency: + group: ${{ github.workflow }}-${{ github.event_name == 'push' && github.ref || github.run_id }} + cancel-in-progress: false jobs: build: + if: github.event_name != 'pull_request' || startsWith(github.head_ref, 'release/') runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 diff --git a/docs/contributing.md b/docs/contributing.md index 87631bbb..02f11a6e 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -69,6 +69,14 @@ For end-to-end tests: make e2e-full ``` +In CI the end-to-end lane ("Gigapipe CI Cluster") and the k6 lane are release +gates: on an ordinary PR their job is skipped (shown as skipped, which counts +as passing). They run on every push to `master`, nightly, when started by hand +from the Actions tab, and on PRs from a `release/*` branch. Run `make e2e-full` +locally, or start the lane by hand on your branch, when your change can affect +them. A release is refused unless the lane ran and passed on the released +commit. + The Makefile is the entry point for every lane CI runs (CI calls these same recipes), plus parser-fuzz helpers for the query transpilers: