Skip to content

ci: restrict workflow permissions and align golangci-lint version - #95

Merged
raeperd merged 4 commits into
mainfrom
fix/ci-review
Nov 5, 2026
Merged

raeperd merged 4 commits into
mainfrom
fix/ci-review

Conversation

@raeperd

@raeperd raeperd commented Nov 4, 2026 •

Copy link
Copy Markdown
Owner

Part 3/3 of the repo review. This PR only touches .github/workflows/build.yaml and Makefile. Go sources and the Dockerfile are handled in PR 1 and PR 2.

Net diff: 2 files, +5 / -2.

Changes

1. Least-privilege GITHUB_TOKEN for build.yaml

build.yaml had no permissions block, so both jobs ran with the repository's default token scope. Neither job needs more than read access:

  • build job: actions/checkout, go build/go test, and coverallsapp/github-action. The Coveralls uploader only uses the token to identify the repo; it does not write to GitHub through it.
  • lint job: actions/checkout, golangci-lint-action (annotations are emitted via workflow commands, which need no extra scope), and deadcode.

So the workflow now declares permissions: contents: read at the top level, matching the style already used in deploy.yaml. deploy.yaml already had contents: read + packages: write, which is exactly what its single job needs to push to GHCR, so it is left as is.

2. Same golangci-lint version locally and in CI

Before: CI pinned v2.11 via golangci-lint-action, while make lint ran whatever golangci-lint happened to be on PATH. Local and CI could lint with different versions and report different findings.

Now both use v2.15.0:

  • Makefile: go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.15.0 run, the same pattern as the existing deadcode line. No local install needed.
  • build.yaml: golangci-lint-action with version: v2.15.0.

The version string lives in two places, one line each. An earlier revision of this PR had CI run make lint so the version lived only in the Makefile, but that compiled golangci-lint on every run (lint steps 31s → 62s) and dropped the action's prebuilt binary, analysis cache, inline PR annotations, and config schema verification. Keeping the action was judged worth one duplicated line.

Why v2.15.0 rather than keeping v2.11: v2.11.x cannot typecheck the Go 1.27 standard library (export data version mismatch), so anyone on a current Go toolchain gets 8 spurious typecheck errors locally. v2.15.0 is the current release, works with both Go 1.26 (what CI gets from go.mod) and Go 1.27, and reports 0 issues on the current code. golangci-lint config verify passes against .golangci.yml with this version.

Verification

  • actionlint passes on both workflows.
  • make lint passes locally on Go 1.27.3 and with GOTOOLCHAIN=go1.26.10 (what CI resolves from go.mod).
  • CI: build and lint green.

Review order

This PR is safest to finalize after PR 2 (Dockerfile) is merged, since build.yaml's path filter includes Dockerfile and a rebase onto that change should get one more CI run here before marking this ready.

Suggestions not included in this PR (low risk, separate follow-ups)

  • Pin third-party actions to commit SHAs instead of major tags (e.g. actions/checkout@<sha> # v7). Dependabot already handles github-actions, so SHA pins would be kept up to date automatically.
  • .golangci.yml is not in the workflow path filters, so lint config changes alone do not trigger CI.
  • deadcode@latest is unpinned in both the Makefile and CI. It could be pinned the same way if reproducibility matters.

@coveralls

coveralls commented Nov 4, 2026 •

Copy link
Copy Markdown

Coverage Status

Coverage is 88.608% — fix/ci-review into main. No base build found for main.

@raeperd raeperd changed the title ci: restrict workflow permissions and pin golangci-lint version in one place ci: restrict workflow permissions and run make lint in CI Nov 4, 2026
@raeperd raeperd changed the title ci: restrict workflow permissions and run make lint in CI ci: restrict workflow permissions and align golangci-lint version Nov 5, 2026
@raeperd
raeperd marked this pull request as ready for review November 5, 2026 13:43
@raeperd
raeperd merged commit 15359c4 into main Nov 5, 2026
3 checks passed
@raeperd
raeperd deleted the fix/ci-review branch November 5, 2026 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants