Skip to content

Commit

Permalink
internal/ci: always check that git is clean when we finish
Browse files Browse the repository at this point in the history
That is, check that git is clean even if a previous step failed.
In https://cuelang.org/cl/1194425 this caused some confusion;
the author forgot to run `go generate ./...`, and since CI runs
that command as a step before `go test ./...` on the main Linux job,
CI seemed to run into a "go test" failure that the author did not.

This human error would have been more obvious if CI had also failed
with "git is not clean" including a diff of the generated code.
By default, a GitHub Actions step only runs if all previous steps
have succeeded, but we can use the "always" condition to also run
even if the job already failed due to a previous step.

Signed-off-by: Daniel Martí <[email protected]>
Change-Id: Ied1c1eb98d53b23f68650d946cc6341d8c2f3c3d
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1196088
TryBot-Result: CUEcueckoo <[email protected]>
Reviewed-by: Noam Dolovich <[email protected]>
Reviewed-by: Paul Jolly <[email protected]>
Unity-Result: CUE porcuepine <[email protected]>
  • Loading branch information
mvdan committed Jun 12, 2024
1 parent 95035da commit b44ef61
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .github/workflows/trybot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,5 +191,6 @@ jobs:
run: |-
go vet ./...
go mod tidy
- name: Check that git is clean at the end of the job
- if: always()
name: Check that git is clean at the end of the job
run: test -z "$(git status --porcelain)" || (git status; git diff; false)
1 change: 1 addition & 0 deletions internal/ci/base/github.cue
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ isReleaseTag: {

checkGitClean: json.#step & {
name: "Check that git is clean at the end of the job"
if: "always()"
run: "test -z \"$(git status --porcelain)\" || (git status; git diff; false)"
}

Expand Down

0 comments on commit b44ef61

Please sign in to comment.