Run the repo checks on pull requests - #58
Merged
Merged
Conversation
Adds .github/workflows/ci.yml: one job running gofmt, a go.mod tidy check, vet, build, and the test suite on every pull request and on pushes to main. The steps mirror the Makefile targets a contributor runs locally, so a CI failure means the same command fails on their machine. gofmt is checked with -l rather than `make fmt`, which rewrites files — CI must report formatting, not silently fix it and then test code the author never wrote. Tests run three times: plain, under -race, and with -shuffle=on. The shuffle is not redundant. The suite mutates process state (HOME, XDG_CONFIG_HOME, cobra flag values), and cmd/root_test.go documents a pflag hazard where a slice flag's first Set in a later test appends rather than replaces, so an order-dependent test is a real risk. Better surfaced here than on an unrelated PR. All three passes together take about 25 seconds. Pushes to main are included so a merge that breaks something is attributed to the merge rather than to the next pull request. Concurrency cancels superseded pull-request runs but never cancels main-branch runs, so consecutive merges each get a result. Conventions follow release.yml: checkout@v7, setup-go@v7, and go-version-file: go.mod so the Go version stays in one place. Permissions are contents: read, since nothing here writes. No services, credentials, or network egress are needed: tests bind ephemeral localhost ports and point HOME at a temp directory, and the container tests assert on the command strings they would run rather than invoking a real runtime. Assisted by Claude. Signed-off-by: Ed Snible <snible@us.ibm.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
.github/workflows/ci.yml— one job on every PR and on pushes tomain:gofmt -l ., failing if non-emptygo mod tidythengit diff --quietmake vetgo build ./...go test ./... -count=1go test ./... -race -count=1go test ./... -count=1 -shuffle=onMirrors the Makefile targets, so a CI failure reproduces locally.
gofmt -lrather thanmake fmt, which rewrites files — CI should report formatting, not fix it and test something the author never wrote.The shuffled run is deliberate: the suite mutates process state (
HOME, cobra flag values), andcmd/root_test.godocuments a pflag hazard where a slice flag's firstSetin a later test appends rather than replaces. Better caught here than on an unrelated PR. All three test passes take ~25s.Pushes to
mainare included so a breaking merge is attributed to the merge, not the next PR. Concurrency cancels superseded PR runs, never main-branch runs.Conventions follow
release.yml(checkout@v7,setup-go@v7,go-version-file: go.mod).permissions: contents: read.Verified each gate actually fails, not just that the workflow is valid and currently green: bad formatting, an unused
require, a badPrintfverb, and a broken assertion were each caught by the intended step. No services, credentials, or egress needed.Assisted by Claude.
Signed-off-by: Ed Snible snible@us.ibm.com
🤖 Generated with Claude Code