ci: harden workflows, add Go version matrix, fix release notes handling - #100
Open
kiro-agent[bot] wants to merge 1 commit into
Open
ci: harden workflows, add Go version matrix, fix release notes handling#100kiro-agent[bot] wants to merge 1 commit into
kiro-agent[bot] wants to merge 1 commit into
Conversation
CI:
- Test against Go 1.21 (the minimum declared in go.mod) through stable,
plus macOS and Windows. Previously only a single hardcoded Go 1.21 ran.
- Collapse the fmt/vet/build jobs into one static-analysis job, removing
three redundant checkout+setup-go cycles.
- Verify go.mod/go.sum are tidy and that module checksums verify.
- Add least-privilege permissions, per-job timeouts, and concurrency
cancellation for superseded runs.
- Upload coverage once (from the stable leg) rather than from every leg,
and never fail the build on a Codecov error or a missing fork token.
- Add an aggregate "All checks passed" job so branch protection can
require one stable check name instead of every matrix leg.
Release:
- Stop interpolating changelog text into a shell command. The 0.2.0 notes
contain backticks, so `--notes "${{ ... }}"` would have run
`github.com/pkg/errors` and `fmt.Errorf` as command substitutions and
silently dropped that text from the published notes. Notes now travel
via --notes-file, and the tag/version reach the shell as env vars.
- Pass the version to awk with -v and match it as a literal prefix, so
dots are not treated as regex wildcards.
- Stop release notes at the trailing markdown link-reference block.
- Fail loudly when CHANGELOG.md has no section for the tag instead of
publishing an empty release body, with workflow_dispatch for recovery.
- Build and test the tagged commit before publishing, verify the tag, and
mark hyphenated SemVer tags as pre-releases.
Also adds a scheduled govulncheck workflow (kept out of PR CI so stdlib
CVE churn cannot block unrelated contributions) and Dependabot config for
Go modules and GitHub Actions.
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.
Summary
Improves the three areas the existing workflows left exposed: version coverage, workflow hardening, and a real bug in release-note handling.
The release workflow bug (worth reviewing first)
The old workflow interpolated changelog text straight into a shell command:
gh release edit "$GITHUB_REF_NAME" --notes "${{ steps.changelog.outputs.notes }}"The current
0.2.0changelog entry contains backticks, so this was not hypothetical. Simulated against the realCHANGELOG.md, the shell attempted command substitution and dropped the text:Any content a maintainer writes in
CHANGELOG.mdwas effectively executed on the runner. Notes now reachghthrough--notes-file, and the tag and version reach the shell as environment variables rather than as interpolated text.Two further fixes found while testing the extractor against the real file:
[0.2.0]: https://...) was being appended to every release body.awkregex, so.matched any character. It is now passed with-vand matched as a literal prefix.CI
go.moddeclaresgo 1.21, but CI only ever ran one hardcoded toolchain, so that floor was never verified. Now runs 1.21 → stable, plus macOS and Windows.fmt,vetandbuildwere three jobs each paying for its own checkout and Go setup; they are now one static-analysis job.go.mod/go.sumare tidy and thatgo mod verifypasses, so a stalego.sumcannot reach consumers.permissions: contents: read, per-jobtimeout-minutes, andconcurrencycancellation of superseded runs.CODECOV_TOKENno longer turns a green build red.All checks passedjob so branch protection can require one stable name instead of every matrix leg, whose names change with each Go release.Release
Also builds and tests the tagged commit before publishing, passes
--verify-tag, marks hyphenated SemVer tags (v1.0.0-rc.1) as pre-releases, and fails loudly whenCHANGELOG.mdhas no section for the tag rather than publishing an empty body. Aworkflow_dispatchinput allows re-publishing an existing tag after fixing the changelog.Added
security.ymlrunninggovulncheckweekly, onmain, and on dependency changes. Deliberately kept out of PR CI:govulncheckalso reports standard-library advisories, so a new Go patch release would otherwise fail unrelated contributor PRs on an unchanged tree.dependabot.ymlfor Go modules and GitHub Actions, with routine action bumps grouped into one PR.Verification
actionlint1.7.12 withshellcheck0.10.0: no findings on any of the three workflows.go test -racepass on Go 1.21.13, 1.22.12, 1.23.8, 1.24.3 and 1.25.1 (74.5% coverage), so no matrix leg is expected to fail.gofmt,go vet,go mod tidyandgo mod verifyare clean on the current tree.CHANGELOG.mdfor a present version, a missing version, and the link-reference boundary.testdatafilenames checked for Windows-illegal characters and path length before adding the Windows job (query strings are md5-hashed, so they are safe).Not included
golangci-lintis not wired in. With its default linters it reports 21 pre-existing findings (11errcheck, 9staticcheck, 1ineffassign), including what looks like a genuine bug atcard.go:176and a possible nil dereference inaction_test.go. Adding it here would either break the build or require a config full of suppressions, and the fixes touch exported error strings. Happy to follow up in a separate PR.