Run the merge gate only for changes its tests read
Tests / vet + fmt + tests (pull_request) Successful in 1m4s

This commit is contained in:
2026-09-03 22:30:02 +02:00
parent 466ed5a4d9
commit cc15bdd1d9
2 changed files with 28 additions and 2 deletions
+17 -1
View File
@@ -16,12 +16,28 @@ jobs:
- uses: actions/checkout@v6 - uses: actions/checkout@v6
with: with:
persist-credentials: false persist-credentials: false
fetch-depth: 0
- name: Relevant changes
id: changes
run: |
if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then
git fetch --no-tags origin "$GITHUB_BASE_REF"
base="origin/$GITHUB_BASE_REF"
else
base="HEAD^"
fi
if git diff --quiet "$base"...HEAD -- '*.go' go.mod go.sum Dockerfile .dockerignore .github data README.md; then
echo "code=false" >> "$GITHUB_OUTPUT"
else
echo "code=true" >> "$GITHUB_OUTPUT"
fi
# `docker build` streams the context to the daemon. A compose bind-mount of # `docker build` streams the context to the daemon. A compose bind-mount of
# `.` mounts an empty host dir instead, because the job is itself a container. # `.` mounts an empty host dir instead, because the job is itself a container.
- name: Latest supported Go - name: Latest supported Go
if: ${{ steps.changes.outputs.code == 'true' }}
run: docker build . run: docker build .
# Runs even when the step above failed, so a red build says whether the # Runs even when the step above failed, so a red build says whether the
# failure is version-specific. # failure is version-specific.
- name: Lowest supported Go - name: Lowest supported Go
if: ${{ !cancelled() }} if: ${{ !cancelled() && steps.changes.outputs.code == 'true' }}
run: docker build --build-arg GO_VERSION=1.22.12 . run: docker build --build-arg GO_VERSION=1.22.12 .
+11 -1
View File
@@ -460,6 +460,13 @@ tokens add cost in proportion to the output.
almost always costs an allocation too (a lost pre-size, a per-item map, an extra almost always costs an allocation too (a lost pre-size, a per-item map, an extra
copy). The benchmark suite (see Development) reports time for a human, not as a copy). The benchmark suite (see Development) reports time for a human, not as a
pass/fail gate. pass/fail gate.
- **The gate runs only when something it consumes changes.** A PR that touches
none of the Go and module files, the Dockerfile, `.dockerignore`, the
workflow, the shipped data nor the README skips `docker build` and passes
as-is — those are what the build feeds or the tests read (`data_test.go` and
`loading_test.go` load `data/`, `readme_test.go` renders every README
example), so any other change is a verdict already decided, and waiting would
be idle. The check still reports success, so the merge gate stays whole.
## Development ## Development
@@ -485,7 +492,10 @@ docker compose run --rm --user "$(id -u):$(id -g)" tidy # go mod tidy
Every pull request runs `docker build .` against both the latest and the lowest Every pull request runs `docker build .` against both the latest and the lowest
supported Go, and must pass before it can be merged. That build is the whole supported Go, and must pass before it can be merged. That build is the whole
gate — vet, complexity, format check and tests — so run it locally before pushing: gate — vet, complexity, format check and tests — so run it locally before pushing.
A PR that touches none of the Go and module files, the Dockerfile,
`.dockerignore`, the workflow, the shipped data nor the README skips the build
and passes as-is (see [Decisions](#decisions)):
```sh ```sh
docker build . # latest docker build . # latest