Repository navigation
feat(workflows): add a reusable Go CI workflow - #50
Merged
Merged
Conversation
ci-go checks a Go module the way ci-java-gradle checks a Gradle build: tidy modules, formatting, golangci-lint, race tests with a coverage summary, govulncheck and a build. go.mod names the Go version and .golangci-lint-version the linter version, so a repo pins both next to its code. The linter and govulncheck run with `go run pkg@version`, built with the module's own toolchain, because a linter built with an older Go than the code refuses to run. Also adds the workflow-templates starter and the README entry.
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.
What changed, and why
Adds
ci-go.yml, a reusable workflow for Go modules, so a Go repo gets the same centralized coverageci-java-gradle.ymlgives a Gradle one. The first consumer will bestudiobimo/zero-trust.One job, in this order:
go mod verifyandgo mod tidy -diffgolangci-lint fmt --diff)golangci-lint run)go test -racewith a coverage profile, summarised in the job summarygovulncheckgo buildDesign choices:
go.modnames the Go version;.golangci-lint-versionnames the linter version, with an input as the fallback. This mirrors howci-java-gradlereads.java-version.go run pkg@version, not a downloaded binary. A golangci-lint built with an older Go than the code refuses to run, and building it with the module's own toolchain rules that out. It is also the same command a developer runs locally.Also adds the
workflow-templates/ci-gostarter and the README row. No existing workflow changes, so nothing breaks for current consumers.How it was tested
check-action-pins(the lefthook pre-commit run), pluscheck-github-workflowsfrom a consumer's pre-commit config.zero-trustmodule on macOS with Go 1.27.2, golangci-lint v2.14.0 and govulncheck v1.8.0, and passed.self-*caller, andzero-trustis not on GitHub yet, so there is no cross-repo run to link. Unproven until then:actions/setup-goreadinggo-version-fileand its cache paths, thego runbuilds on an Ubuntu runner, and the coverage summary step.Suggested before merging or moving
v1: pointzero-trust's wrapper at this branch's SHA in a draft PR and link the run here.Checklist
branch follows Conventional Branch
gh stackif not)uses:pinned to a full SHA with a# vX.Y.Zcomment$/from a workflow, SHA-pinned from a template(
sh .devtools/check-action-pins.sh) — none are used here; the script passespermissions: {}at workflow level; each job asks for the least it needsv1— none