Skip to content

feat(images): Automatically push and then test new images when changes made, fixes #8609 - #8707

Merged
rfay merged 43 commits into
ddev:mainfrom
rfay:20260814_rfay_docker_update_phase_2
Aug 18, 2026
Merged

rfay merged 43 commits into
ddev:mainfrom
rfay:20260814_rfay_docker_update_phase_2

Conversation

@rfay

@rfay rfay commented Aug 14, 2026 •

Copy link
Copy Markdown
Member

Short Summary (TL;DR)

When a pull request changes a container image, CI now builds and pushes that image by itself, instead of a maintainer noticing and running push-tagged-image.yml by hand. Forked PRs get the same treatment, but a maintainer has to approve the build and push.

The Issue

Phase 1 (#8612) gave every image a content-addressed <branch>-<hash> tag and made make build a changed image locally, updating versionconstants.go automatically. Getting that image into the registry was still manual, and fork contributors couldn't do it at all.

How This PR Solves The Issue

One rule for which tag an image needs. containers/required-image-tag.sh resolves it the same way autotag.sh does — the tag committed in versionconstants.go if its hash still matches the content, otherwise a fresh <branch>-<hash>. detect, the Buildkite/GitHub test runners, and make therefore all agree on the same tag, and a PR that touches containers/ without changing an image builds nothing.

Build and push are separate workflows, so a push secret never shares a job with fork content.

  • image-build-push.yml (untrusted side). detect resolves each image's tag and checks the registry. For a fork PR, build compiles per-arch with no secrets anywhere in the job and uploads a docker save tarball plus metadata. For anything else — a push, or a same-repo PR — build-and-push builds and pushes directly with no approval gate, the same trust level main-build.yml already runs at.
  • image-push.yml (trusted side). Fires on workflow_run, so it always runs the default-branch copy of itself and never checks out the PR's code. It re-validates the tag and every repository name out of the artifact (validate-image-tag.sh, validate-image-repo.sh), pushes, assembles the multi-arch manifest, and comments on the PR. Only this job carries the image-push environment, so the approval is requested once, and only when there is something to push.

A ddev-dbserver change builds and pushes all 20 variants together, not just the default one. All 20 share one tag (BaseDBTag), so a build that only covered mariadb_11.8 left the other 19 pointing at a tag nobody published. detect now expands to 36 build jobs (one per image/arch; the four oldest variants are amd64-only), reading the matrix from containers/ddev-dbserver/variants.txt. push-tagged-image.yml and push-tagged-dbimage.yml were also updated to read that same list instead of keeping their own hardcoded copies.

Test runners wait for the registry. No test runner holds push credentials, so containers/wait-for-images.sh polls for the tags this commit actually pulls before anything starts pulling. It doesn't wait for an image whose content changed — make builds that one locally on the runner.

Manual Testing Instructions

One-time setup, already done on ddev-test/ddev and ddev/ddev: a GitHub Environment named image-push with required reviewers, and PUSH_SERVICE_ACCOUNT_TOKEN as a secret scoped to it. Verify the rule actually took with gh api repos/<owner>/<repo>/environments/image-push — an environment referenced before it exists is auto-created with no protection.

On ddev-test/ddev:

  1. A PR touching no containers/ file — every test job should print five wait-for-images.sh: found … lines within seconds, nothing else runs.
  2. A containers/ file outside any image's hash paths — detect reports "already exists" for everything, builds nothing.
  3. Edit a single image's Dockerfile, run make, push to a same-repo branch — detect lists only that image, builds and pushes with no approval, and comments on the PR.
  4. Same edit from a fork — build has no secret-loading step, image-push asks for approval once, then pushes and comments.
  5. Fork PR touching containers/ with no image change — no approval request at all.
  6. A ddev-dbserver change — detect reports 36 build jobs across 20 images, and all 20 get pushed.
  7. push-tagged-dbimage.yml, run manually with an empty tag input and again with an explicit vX.Y.Z — both should push all 20 variants.
  8. A branch name with shell metacharacters — it should show up sanitized in the tag, never executed.

Verified end-to-end on ddev-test/ddev: all eight items above passed, including the fork-PR and db-variant-matrix paths.

Two bugs found and still open, both fork-PR-specific and fail closed (not security holes):

  • A fork PR's build/detect step can't read the repo's real DOCKER_ORG — GitHub doesn't expose repo variables to a fork-triggered pull_request run, so it silently falls back to the hardcoded literal ddev. This only bites when a repo's real DOCKER_ORG differs from that fallback (as ddev-test/ddev does on purpose, to test in isolation) — production ddev/ddev is unaffected today, but this is worth fixing before DOCKER_ORG there ever changes.
  • The PR-comment step can't find a fork's commit (listPullRequestsAssociatedWithCommit only sees commits that live in the base repo) and silently skips commenting, while still reporting success. A fork contributor whose images pushed fine would see no confirmation on their PR.

Not testable without a runner token or a temporary edit to ddev-test/ddev's shared main branch: a tampered build artifact (adversarial repos.txt) and an expired-artifact approval. Both are covered by direct script tests (validate-image-repo.sh rejects a disallowed repo) instead.

Automated Testing Overview

Seven bash harnesses (131 checks) run in container-tests.yml's existing unit-test job — autotag, db_variants, required_image_tag, registry_tag_exists, validate_image_tag, validate_image_repo, wait_for_images. They stub docker/sleep and use a throwaway versionconstants.go, so no daemon, network, or registry is needed. No Go code changed.

Release/Deployment Notes

No behavior change for anyone not touching containers/. The build/push path activates only when an image's content hash differs from the tag already published for it. The two open fork-PR bugs above should be fixed or explicitly accepted before merge.

Still a draft: the image-push environment on ddev/ddev hasn't been exercised against the production DockerHub org yet. Don't approve a push job there until that's intentional.

@rfay
rfay force-pushed the 20260814_rfay_docker_update_phase_2 branch 2 times, most recently from c887196 to 99d93be Compare August 15, 2026 01:56
@rfay rfay changed the title feat(containers): fork-safe automatic image build/push and registry-aware CI/Buildkite, for #8609 feat(images): Automatically push and then test new images when changes made, fixes #8609 Aug 16, 2026
@rfay
rfay force-pushed the 20260814_rfay_docker_update_phase_2 branch from 3b8dd0b to 33c06ba Compare August 16, 2026 01:13
@github-actions github-actions Bot added the dependencies Pull requests that update a dependency file label Aug 16, 2026
@github-actions

github-actions Bot commented Aug 16, 2026 •

Copy link
Copy Markdown

@rfay

rfay commented Aug 16, 2026

Copy link
Copy Markdown
Member Author

Manual test results (on ddev-test/ddev)

Ran through HANDOFF.md's full manual test plan. Results:

# Test Result
MUST-1 ddev-dbserver change builds/pushes all 20 variants ✅ Pass — 36 build jobs, 20 images, all confirmed pushed, downstream db test suite passed
MUST-2 push-tagged-dbimage.yml manual run (empty tag + explicit vX.Y.Z) ✅ Pass — both paths, correct 36-job matrix, correct multi-arch split
1 PR touching no containers/ file ✅ Pass — five wait-for-images.sh: found … lines within seconds, nothing else runs
2 containers/ file outside any image's hash paths ✅ Pass — detect reports "already exists" for all 24 images, 0 build jobs
3 Same-repo image change ✅ Pass — full detect → build-and-push → manifest → PR comment flow
4 Fork PR touching multiple images ✅ Pass — no secrets in build, exactly one approval, download succeeds, push succeeds (see bugs below)
5 Fork PR touching containers/ with no image change ✅ Pass — zero approval requests
6 Adversarial artifact (tampered repos.txt) ⚠️ Verified at the script level only (validate-image-repo.sh rejects a disallowed repo). Live artifact tampering needs a runner token or a temporary edit to a shared main branch, neither of which was practical here
7 Hostile branch name ✅ Pass, live — evil";id;# sanitized to evil-id- in the pushed tag, no code execution
8 Expired artifact ⏭️ Skipped — forcing retention expiry isn't practical to test quickly

Two bugs found, both fork-PR-specific and fail closed (not security holes)

  1. DOCKER_ORG isn't available to a fork PR's build/detect job. GitHub doesn't expose repo variables to a fork-triggered pull_request run, so it silently falls back to the hardcoded literal ddev. Only bites when a repo's real DOCKER_ORG differs from that fallback — ddev-test/ddev hits this on purpose (isolated test org), production ddev/ddev doesn't today, but it's worth fixing before DOCKER_ORG there ever changes.

  2. The PR-comment step silently no-ops for fork PRs. listPullRequestsAssociatedWithCommit only resolves commits that live in the base repo, so it can't find a fork's commit, logs "No pull request associated ... skipping comment," and still reports success. A fork contributor whose images pushed fine gets no visible confirmation on their PR.

Both are now noted in the PR description. Test PRs (#31–#37 on ddev-test/ddev) are left open as evidence.

rfay added a commit to ddev-test/ddev that referenced this pull request Aug 16, 2026
…ment step, for ddev#8609

`listPullRequestsAssociatedWithCommit` only finds a commit within the repo
it's queried against. The push-comment step always queried the base repo,
so it silently skipped commenting on any fork PR - a fork-authored commit
never lives in the base repo's own history - while still reporting success.

Query `workflow_run.head_repository` (the fork, for a fork PR) instead, then
filter the results to PRs whose base actually is this repo, in case the
commit is associated with an unrelated PR elsewhere.

Found while manually testing PR ddev#8707's fork-PR path on ddev-test/ddev.
rfay and others added 9 commits August 17, 2026 00:38
…ware CI/Buildkite, for ddev#8609

Phase 2 of ddev#8609: CI now detects a changed container image, waits for a maintainer's approval, and builds/pushes it automatically for both maintainer and fork PRs, without ever exposing the DockerHub push token to a job that runs fork-supplied build content. Buildkite no longer races the push.

- Phase 2 of ddev#8609

Phase 1 (ddev#8612) gave every image a content-addressed tag and made `make` auto-build changed images locally. The CI/registry side was untouched: a maintainer still had to notice a container changed and manually run `push-tagged-image.yml`/`push-tagged-dbimage.yml`, and fork contributors couldn't get an image change pushed without a maintainer doing it by hand.

Two new workflows split build from push so a push secret never shares a job with untrusted (fork) build content:

- `image-build-push.yml` (untrusted side, no secrets anywhere): a `detect` job recomputes each image's real content hash and checks the registry directly (never trusting the tag string committed in `versionconstants.go`, so a fork can't forge it); an `approval` job gates on the new `image-push` GitHub Environment before any expensive/untrusted build work runs; a `build` job builds per-arch using the same local-build Makefile targets Phase 1's `autotag-images` already uses, then uploads a `docker save` tarball plus tag metadata as an artifact.
- `image-push.yml` (trusted side): triggered by `workflow_run` once the build workflow completes, so it always runs the default-branch version of itself and never checks out or executes the PR's code. It downloads the artifact, re-validates the tag against a strict format + reserved-tag blocklist (`containers/validate-image-tag.sh`), loads and pushes each per-arch image, assembles the multi-arch manifest, and comments on the PR.

New scripts: `containers/registry-tag-exists.sh` (registry existence check, the same `docker buildx imagetools inspect` idiom already used in the post-push wait-loop) and `containers/validate-image-tag.sh`, both with bash test harnesses matching `containers/autotag_test.sh`'s style.

Buildkite gets a `.buildkite/wait-for-images.sh` self-guarding step (wired into `test.sh`/`perf.sh`) that polls the registry for the tags a checkout actually needs before pulling anything, instead of racing the push - implementing the "lighter" option from the issue's open Buildkite decision.

The existing `push-tagged-image.yml`/`push-tagged-dbimage.yml` are untouched and remain for manual re-pushes and the 18 `ddev-dbserver` variants Phase 1 doesn't auto-build.

Requires one-time setup on the test repo (see `release-management.md`'s new "One-time setup" section): create a GitHub Environment named `image-push` with required reviewers, and add `PUSH_SERVICE_ACCOUNT_TOKEN` as a secret scoped to that environment.

1. Run the new unit tests directly: `containers/registry_tag_exists_test.sh` and `containers/validate_image_tag_test.sh` (no Docker daemon or network needed).
2. On a test repo (`image-push.yml` must be on its default branch - `workflow_run` triggers only fire for the default-branch copy of the listening workflow), push a trivial change to `containers/ddev-xhgui/` on a branch and open a PR. Confirm: `detect` flags it, `approval` blocks `build` until a reviewer approves, `build` produces artifacts with no secrets referenced in that job, `image-push` fires on completion (its own approval), loads and pushes the image, and comments on the PR.
3. Negative test: hand-edit `versionconstants.go` on that branch to a bogus `latest-<fakehash>`-shaped tag and confirm `detect` ignores it (recomputes the real hash from content) and that `containers/validate-image-tag.sh` rejects a manufactured `latest`/`vX.Y.Z` tag directly.

Two new bash test harnesses (`containers/registry_tag_exists_test.sh`, `containers/validate_image_tag_test.sh`) stub `docker`/use pure string checks, no daemon or network required, wired into `container-tests.yml`'s existing unit-test job alongside `autotag_test.sh`. No Go code changed.

No behavior change for anyone not touching `containers/`. Requires one-time manual GitHub Environment setup (documented) before the automatic push path is live on a given repo; until then `detect`/`approval`/`build` still run harmlessly (approval job would just wait indefinitely with no reviewers configured).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WqmDPsdWxQjwGu3LFNzGLg
…ix, for ddev#8609

The automatic build/push flow (and Phase 1's autotag-images before it) only
auto-builds the default ddev-dbserver variant (mariadb_11.8). Tests exercising
other db types/versions (TestDdevAllDatabases and similar) still need a manual
push. Confirmed via a live test run on ddev-test/ddev that this is working as
designed, not a bug - recording it as a follow-up to revisit, likely by moving
full-matrix builds later in the flow rather than the pre-approval detect/build
stage, since building all ~19 variants on every PR would be expensive.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WqmDPsdWxQjwGu3LFNzGLg
…recation warning

Caught via a live test run on ddev-test/ddev: image-push.yml's use of
actions/download-artifact@v4 still targets Node 20 internally, which GitHub
now flags as deprecated and force-runs on Node 24 anyway. v8 uses Node 24
natively with the same github-token/run-id/pattern/path inputs, so this is a
straight version bump, not a behavior change.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WqmDPsdWxQjwGu3LFNzGLg
…t, for ddev#8609

Caught via a live test run on ddev-test/ddev: unlike push-tagged-image.yml and
push-tagged-dbimage.yml, image-push.yml wasn't cleaning up the intermediary
<tag>-amd64/<tag>-arm64 tags after assembling the multi-arch manifest, leaving
them on DockerHub permanently. Adds the same JWT-token DELETE cleanup those
workflows already do, right after each docker buildx imagetools create call.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WqmDPsdWxQjwGu3LFNzGLg
…sh race Buildkite has, for ddev#8609

## Short Summary (TL;DR)

test-reusable.yml and test-wsl2-reusable.yml pull pinned images the same way Buildkite does - a fresh runner never builds a changed image itself, so they can race image-push.yml's approval/build/push exactly like Buildkite could. Adds the same wait-for-images.sh guard there too, and moves the script out of .buildkite/ since it's no longer Buildkite-specific.

## The Issue

Related to ddev#8609 (phase 2). Confirmed live on ddev-test/ddev PR #30: a `containers/ddev-xhgui` change passed "Test Nginx-FPM" regardless of push status only because that test never pulls ddev-xhgui (it's gated behind XHProf mode). If the changed image had been ddev-webserver (used by nearly every test), or a test that does exercise xhgui had run, it would have raced the push and failed on the pull - `autotag.sh`'s no-op fast path trusts the committed tag without verifying the image exists anywhere, and a brand-new GitHub-hosted runner has no local build to fall back on.

## How This PR Solves The Issue

- Moves `wait-for-images.sh` from `.buildkite/` to `containers/`, since both Buildkite and the GitHub-hosted test workflows need it now.
- Adds a "Wait for pushed images" step to `test-reusable.yml`, right after the public-variables fetch and before anything Docker-dependent.
- Adds the equivalent call to `.github/workflows/wsl2-test.sh` (the script `test-wsl2-reusable.yml` runs inside the WSL2 guest), right after Docker is confirmed ready and before `make` builds the binary.
- Fixes a latent bug the new test caught: `tag="$(tag_for "$tag_var")"` silently killed the whole script under `set -e -o pipefail` when a tag var was missing from `versionconstants.go`, before ever reaching the intended "could not find..." error message. Same pattern exists in Phase 1's `autotag.sh` (`EXISTING_TAG="$(grep ... | sed ...)"`) - confirmed it has the identical silent-death bug, but left it alone since it's already-shipped code and this PR's scope is the wait-for-images guard; flagging separately.
- Adds `containers/wait_for_images_test.sh` (same bash-harness style as `autotag_test.sh`), covering the fast path, eventual recovery within budget, giving up after exhausting the budget, and the missing-tag-var error path. Wired into `container-tests.yml`.

## Manual Testing Instructions

Run `containers/wait_for_images_test.sh` directly (stubs `docker`/`sleep`, no daemon or network). For the real path: open a PR that changes an image test-reusable.yml/test-wsl2-reusable.yml actually depend on (e.g. `containers/ddev-webserver`) before approving the corresponding `image-push` run, and confirm the "Wait for pushed images" step polls rather than failing outright, then succeeds once the push lands.

## Automated Testing Overview

New `containers/wait_for_images_test.sh`, run directly and via `container-tests.yml`'s unit-test job alongside the other containers/ bash tests.

## Release/Deployment Notes

No behavior change when nothing changed under `containers/` (fast path, single registry check per image, no wait). Only affects PRs where an auto-managed image's tag doesn't yet exist in the registry.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WqmDPsdWxQjwGu3LFNzGLg
…est workflows

The previous commit only staged the .buildkite -> containers rename (a
mis-staged `git add` silently dropped everything else). This commit carries
the actual content: the new "Wait for pushed images" steps in
test-reusable.yml and wsl2-test.sh, the wait-for-images.sh silent-exit fix,
the new containers/wait_for_images_test.sh, and its wiring into
container-tests.yml. See the previous commit's message for the full
rationale.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WqmDPsdWxQjwGu3LFNzGLg
… for ddev#8609

## Short Summary (TL;DR)

A push to `main` or a same-repo PR (no fork involved) no longer needs any manual approval to build/push a changed container image - only actual fork PRs still go through the two-approval fork-safe flow. Reported as awkward friction on ddev-test#30, where a maintainer-pushed, non-fork PR still required two approval clicks.

## The Issue

Related to ddev#8609 (phase 2). The `approval` gate (before `build`) and `image-push.yml`'s own approval exist purely because of the fork threat model: GitHub won't hand secrets to a job running a fork's Dockerfile, and even if it would, you don't want to. Neither concern applies to a `push` event (only write-access collaborators can push branches to the base repo) or a same-repo PR (head and base are the same repo, exactly as trusted as `main-build.yml`, which already uses this same secret unguarded). Gating those cases behind an approval was unjustified friction, not a security requirement.

## How This PR Solves The Issue

`detect` now also computes `is_fork` using the same fork-check idiom already used in `push-tagged-image.yml`/`push-tagged-dbimage.yml`/`test-pull-push-providers.yml` (`github.event.pull_request.head.repo.owner.login != github.repository_owner`, false for any non-`pull_request` event). Jobs branch on it:

- `is_fork == 'true'`: unchanged `approval` -> `build` (no secrets, artifact hand-off) -> `image-push.yml` (its own approval) flow.
- `is_fork == 'false'`: new `build-and-push` job builds and pushes directly per arch, then `create-manifests` assembles the multi-arch manifest, cleans up the intermediary per-arch tags, and comments on the PR if there is one. Neither job declares `environment: image-push`, so they read `PUSH_SERVICE_ACCOUNT_TOKEN` as a plain repository secret with no approval gate - the same access level `main-build.yml` already has.

Updated `building-contributing.md`/`release-management.md` to describe the fork-vs-non-fork split instead of a blanket "one approval click."

## Manual Testing Instructions

Replayed the `is_fork` bash logic directly against `pull_request`-from-fork, `pull_request`-same-repo, and `push` event shapes - resolves to `true`/`false`/`false` respectively. Replayed `create-manifests`' push/imagetools-create/cleanup logic against a stubbed `docker`/`curl` - confirms both `ddev-webserver` and `ddev-webserver-prod` get manifests created and per-arch tags cleaned up. On `ddev-test/ddev`: push directly to a branch (non-fork) with a container change and confirm no approval prompt appears at all before the image is pushed.

## Automated Testing Overview

No new bash test files (this is workflow-YAML branching); verified via direct bash replay of the fork-detection and manifest-creation logic (see above), plus `make staticrequired`.

## Release/Deployment Notes

Reduces friction for maintainer/same-repo workflows; fork PRs are unaffected and keep the full two-approval flow.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WqmDPsdWxQjwGu3LFNzGLg
…ovals, for ddev#8609

## Short Summary (TL;DR)

The pre-build and pre-push approvals both showed up as "image-push" in GitHub's approval prompt, since that's the environment name it surfaces, not the job name - making it hard to tell which one a reviewer was being asked about. The pre-build gate now uses its own `image-build-approval` environment.

## The Issue

Related to ddev#8609 (phase 2). Reported after testing on ddev-test/ddev: "Review pending deployments" only distinguishes by environment name, and both approval points shared `environment: image-push`, so approvers had to dig into which workflow/job they were actually looking at.

## How This PR Solves The Issue

The `approval` job in image-build-push.yml (fork-PR pre-build gate) now uses `environment: image-build-approval` instead of `image-push`. It needs no secret - only `image-push.yml`'s `push` job still needs the DockerHub token, so that's the only one that keeps `environment: image-push`. Sharpened both jobs' `name:` fields ("Approve: build this fork PR's Dockerfile(s)" / "Approve: push the built image(s) to DockerHub") for the same reason. Updated release-management.md's setup checklist to create both environments, and noted that referencing an environment that doesn't exist yet auto-creates it with no protection rules - so it's important to verify each one actually has a `required_reviewers` rule (e.g. via `gh api .../environments/<name>`) before relying on it.

## Manual Testing Instructions

Open a fork PR that changes a container image and confirm the two approval prompts now name different environments (`image-build-approval` then `image-push`). Requires creating the new `image-build-approval` GitHub Environment (with required reviewers, no secret) on the test/target repo first - until then this gate would silently not gate at all.

## Automated Testing Overview

No behavioral logic changed (only environment names/job names), verified via `yaml.safe_load` that both jobs' `environment`/`name` fields resolve as intended, plus the existing containers/*_test.sh suite and `make staticrequired`.

## Release/Deployment Notes

Requires the one-time creation of the `image-build-approval` GitHub Environment before this lands, on both ddev-test/ddev and ddev/ddev, mirroring image-push's required reviewers.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WqmDPsdWxQjwGu3LFNzGLg
rfay added 3 commits August 17, 2026 01:00
…ddev#8609

Every item in the plan has run on ddev-test/ddev: the two MUST-TEST items,
all eight other-human-verification items (two accepted with a noted
limitation), and the two bugs it flagged are fixed. Results are posted as
a PR comment, so the file has no more information than the PR itself.
…R_ORG, for ddev#8609

Every generic public-variables loader (test-reusable.yml, test-wsl2-reusable.yml,
.buildkite/test.sh) runs unconditionally and overwrites every variable it finds,
including DOCKER_ORG now that ddev#8711 added it. That's correct for variables like
DDEV_EMBARGO_TESTS, which must apply everywhere unconditionally, but DOCKER_ORG is
only meant as a fork-PR fallback: a same-repo run's own vars.DOCKER_ORG (e.g.
ddev-test/ddev's ddevhq) was getting silently replaced by whatever the
public-variables branch publishes for forks. Found while reviewing this PR - it
would have broken the very Buildkite test being set up to validate it.

Each loader now skips DOCKER_ORG when it's already non-empty, the same way it
already skips README.md.

Also fixes autotag.sh:77, a duplicate of a pattern this PR already fixed once in
required-image-tag.sh: a missing `var <Tag> = ...` line made the grep|sed pipeline
fail under `set -e`, killing the script before it reached its own "could not find"
error message. Added the same `|| true` required-image-tag.sh uses, plus a test
case (autotag_test.sh) that would have caught the regression.
…sites, for ddev#8609

Found during review: the DOCKER_ORG fallback comment was near-duplicated
between image-build-push.yml's detect and build jobs, and the alias-branch
trust comment was near-duplicated between image-build-push.yml and
image-push.yml. Each now states its rationale once and points the other
call site at it, matching the pattern already used by the DDEV_IMAGE_TAG
comment in build-and-push.
@rfay
rfay marked this pull request as ready for review August 17, 2026 03:28
@rfay
rfay requested review from a team as code owners August 17, 2026 03:28
@rfay
rfay requested a review from stasadev August 17, 2026 03:28
@rfay

rfay commented Aug 17, 2026 •

Copy link
Copy Markdown
Member Author

I think this is working pretty well @stasadev - testing with a ddev-test/ddev PR should work completely. A forked PR doesn't work without fiddling with the DOCKER_ORG on ddev-test/ddev and letting it push to the ddev org. Please see what you think of it.

It won't suprise me if we find flaws after pulling it and have to do some followups. OTOH hopefully it won't affect users.

The last set of tests on my agenda are to see a buildkite pipeline work, which I haven't done yet.

stasadev and others added 7 commits August 17, 2026 21:04
Preparing a release meant hand-editing: append a marker comment to each
Dockerfile so its hash moves, read the new hashes out of `make
check-image-tags`, then edit versionconstants.go by hand. That is how the
v1.106.1 test commit ended up with trailing comments still naming the previous
hashes.

`make release-prep TAG=v1.25.4` does all of it - stamps
`# ddev-release-marker: v1.25.4` into every image's Dockerfile, replacing any
previous marker rather than appending, rewrites each tag to the resulting
content hash, and sets each <TagVar>Branch to the release. A Dockerfile comment
is stripped by the parser, so this moves the hash without changing a layer of
the image. Nothing is built or committed; the images come from the pull
request's own CI run, which is what tests them before the release is cut. The
trailing // <branch>-<hash> comment stays branch-based, since that is the alias
the push publishes - validate-image-tag.sh rejects a release-shaped one.

`make retag-images` is the same rewrite without the markers: autotag-images
minus the Docker work, for a change whose images CI will build. Both go through
a new autotag.sh --no-build, and take their image list from image-configs.sh
rather than repeating it in the Makefile a third time.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…ddev#8609

Getting the release names onto the images meant dispatching
push-tagged-image.yml four times and push-tagged-dbimage.yml once, each of
which rebuilds from scratch - so ddev/ddev-webserver:v1.25.3 was a different
build from the hash tag the v1.25.3 binary actually pulls, and from the one the
tests ran against.

detect now reads the marker release-prep.sh stamps into each Dockerfile, and
create-manifests adds vX.Y.Z and latest as further names on the manifest it is
already creating. One build, tested by the release pull request, published
under every name it needs.

The marker stays in the Dockerfile after the release merges, so both are
skipped when vX.Y.Z is already in the registry - otherwise an unrelated later
change to that image would move a released tag onto a post-release build.
detect also declines to skip an image whose hash exists but whose release tag
does not, which would otherwise leave one image out of the release.

containers/release-marker.sh reads the marker and rejects one that is
malformed or duplicated, so a typo fails the build instead of publishing a tag
nobody meant. The fork path is unaffected: create-manifests is gated on
is_fork, and image-push.yml runs every tag through validate-image-tag.sh, which
rejects a release shape.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
"Image build" fans out to one job per image and arch and finishes in about
six minutes, but everything it produced then went to a single job in
"Image push": 40 artifacts, 9 GB, downloaded together and then loaded,
pushed and manifested one image after another. Run 32057606984 spent 2m22s
downloading and 23m49s in that loop.

check-artifacts now groups the artifact names into one entry per image and
push runs as a matrix over them, each job downloading only its own two
arches and creating its own manifest - the shape push-tagged-dbimage.yml
already uses.

The approval moves to a gate job of its own, so a run is still one click
rather than one per image, and the per-image summaries are collected into
the single pull request comment through an artifact, since matrix jobs
cannot each set the same job output.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…ddev#8609

The scratch repository is a copy of the real containers/, and every check
assumed that copy started with no release marker in it. That holds until
someone runs `make release-prep` - so the test failed on exactly the branch
it most needs to pass on, with "a rejected tag stamps no Dockerfile
(expected '0', got '1')".

The copy is now stripped of markers before the first test runs, and the
rejected-tag check compares every Dockerfile's content rather than counting
webserver's markers, which says what is meant (a refused tag changes
nothing) and no longer depends on where it started.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…dev#8609

download-artifact gives an artifact a directory of its own only when more
than one matched the pattern; a lone match is extracted straight into the
download path. The four amd64-only db variants have exactly one artifact,
so `for dir in artifacts/image-*` matched nothing for them and the push job
reported "the matrix named an image with no artifact".

Both loops now find their input by the file they need rather than by where
the action chose to put it, which also covers the summary collection when a
pull request builds a single image.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…dev#8609

create-manifests, the only job that publishes vX.Y.Z and latest, is gated on
is_fork, and image-push.yml never checks out the pull request's code, so it
cannot see the marker at all. A release branch opened from a fork therefore
rebuilt and pushed all 22 images and silently left the release names off -
which is what ddev-test#42 did.

detect now refuses that combination in its first twenty seconds, before any
image is built and long before the approval, and says to open the release
pull request from a branch in the repository instead. Keeping the fork path
unable to publish a release name is deliberate: validate-image-tag.sh
already rejects release-shaped tags there so that an approval can only ever
publish a hash.

Also corrects the image-push environment setup, which asked for
PUSH_SERVICE_ACCOUNT_TOKEN to be moved onto the environment. Nothing reads
it there: the non-fork path never declared an environment, and since the
push was parallelised neither do the per-image push jobs.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

@stasadev stasadev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

rfay added 2 commits August 17, 2026 18:17
…dev#8609

Image tags like BaseDBTag are content hashes, not branch-scoped, so two
concurrent builds of identical container content can both target the
same repo:TAG. Whichever finishes create-manifests first publishes the
manifest and deletes the per-arch staging tags; the other then fails
with "not found" trying to build the manifest from those same
now-deleted arch tags, and keeps failing on retry since the arch tags
never come back.

create-manifests now checks whether repo:TAG already exists before
building the manifest. If a concurrent build already published it,
alias/release tags are created from that existing manifest instead of
the per-arch tags, instead of crashing.
@rfay

rfay commented Aug 18, 2026

Copy link
Copy Markdown
Member Author

I fiddled with just a tiny bit of comments and docs. Then I tested one more PR and had a seemingly unrecoverable failure (mariadb:10.2 didn't succeed in being pushed or getting included in manifest). One more commit to hopefully fix that. It wasn't confidence building, but OTOH it's too hard to work in this situation so it's time to get it pulled and see if we can live with it. And understand it.

@rfay
rfay merged commit a6ff2e7 into ddev:main Aug 18, 2026
50 of 55 checks passed
@rfay
rfay deleted the 20260814_rfay_docker_update_phase_2 branch August 18, 2026 04:34
rfay added a commit that referenced this pull request Aug 18, 2026
 #8609

## Short Summary (TL;DR)

quickstart.yml, perf-start-time.yml, perf-linux.yml, and the Windows
installer test each build or start ddev without waiting for image-push.yml's
async push, so they can race a content-tagged image that hasn't landed on
Docker Hub yet. Add the same containers/wait-for-images.sh step that
test-reusable.yml, test-wsl2-reusable.yml, and the Buildkite test.sh/perf.sh
legs already use.

## The Issue

- Fixes #8609

#8707 added content-hash image tags built and pushed asynchronously by
image-push.yml, and added a wait-for-images.sh step to test-reusable.yml and
wsl2-test.sh to avoid racing that push. It missed quickstart.yml,
perf-start-time.yml, perf-linux.yml, and the Windows installer pipeline.
PR #8705's perf-start-time run failed with `ddev-dbserver-mariadb-11.8:...:
not found`, and two quickstart runs on PRs rebased past the same commit
failed identically inside `ddev start` for `dummy-project` (output
swallowed by `>/dev/null 2>&1`, so it just looked like a bare `Error 1`).

## How This PR Solves The Issue

Adds a `Wait for pushed images` step (`containers/wait-for-images.sh`) to
quickstart.yml, perf-start-time.yml, and perf-linux.yml, and the equivalent
inline call to installer-test.sh, all placed the same way as the existing
callers: after public-variables/DOCKER_ORG is available, before anything
that pulls or builds a DDEV image. Audited every other GitHub Actions
workflow and Buildkite pipeline: the rest either route through
test-reusable.yml/test-wsl2-reusable.yml/test.sh/perf.sh (already covered)
or never pull a pre-built image tag (cross-compile jobs, the image-build/push
jobs themselves, docs/lint jobs).

## Manual Testing Instructions

- `actionlint .github/workflows/quickstart.yml .github/workflows/perf-start-time.yml .github/workflows/perf-linux.yml` - no new findings (one pre-existing shellcheck warning in quickstart.yml predates this change).
- `bash -n .buildkite/installer-test.sh` - syntax OK.
- Re-run the quickstart and perf-start-time workflows on a PR rebased past an image-only commit; both should now block on wait-for-images.sh instead of failing with an image-not-found error.

## Automated Testing Overview

No new tests - this only reorders CI steps to reuse the existing,
already-tested containers/wait-for-images.sh script.

## Release/Deployment Notes

CI-only change. Adds up to ~20 minutes of wait time (only when a relevant
image actually changed and hasn't finished pushing yet; fast path is a
single registry check per image otherwise).
rfay added a commit that referenced this pull request Aug 21, 2026
…authorized authors [skip ci]

Moves the maintainer approval for a fork PR's image build/push from after the build finishes to right after detect knows a build is needed, and skips it entirely when the PR author already has push access to the repo.

Follow-up to #8707. Two rough edges in the fork-PR image build/push flow:

1. The approval gate lived in image-push.yml, triggered via workflow_run only after the entire (often multi-minute, multi-arch) fork build finished. A maintainer had no visibility into the pending approval until well after it was actually knowable.
2. A maintainer's own fork PR (author_association OWNER/MEMBER/COLLABORATOR) still had to wait on the same approval as an unknown external contributor, even though they already have push access.

- image-build-push.yml's detect job gains an `is_authorized` output (from `github.event.pull_request.author_association`) alongside the existing `is_fork`.
- A new `approve` job runs right after detect, gated on the `image-push` environment, only when the PR is from a fork and the author is not authorized. The `build` job now depends on it.
- image-push.yml no longer has its own approval gate — by the time an artifact exists to push, image-build-push.yml's `approve` job already required sign-off.
- Updated the workflow header comments and the two docs pages (building-contributing.md, release-management.md) that described the old flow.
- Added a bullet to CLAUDE.md's Comments section: write comments as a plain description of the current design, not framed relative to what changed.

- `actionlint .github/workflows/image-build-push.yml .github/workflows/image-push.yml` passes clean.
- Open a PR from an external fork that touches `containers/**`: confirm the `image-push` environment approval request appears as soon as the "Image build" workflow's `detect` job completes, not after `build` finishes.
- Open a PR from a maintainer's own fork: confirm no approval is requested and the image still builds and pushes via the existing fork-safe split.
- Open a same-repo PR or push to main: confirm behavior is unchanged (no gate, direct build-and-push).

No new automated tests — this is GitHub Actions workflow orchestration, validated with actionlint and manual PR runs as described above.

No user-facing behavior change. Affects only the internal container image build/push CI flow for ddev/ddev.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
rfay added a commit to ddev-test/ddev that referenced this pull request Aug 24, 2026
* fix(ci): wait for pushed images reliably, fixes ddev#8609 (ddev#8712)

Co-authored-by: Claude Sonnet 5 <[email protected]>

* test(mutagen): Minor test cleaup (ddev#8719)

* fix(images): gate fork image builds on approval earlier, skip it for authorized authors [skip ci]

Moves the maintainer approval for a fork PR's image build/push from after the build finishes to right after detect knows a build is needed, and skips it entirely when the PR author already has push access to the repo.

Follow-up to ddev#8707. Two rough edges in the fork-PR image build/push flow:

1. The approval gate lived in image-push.yml, triggered via workflow_run only after the entire (often multi-minute, multi-arch) fork build finished. A maintainer had no visibility into the pending approval until well after it was actually knowable.
2. A maintainer's own fork PR (author_association OWNER/MEMBER/COLLABORATOR) still had to wait on the same approval as an unknown external contributor, even though they already have push access.

- image-build-push.yml's detect job gains an `is_authorized` output (from `github.event.pull_request.author_association`) alongside the existing `is_fork`.
- A new `approve` job runs right after detect, gated on the `image-push` environment, only when the PR is from a fork and the author is not authorized. The `build` job now depends on it.
- image-push.yml no longer has its own approval gate — by the time an artifact exists to push, image-build-push.yml's `approve` job already required sign-off.
- Updated the workflow header comments and the two docs pages (building-contributing.md, release-management.md) that described the old flow.
- Added a bullet to CLAUDE.md's Comments section: write comments as a plain description of the current design, not framed relative to what changed.

- `actionlint .github/workflows/image-build-push.yml .github/workflows/image-push.yml` passes clean.
- Open a PR from an external fork that touches `containers/**`: confirm the `image-push` environment approval request appears as soon as the "Image build" workflow's `detect` job completes, not after `build` finishes.
- Open a PR from a maintainer's own fork: confirm no approval is requested and the image still builds and pushes via the existing fork-safe split.
- Open a same-repo PR or push to main: confirm behavior is unchanged (no gate, direct build-and-push).

No new automated tests — this is GitHub Actions workflow orchestration, validated with actionlint and manual PR runs as described above.

No user-facing behavior change. Affects only the internal container image build/push CI flow for ddev/ddev.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* Emit some info about auth choice [skip ci]

* don't skip the push when authorized [skip ci]

* first try pr as rfay

* build(ci): Try it again, but this time rebased

* try it again

---------

Co-authored-by: Randy Fay <[email protected]>
Co-authored-by: Claude Sonnet 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants