refactor(ci): update helper image through repository variable

Signed-off-by: WenyXu <wenymedia@gmail.com>
This commit is contained in:
WenyXu
2026-10-29 01:03:45 +00:00
parent 06a77798c9
commit 4f908464fa
8 changed files with 46 additions and 69 deletions
+4 -4
View File
@@ -18,19 +18,19 @@
import argparse
import hashlib
import json
import os
import re
import subprocess
from pathlib import Path
BINARIES = ("query_perf_fixture", "query_regression_runner")
PIN = Path(__file__).resolve().parents[1] / "query-regression-helpers-image.txt"
def resolve_image(value, pin=PIN):
def resolve_image(value):
if value == "pinned":
value = pin.read_text().strip()
value = os.environ.get("QUERY_REGRESSION_HELPERS_IMAGE", "")
if not re.fullmatch(r"[a-zA-Z0-9][a-zA-Z0-9._/:@-]*@sha256:[0-9a-f]{64}", value):
raise ValueError("helpers_image requires an image@sha256 digest; publish and merge the pin-update PR before using 'pinned'")
raise ValueError("helpers_image requires an image@sha256 digest; set QUERY_REGRESSION_HELPERS_IMAGE by publishing a verified image before using 'pinned'")
return value
@@ -1,45 +1,14 @@
#!/usr/bin/env bash
set -euo pipefail
: "${HELPERS_IMAGE:?Published image digest is required}"
: "${HELPERS_IMAGE:?Verified image digest is required}"
: "${GITHUB_REPOSITORY:?Repository is required}"
repository=greptime-registry.cn-hangzhou.cr.aliyuncs.com/tools/query-regression-helpers
[[ "$HELPERS_IMAGE" =~ ^${repository}@sha256:[0-9a-f]{64}$ ]]
branch="ci/update-query-regression-helpers-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
git config user.name greptimedb-ci
git config user.email greptimedb-ci@greptime.com
git fetch origin main
git checkout -b "$branch" origin/main
pin=.github/query-regression-helpers-image.txt
printf '%s\n' "$HELPERS_IMAGE" > "$pin"
git add "$pin"
if git diff --cached --quiet; then
echo 'Helper image pin is already current.'
exit 0
fi
git commit -s -m 'ci(query-regression): update precompiled helpers image'
git push origin "HEAD:refs/heads/$branch"
body="$(mktemp)"
trap 'rm -f -- "$body"' EXIT
cat > "$body" <<EOF
I hereby agree to the terms of the [GreptimeDB CLA](https://github.com/GreptimeTeam/.github/blob/main/CLA.md).
## Refer to a related PR or issue link (optional)
${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}
## What's changed and what's your intention?
Update the query-regression helper image to \`$HELPERS_IMAGE\`, built from \`$GITHUB_SHA\`.
The ECS build smoke-tested both packaged binaries and compared fixture plans. The publishing job extracted both binaries from the published digest and verified their SHA-256 checksums against those build outputs.
Runs opting into \`helpers_image: pinned\` use this version after merge. Source-build defaults are unchanged.
## PR Checklist
- [ ] I have written the necessary rustdoc comments.
- [x] I have added the necessary unit tests and integration tests.
- [ ] This PR requires documentation updates.
- [x] API changes are backward compatible.
- [x] Schema or data changes are backward compatible.
- [ ] This PR needs to be backported to release branches, and I have added the matching labels.
EOF
gh pr create --draft --base main --head "$branch" \
--title 'ci(query-regression): update precompiled helpers image' --body-file "$body"
[[ "$HELPERS_IMAGE" == "$repository@sha256:"* ]]
[[ "${HELPERS_IMAGE#"$repository@"}" =~ ^sha256:[0-9a-f]{64}$ ]]
# Like QUERY_REGRESSION_ECS_IMAGE_ID, this is CI configuration, not a source
# change. Create on first publication, then update only after image verification.
gh variable set QUERY_REGRESSION_HELPERS_IMAGE \
--repo "$GITHUB_REPOSITORY" --body "$HELPERS_IMAGE"
gh api "repos/$GITHUB_REPOSITORY/actions/variables/QUERY_REGRESSION_HELPERS_IMAGE" \
| jq -e --arg expected "$HELPERS_IMAGE" '.value == $expected' >/dev/null
printf 'QUERY_REGRESSION_HELPERS_IMAGE updated to `%s`\n' "$HELPERS_IMAGE"