Skip to content

Commit

Permalink
internal/ci: ensure that GitHub and Gerrit agree on the list of tags
Browse files Browse the repository at this point in the history
We have messed this up twice recently, even though we document it in
https://github.com/cue-lang/cue/wiki/Notes-for-project-maintainers.
Start checking it automatically between both remote git repositories.

While here, give the _goChecks step a better name.

Signed-off-by: Daniel Martí <[email protected]>
Change-Id: I184abfad71bdd0e11d4eea03568744592f6a557a
Dispatch-Trailer: {"type":"trybot","CL":1201173,"patchset":3,"ref":"refs/changes/73/1201173/3","targetBranch":"master"}
  • Loading branch information
mvdan authored and cueckoo committed Sep 13, 2024
1 parent 67f9dfa commit 60f783e
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
18 changes: 17 additions & 1 deletion .github/workflows/trybot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,27 @@ jobs:
cd internal/_e2e
go test -race
- if: (matrix.go-version == '1.23.x' && matrix.runner == 'ubuntu-22.04')
name: Check
name: Go checks
run: |-
go vet ./...
go mod tidy
(cd internal/_e2e && go test -run=-)
- if: (matrix.go-version == '1.23.x' && matrix.runner == 'ubuntu-22.04')
name: Check all git tags are available
run: |-
tmp=$(mktemp -d)
git ls-remote --tags https://github.com/cue-lang/cue >"$tmp/github.txt"
echo "GitHub tags:"
cat "$tmp/github.txt"
git ls-remote --tags https://review.gerrithub.io/cue-lang/cue >"$tmp/gerrit.txt"
if ! diff -u "$tmp/github.txt" "$tmp/gerrit.txt"; then
echo "GitHub and Gerrit do not agree on the list of tags!"
echo "Did you forget about refs/attic branches? https://github.com/cue-lang/cue/wiki/Notes-for-project-maintainers"
exit 1
fi
- 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)
29 changes: 28 additions & 1 deletion internal/ci/github/trybot.cue
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ workflows: trybot: _repo.bashWorkflow & {
_goTestWasm,
for v in _e2eTestSteps {v},
_goCheck,
_checkTags,
_repo.checkGitClean,
]
}
Expand Down Expand Up @@ -167,14 +168,40 @@ workflows: trybot: _repo.bashWorkflow & {
//
// TODO: consider adding more checks as per https://github.com/golang/go/issues/42119.
if: "\(_isLatestLinux)"
name: "Check"
name: "Go checks"
run: """
go vet ./...
go mod tidy
(cd internal/_e2e && go test -run=-)
"""
}

_checkTags: json.#step & {
// Ensure that GitHub and Gerrit agree on the full list of available tags.
// This way, if there is any discrepancy, we will get a useful go-cmp diff.
//
// We use `git ls-remote` to list all tags from each remote git repository
// because it does not depend on custom REST API endpoints and is very fast.
// Note that it sorts tag names as strings, which is not the best, but works OK.
if: "\(_isLatestLinux)"
name: "Check all git tags are available"
run: """
tmp=$(mktemp -d)
git ls-remote --tags https://github.com/cue-lang/cue >"$tmp/github.txt"
echo "GitHub tags:"
cat "$tmp/github.txt"
git ls-remote --tags https://review.gerrithub.io/cue-lang/cue >"$tmp/gerrit.txt"
if ! diff -u "$tmp/github.txt" "$tmp/gerrit.txt"; then
echo "GitHub and Gerrit do not agree on the list of tags!"
echo "Did you forget about refs/attic branches? https://github.com/cue-lang/cue/wiki/Notes-for-project-maintainers"
exit 1
fi
"""
}

_goTestRace: json.#step & {
name: "Test with -race"
env: GORACE: "atexit_sleep_ms=10" // Otherwise every Go package being tested sleeps for 1s; see https://go.dev/issues/20364.
Expand Down

0 comments on commit 60f783e

Please sign in to comment.