Skip to content

CI: enforce gofmt and add golangci-lint checks#9

Merged
disk0Dancer merged 5 commits into
mainfrom
copilot/add-fmt-lint-code-at-ci
Apr 22, 2026
Merged

CI: enforce gofmt and add golangci-lint checks#9
disk0Dancer merged 5 commits into
mainfrom
copilot/add-fmt-lint-code-at-ci

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 22, 2026

This PR adds formatting and lint gates to CI so PRs fail early on style and static-analysis violations, not just tests/build. The goal is to make fmt+lint part of the default quality bar in the main workflow.

  • CI quality gates

    • Added a Check formatting step that fails when gofmt -l . returns any files.
    • Added a Run golangci-lint step using golangci/golangci-lint-action@v6 (v1.59).
  • Workflow behavior

    • The new checks run before test/build steps in .github/workflows/ci.yml, so formatting/lint issues are surfaced immediately in PR validation.
- name: Check formatting
  run: |
    unformatted="$(gofmt -l .)"
    if [ -n "$unformatted" ]; then
      echo "These files are not gofmt-formatted:"
      echo "$unformatted"
      exit 1
    fi

- name: Run golangci-lint
  uses: golangci/golangci-lint-action@v6
  with:
    version: v1.59

Agent-Logs-Url: https://github.com/disk0Dancer/climate/sessions/99518009-d1ed-4cb8-a58b-863ca6a8cb07

Co-authored-by: disk0Dancer <89835485+disk0Dancer@users.noreply.github.com>
@disk0Dancer disk0Dancer marked this pull request as ready for review April 22, 2026 14:52
Copilot AI review requested due to automatic review settings April 22, 2026 14:52
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR strengthens the repository’s CI workflow by adding formatting and static-analysis gates so style/lint issues fail CI before tests/build, aligning PR validation with a stricter Go quality bar.

Changes:

  • Add a gofmt -l . formatting check step that fails when any files are not formatted.
  • Add a golangci-lint CI step via golangci/golangci-lint-action@v6 (running v1.59).
  • Run these new checks before the existing test/vet/build steps in CI.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/ci.yml Outdated
@disk0Dancer
Copy link
Copy Markdown
Owner

@copilot if in ci fails formatting check, format code, commit and push, ther restart workflow on latest commit

disk0Dancer and others added 4 commits April 22, 2026 15:47
Keep the primary CI workflow check-only and move formatter/linter remediation
into a separate workflow_run auto-fix lane. This preserves deterministic
verification while still allowing same-repo branches to receive gofmt and
golangci-lint --fix updates automatically.

The auto-fix workflow re-dispatches CI after pushing because GITHUB_TOKEN
pushes do not retrigger push-based workflows. The publish templates and docs
now emit and describe the same workflow pair for generated repositories.

Constraint: GITHUB_TOKEN pushes do not trigger push workflows
Constraint: Main CI must remain deterministic and reviewable
Rejected: Mutate the main CI job in place | mixes verification with write-side effects
Rejected: Auto-fix all failures | only formatter and lint fixes are safe to automate
Confidence: high
Scope-risk: moderate
Reversibility: clean
Directive: Keep CI check-only; add new auto-remediation only in follow-up workflows
Tested: golangci-lint run
Tested: go test -race -coverprofile=coverage.out ./...
Tested: go vet ./...
Tested: go build ./...
Tested: YAML parse for .github/workflows/{ci,ci-autofix,release}.yml
Not-tested: Live GitHub Actions execution of workflow_run auto-fix and workflow_dispatch redispatch
The workflow and publish templates were pinned to golangci-lint-action@v6
while requesting golangci-lint v2.11.3, which now fails immediately.
Bump the action pins to v7 so the existing v2 linter version remains valid
for both repository workflows and generated repositories.

Constraint: golangci-lint-action v6 no longer accepts golangci-lint v2
Constraint: Generated repositories must emit the same compatible workflow pins as this repo
Rejected: Downgrade golangci-lint back to v1 | moves away from the current lint configuration
Rejected: Jump straight to a newer action major | unnecessary for the immediate compatibility fix
Confidence: high
Scope-risk: narrow
Reversibility: clean
Directive: Keep the action major aligned with the golangci-lint major in both repo workflows and publish templates
Tested: golangci-lint run
Tested: go test -race -coverprofile=coverage.out ./...
Tested: go vet ./...
Tested: go build ./...
Tested: YAML parse for .github/workflows/{ci,ci-autofix,release}.yml
Not-tested: Live GitHub Actions execution after the push
@disk0Dancer disk0Dancer merged commit 97ecea3 into main Apr 22, 2026
4 checks passed
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.

3 participants