ci: build and test each tree once
Release / Plan (reuse the published image?) (push) Successful in 5s
Release / ci (push) Skipped
Release / Build hub image (amd64) (push) Skipped
Release / Build probe image (amd64) (push) Skipped
Release / Build hub image (arm64) (push) Skipped
Release / Build probe image (arm64) (push) Skipped
Release / Publish tags (probe) (push) Successful in 16s
Release / Publish tags (hub) (push) Successful in 17s
Release / Gitea release (push) Skipped
Release / Plan (reuse the published image?) (push) Successful in 5s
Release / ci (push) Skipped
Release / Build hub image (amd64) (push) Skipped
Release / Build probe image (amd64) (push) Skipped
Release / Build hub image (arm64) (push) Skipped
Release / Build probe image (arm64) (push) Skipped
Release / Publish tags (probe) (push) Successful in 16s
Release / Publish tags (hub) (push) Successful in 17s
Release / Gitea release (push) Skipped
The release ran per ref, so main and a tag pushed together both planned before any image existed and built everything twice; it also re-ran the whole CI that the pull request had already passed on the same commit, and the PR CI built the images a third time. Now: one release queue (the tag waits for main and only re-points tags), the release skips CI when the pull request already passed for this commit, and the PR CI no longer builds images (the release builds once per input hash and smoke-tests before publishing). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
dc8e390dba
commit
7c92d4b359
2 files changed
+25
-20
No files matched your search
+2
-17
@@ -80,20 +80,5 @@ jobs:
|
||||
export PATH="$PATH:$(go env GOPATH)/bin"
|
||||
govulncheck ./...
|
||||
|
||||
image:
|
||||
name: Docker images (build and smoke test)
|
||||
if: ${{ gitea.event_name == 'pull_request' }}
|
||||
runs-on: linux-arm64
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- name: Build hub
|
||||
run: docker build --target hub -t "urutau-ci:${{ gitea.run_id }}" .
|
||||
- name: Build probe
|
||||
run: docker build --target probe -t "urutau-probe-ci:${{ gitea.run_id }}" .
|
||||
- name: Smoke test (hub)
|
||||
run: scripts/smoke-image.sh "urutau-ci:${{ gitea.run_id }}"
|
||||
- name: Smoke test (probe, under 15 MB)
|
||||
run: scripts/smoke-probe.sh "urutau-probe-ci:${{ gitea.run_id }}"
|
||||
- name: Clean up
|
||||
if: always()
|
||||
run: docker rmi -f "urutau-ci:${{ gitea.run_id }}" "urutau-probe-ci:${{ gitea.run_id }}" >/dev/null 2>&1 || true
|
||||
# No image build here: the release builds each image once per input hash,
|
||||
# natively per architecture, and smoke-tests it before publishing any tag.
|
||||
@@ -12,8 +12,11 @@ on:
|
||||
tags: ['v*']
|
||||
workflow_dispatch:
|
||||
|
||||
# One queue for main and tags: a tag pushed together with main waits for the
|
||||
# main run, then finds the images already published and only re-points tags.
|
||||
# (A per-ref group let both runs plan at once, see nothing, and build twice.)
|
||||
concurrency:
|
||||
group: release-${{ gitea.ref }}
|
||||
group: release
|
||||
cancel-in-progress: false
|
||||
|
||||
env:
|
||||
@@ -29,6 +32,7 @@ jobs:
|
||||
outputs:
|
||||
inputs: ${{ steps.plan.outputs.inputs }}
|
||||
reuse: ${{ steps.plan.outputs.reuse }}
|
||||
tested: ${{ steps.tested.outputs.tested }}
|
||||
image: ${{ steps.plan.outputs.image }}
|
||||
probe_image: ${{ steps.plan.outputs.probe_image }}
|
||||
steps:
|
||||
@@ -56,10 +60,25 @@ jobs:
|
||||
echo "reuse=$reuse" >> "$GITHUB_OUTPUT"
|
||||
echo "image=$REGISTRY/$ns" >> "$GITHUB_OUTPUT"
|
||||
echo "probe_image=$REGISTRY/$ns-probe" >> "$GITHUB_OUTPUT"
|
||||
# The pull request already ran the whole CI on this exact commit (the
|
||||
# merge is a fast-forward): do not run the same tests again here.
|
||||
- id: tested
|
||||
env:
|
||||
REPO: ${{ gitea.repository }}
|
||||
SHA: ${{ gitea.sha }}
|
||||
# The job token reads this repository's runs; on any error the answer
|
||||
# is false and the CI simply runs (never skips tests by mistake).
|
||||
TOKEN: ${{ gitea.token }}
|
||||
run: |
|
||||
tested=$(curl -fsS -H "Authorization: token $TOKEN" "https://$REGISTRY/api/v1/repos/$REPO/actions/runs?limit=50" \
|
||||
| jq -r --arg sha "$SHA" '[.workflow_runs[] | select(.head_sha == $sha and (.path | startswith("ci.yml")) and .conclusion == "success")] | length > 0' 2>/dev/null) || tested=false
|
||||
[ "$tested" = true ] || tested=false
|
||||
echo "CI already passed for $SHA: $tested"
|
||||
echo "tested=$tested" >> "$GITHUB_OUTPUT"
|
||||
|
||||
ci:
|
||||
needs: plan
|
||||
if: ${{ needs.plan.outputs.reuse != 'true' }}
|
||||
if: ${{ needs.plan.outputs.reuse != 'true' && needs.plan.outputs.tested != 'true' }}
|
||||
uses: ./.gitea/workflows/ci.yml
|
||||
|
||||
# Each architecture of each image is built on a native runner (no QEMU) and
|
||||
@@ -67,7 +86,8 @@ jobs:
|
||||
build:
|
||||
name: Build ${{ matrix.target }} image (${{ matrix.arch }})
|
||||
needs: [plan, ci]
|
||||
if: ${{ needs.plan.outputs.reuse != 'true' }}
|
||||
# ci is skipped (not failed) when the pull request already tested this commit.
|
||||
if: ${{ !cancelled() && needs.plan.result == 'success' && needs.plan.outputs.reuse != 'true' && (needs.ci.result == 'success' || needs.ci.result == 'skipped') }}
|
||||
runs-on: ${{ matrix.runner }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
|
||||
Reference in new issue
Block a user