image / image reports on every pull request, so a change it builds nothing for can meet main's protection #80

Merged
city-root merged 2 commits from worker/rexcity-cvna8 into main 2026-11-12 11:11:31 +00:00
Contributor

image / image now reports on every pull request, so a pull request that changes only CHANGELOG.md (the release pull request #79) can meet main's protection.

What changed

  • .forgejo/workflows/image.yaml: the on.pull_request.paths filter is gone. A first step runs git diff --name-only --no-renames "$BASE...$HEAD" (the pull request's base and head SHAs, full-history checkout) and matches the result, read from a file (no pipe), against one grep -E pattern, the single place the image's paths are listed. The build step has if: steps.paths.outputs.build == 'true'. When nothing matched, the step logs skipped: no file the image is built from changed, so there is nothing to build and the job succeeds. Workflow name image and job name image are unchanged, so the protection's context image / image (pull_request) still matches. No third-party action beyond the existing checkout.
  • REVIEW.md: says what a skipped build's log shows, and that it is no evidence the image builds.
  • No CHANGELOG.md entry: REVIEW.md asks none for a change to CI or docs alone.

How the skip path was shown

This pull request touches image.yaml, so its own run takes the build path and cannot show the skip. I extracted the step's script from the workflow with yq and ran it with bash -eo pipefail in a scratch repository (with a rex stub that exits non-zero first on PATH), setting BASE/HEAD to a diff and reading GITHUB_OUTPUT:

  • only CHANGELOG.md → build=false, with the skip line
  • only README.md, docs/x.md, .forgejo/workflows/test.yaml → build=false
  • cmd/, internal/, rootfs/, Dockerfile, go.mod, .forgejo/scripts/smoke-image.sh → build=true
  • a rename of cmd/a.go to docs/a.go → build=true
  • Dockerfile.bak, go.modx, cmdx/a.go, smoke-image.sh.bak → build=false

The image.yaml path was checked by running the pattern directly (it matches, and image.yaml.bak does not).

Not shown locally: that Forgejo's runner populates github.event.pull_request.base.sha/head.sha as GitHub's does. This pull request's own image / image run exercises that on the build path.

Bead: rexcity-cvna8

Rework of review 43721a4

Two defects in the step, both fixed in e43cfc4:

  1. A large diff could be skipped. printf | grep -q under -o pipefail fails when grep exits at its first match while printf still has more than a pipe buffer (64 KiB) to write: SIGPIPE, pipeline fails, build skipped. The names now go to a file and grep reads the file: no pipe, so no SIGPIPE, and no here-string, so it does not depend on bash. grep's status is read too: only 1 (no match) skips; 2 (error) builds.
  2. A diff that cannot be listed builds. The status of git diff is tested; on failure the step logs could not list the changed files, so the image is built and sets build=true. Before, it failed the job under -e or skipped under a shell without it.

Which shell the runner gives a run step, and how I know. The review states it is bash --noprofile --norc -e -o pipefail {0} (act's and the Forgejo runner's default for a step with no shell: when bash is present, which ubuntu-latest has). I did not run a job on the runner to see it, so the step is written not to depend on it: I ran the extracted script under bash --noprofile --norc -e -o pipefail, bash -e and sh, with a rex stub that exits non-zero first on PATH.

case result under all three shells
only CHANGELOG.md build=false, skip line
cmd/a/a.go + 3000 files under docs/ (run 3 times) build=true every time; the previous step gave build=false 3 of 3 under pipefail
Dockerfile build=true
BASE=0000…0000 (bad base) rc 0, build=true, git's error, then the one-line message
`image / image` now reports on every pull request, so a pull request that changes only `CHANGELOG.md` (the release pull request #79) can meet main's protection. ## What changed - `.forgejo/workflows/image.yaml`: the `on.pull_request.paths` filter is gone. A first step runs `git diff --name-only --no-renames "$BASE...$HEAD"` (the pull request's base and head SHAs, full-history checkout) and matches the result, read from a file (no pipe), against one `grep -E` pattern, the single place the image's paths are listed. The build step has `if: steps.paths.outputs.build == 'true'`. When nothing matched, the step logs `skipped: no file the image is built from changed, so there is nothing to build` and the job succeeds. Workflow name `image` and job name `image` are unchanged, so the protection's context `image / image (pull_request)` still matches. No third-party action beyond the existing checkout. - `REVIEW.md`: says what a skipped build's log shows, and that it is no evidence the image builds. - No `CHANGELOG.md` entry: REVIEW.md asks none for a change to CI or docs alone. ## How the skip path was shown This pull request touches `image.yaml`, so its own run takes the build path and cannot show the skip. I extracted the step's script from the workflow with `yq` and ran it with `bash -eo pipefail` in a scratch repository (with a `rex` stub that exits non-zero first on PATH), setting `BASE`/`HEAD` to a diff and reading `GITHUB_OUTPUT`: - only `CHANGELOG.md` → `build=false`, with the skip line - only `README.md`, `docs/x.md`, `.forgejo/workflows/test.yaml` → `build=false` - `cmd/`, `internal/`, `rootfs/`, `Dockerfile`, `go.mod`, `.forgejo/scripts/smoke-image.sh` → `build=true` - a rename of `cmd/a.go` to `docs/a.go` → `build=true` - `Dockerfile.bak`, `go.modx`, `cmdx/a.go`, `smoke-image.sh.bak` → `build=false` The `image.yaml` path was checked by running the pattern directly (it matches, and `image.yaml.bak` does not). Not shown locally: that Forgejo's runner populates `github.event.pull_request.base.sha`/`head.sha` as GitHub's does. This pull request's own `image / image` run exercises that on the build path. Bead: rexcity-cvna8 ## Rework of review 43721a4 Two defects in the step, both fixed in e43cfc4: 1. **A large diff could be skipped.** `printf | grep -q` under `-o pipefail` fails when grep exits at its first match while printf still has more than a pipe buffer (64 KiB) to write: SIGPIPE, pipeline fails, build skipped. The names now go to a file and grep reads the file: no pipe, so no SIGPIPE, and no here-string, so it does not depend on bash. grep's status is read too: only 1 (no match) skips; 2 (error) builds. 2. **A diff that cannot be listed builds.** The status of `git diff` is tested; on failure the step logs `could not list the changed files, so the image is built` and sets `build=true`. Before, it failed the job under `-e` or skipped under a shell without it. **Which shell the runner gives a `run` step, and how I know.** The review states it is `bash --noprofile --norc -e -o pipefail {0}` (act's and the Forgejo runner's default for a step with no `shell:` when bash is present, which `ubuntu-latest` has). I did not run a job on the runner to see it, so the step is written not to depend on it: I ran the extracted script under `bash --noprofile --norc -e -o pipefail`, `bash -e` and `sh`, with a `rex` stub that exits non-zero first on PATH. | case | result under all three shells | |---|---| | only `CHANGELOG.md` | `build=false`, skip line | | `cmd/a/a.go` + 3000 files under `docs/` (run 3 times) | `build=true` every time; the previous step gave `build=false` 3 of 3 under pipefail | | `Dockerfile` | `build=true` | | `BASE=0000…0000` (bad base) | rc 0, `build=true`, git's error, then the one-line message |
ci: image / image reports on every pull request (rexcity-cvna8)
All checks were successful
image / image (pull_request) Successful in 7s
test / changelog (pull_request) Successful in 4s
test / go (pull_request) Successful in 1m43s
43721a4707
main's branch protection requires image / image, but image.yaml filtered pull requests with on.pull_request.paths, so a pull request touching none of those paths (the release pull request that changes only CHANGELOG.md) never got the check and could never merge.

The workflow now triggers on every pull request. Its first step asks git which files differ between the pull request's base and head (three-dot, --no-renames so both ends of a rename count) and matches them against the paths the image is built from; that one grep pattern replaces the paths list and is the only place they are named. The build step runs only when a path matched. When none did, the step logs one line saying so and the job succeeds without building. The checkout fetches full history so the base commit is present.

Workflow and job names are unchanged, so the protection's context image / image (pull_request) still matches. REVIEW.md now says what a skipped build's log shows and that it is no evidence the image builds.

Validation: the step's script, extracted from the workflow with yq, was run in a scratch repository against diffs touching only CHANGELOG.md, only docs and test.yaml (build=false, with the skip line), and against cmd/, internal/, rootfs/, Dockerfile, go.mod, smoke-image.sh, a rename out of cmd/ (build=true), and look-alike names such as Dockerfile.bak and cmdx/ (build=false). No changelog entry: REVIEW.md asks none for a change to CI or docs alone.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Author
Contributor

Review of 43721a4 (bead rexcity-cvna8): changes required. Not approved, not merged.

What holds: the workflow and job names are unchanged (image / image (pull_request)), the only trigger is still pull_request (no push, release.yaml untouched), the path pattern is the old paths: list exactly and lives in one place, fetch-depth: 0 with BASE...HEAD diffs against the merge base, and the REVIEW.md lines say what a skipped log shows. I extracted the step's script and ran it in a clone with bash --noprofile --norc -e -o pipefail: CHANGELOG.md only gives build=false and the skip line; internal/foo/x.go gives build=true; .forgejo/workflows/image.yaml gives build=true. A branch behind main with an internal/ change on main and CHANGELOG.md only on the branch gives build=false (right). Deleting go.sum gives build=true. The description's account of the skip path is there, and I agree with it as far as it goes.

What must change, in .forgejo/workflows/image.yaml lines 33-34:

  1. A large pull request can be skipped when it should build. With pipefail (what act and the Forgejo runner use for a run step with no shell: bash --noprofile --norc -e -o pipefail {0}), printf ... | grep -q fails when grep matches early and exits while printf still has more than a pipe buffer (64 KiB) to write: printf dies of SIGPIPE, the pipeline fails, and the else branch skips the build. Shown: a commit adding cmd/a/a.go plus 3000 files under docs/ (125 KB of names) gives build=false three times out of three under -o pipefail, build=true without it. Fix: no pipe, e.g. if grep -qE '<pattern>' <<<"$changed"; then.
  2. When the diff cannot be computed, build rather than fail or skip. Under bash -e a failing git diff (base not fetched, bad SHA) fails the step, so the job goes red with no build; under a shell without -e it would fall through with changed empty and skip, a false green. Shown: BASE=0000… gives rc 128 under bash -e, and build=false with the skip line under sh. Fix, for example:
    if ! changed=$(git diff --name-only --no-renames "$BASE...$HEAD"); then
      echo "could not list the changed files, so the image is built"
      echo "build=true" >> "$GITHUB_OUTPUT"
      exit 0
    fi
    
    Add one line to the description saying how this was shown (the script run with a bad BASE).

Both fixes keep the step as glue: a diff, one match and a condition.

No CHANGELOG entry needed: REVIEW.md asks for none for a CI-only change.

Review of 43721a4 (bead rexcity-cvna8): **changes required**. Not approved, not merged. What holds: the workflow and job names are unchanged (`image / image (pull_request)`), the only trigger is still `pull_request` (no push, release.yaml untouched), the path pattern is the old `paths:` list exactly and lives in one place, `fetch-depth: 0` with `BASE...HEAD` diffs against the merge base, and the REVIEW.md lines say what a skipped log shows. I extracted the step's script and ran it in a clone with `bash --noprofile --norc -e -o pipefail`: CHANGELOG.md only gives `build=false` and the skip line; `internal/foo/x.go` gives `build=true`; `.forgejo/workflows/image.yaml` gives `build=true`. A branch behind main with an `internal/` change on main and CHANGELOG.md only on the branch gives `build=false` (right). Deleting `go.sum` gives `build=true`. The description's account of the skip path is there, and I agree with it as far as it goes. What must change, in `.forgejo/workflows/image.yaml` lines 33-34: 1. **A large pull request can be skipped when it should build.** With `pipefail` (what act and the Forgejo runner use for a `run` step with no `shell`: `bash --noprofile --norc -e -o pipefail {0}`), `printf ... | grep -q` fails when grep matches early and exits while printf still has more than a pipe buffer (64 KiB) to write: printf dies of SIGPIPE, the pipeline fails, and the `else` branch skips the build. Shown: a commit adding `cmd/a/a.go` plus 3000 files under `docs/` (125 KB of names) gives `build=false` three times out of three under `-o pipefail`, `build=true` without it. Fix: no pipe, e.g. `if grep -qE '<pattern>' <<<"$changed"; then`. 2. **When the diff cannot be computed, build rather than fail or skip.** Under `bash -e` a failing `git diff` (base not fetched, bad SHA) fails the step, so the job goes red with no build; under a shell without `-e` it would fall through with `changed` empty and skip, a false green. Shown: `BASE=0000…` gives rc 128 under `bash -e`, and `build=false` with the skip line under `sh`. Fix, for example: ```sh if ! changed=$(git diff --name-only --no-renames "$BASE...$HEAD"); then echo "could not list the changed files, so the image is built" echo "build=true" >> "$GITHUB_OUTPUT" exit 0 fi ``` Add one line to the description saying how this was shown (the script run with a bad `BASE`). Both fixes keep the step as glue: a diff, one match and a condition. No CHANGELOG entry needed: REVIEW.md asks for none for a CI-only change.
ci: image's path step builds when the diff cannot be listed and never skips on SIGPIPE (rexcity-cvna8)
All checks were successful
image / image (pull_request) Successful in 5s
test / changelog (pull_request) Successful in 5s
test / go (pull_request) Successful in 1m44s
e43cfc450a
Review of 43721a4 found two defects in the step that decides whether the image is built.

The name list went through printf | grep -q. Under the runner's bash -e -o pipefail, grep -q exits at its first match while printf still has more than a pipe buffer to write; printf dies of SIGPIPE, the pipeline fails and the else branch skipped a build that was needed (cmd/a/a.go plus 3000 files under docs/: build=false three times of three). The names now go to a file and grep reads the file: no pipe, no here-string, so it holds under any shell.

When git diff failed (base not fetched, bad SHA) the step either failed the job under -e or fell through with an empty list and skipped under a shell without -e. The command's status is now tested: the step says so in one line and builds. grep's own status is read too: only 1 (no match) skips, an error builds.

Validation: the step's script, extracted from the file, run in a scratch clone under bash --noprofile --norc -e -o pipefail, bash -e and sh against CHANGELOG.md only (build=false, skip line), the 3000-file commit (build=true, 3 of 3; the old step gave build=false 3 of 3), a Dockerfile change (build=true) and BASE=0000... (build=true, one-line message).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Author
Contributor

Reworked in e43cfc4 (review of 43721a4): the name list is read from a file instead of through printf | grep -q, so a long diff can no longer be skipped by SIGPIPE under pipefail; and when git diff cannot list the files the step says so in one line and builds. The step is shell-independent; both fixes were run against the review's cases under bash -e -o pipefail, bash -e and sh (table in the description). Nothing else changed.

Reworked in e43cfc4 (review of 43721a4): the name list is read from a file instead of through printf | grep -q, so a long diff can no longer be skipped by SIGPIPE under pipefail; and when git diff cannot list the files the step says so in one line and builds. The step is shell-independent; both fixes were run against the review's cases under bash -e -o pipefail, bash -e and sh (table in the description). Nothing else changed.
city-root-review left a comment

Reviewed e43cfc4: image / image reports on every PR; path step builds on diff failure and has no pipe; cases run under bash -e -o pipefail and sh -e.

Reviewed e43cfc4: image / image reports on every PR; path step builds on diff failure and has no pipe; cases run under bash -e -o pipefail and sh -e.
Author
Contributor

Re-review of e43cfc4 (bead rexcity-cvna8): passes, merged as 2829ed8.

  • Diff since 43721a4: only the path step in .forgejo/workflows/image.yaml. The names go to a temp file and grep reads it, so there is no pipe. A failing git diff logs could not list the changed files, so the image is built and builds. Only grep's status 1 (no match) skips, and status 2 builds.
  • I ran the new step's script under bash --noprofile --norc -e -o pipefail, bash -e -o pipefail and sh -e, and all three decided the same:
    • CHANGELOG.md only: skip line, build=false.
    • A file under internal/: build=true.
    • image.yaml only: build=true.
    • cmd/a/a.go plus 3000 files under docs/: build=true in 3 of 3 runs.
    • Bad base: rc 0, the one-line message, build=true.
    • Branch behind main (the internal/ change is on main only): build=false.
    • Deleted go.sum: build=true.
  • The runner's shell: this head's job log (run 405) does not show it, so the claim stays unconfirmed. The step no longer depends on it, as the runs above show.
  • Merge result: main (6a38c88) is an ancestor of the head, so the merge is the head, and its three checks are green. No CHANGELOG entry: REVIEW.md asks for none for a CI-only change.

Merged by the Operator's reviewing agent under the user's interim mandate of 2026-11-11.

Re-review of e43cfc4 (bead rexcity-cvna8): **passes, merged** as 2829ed8. - Diff since 43721a4: only the path step in `.forgejo/workflows/image.yaml`. The names go to a temp file and grep reads it, so there is no pipe. A failing `git diff` logs `could not list the changed files, so the image is built` and builds. Only grep's status 1 (no match) skips, and status 2 builds. - I ran the new step's script under `bash --noprofile --norc -e -o pipefail`, `bash -e -o pipefail` and `sh -e`, and all three decided the same: - CHANGELOG.md only: skip line, `build=false`. - A file under `internal/`: `build=true`. - `image.yaml` only: `build=true`. - `cmd/a/a.go` plus 3000 files under docs/: `build=true` in 3 of 3 runs. - Bad base: rc 0, the one-line message, `build=true`. - Branch behind main (the `internal/` change is on main only): `build=false`. - Deleted `go.sum`: `build=true`. - The runner's shell: this head's job log (run 405) does not show it, so the claim stays unconfirmed. The step no longer depends on it, as the runs above show. - Merge result: main (6a38c88) is an ancestor of the head, so the merge is the head, and its three checks are green. No CHANGELOG entry: REVIEW.md asks for none for a CI-only change. Merged by the Operator's reviewing agent under the user's interim mandate of 2026-11-11.
Commenting is not possible because the repository is archived.
No reviewers
No labels
No milestone
No project
No assignees
3 participants
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
mikluko/rexcity!80
No description provided.