Skip to content

Warn when local golangci-lint version differs from CI (#1052)#1683

Open
pujitha24 wants to merge 1 commit into
dapr:masterfrom
pujitha24:auto/issue-1052
Open

Warn when local golangci-lint version differs from CI (#1052)#1683
pujitha24 wants to merge 1 commit into
dapr:masterfrom
pujitha24:auto/issue-1052

Conversation

@pujitha24

Copy link
Copy Markdown

Motivation:
make lint runs the locally installed golangci-lint binary, but
nothing checks that its version matches the one pinned for the
golangci-lint-action step in .github/workflows/dapr_cli.yaml
(GOLANG_CI_LINT_VER). A version drift between a contributor's local
lint and CI's lint can produce different results locally vs. in the
pipeline, which is confusing to debug. This mirrors the approach
already adopted in dapr/components-contrib (PR #1861), which the
issue explicitly links as a reference solution.

Approach:
Add two new Makefile targets, wired as prerequisites of lint:

  • verify-linter-installed: fails with exit 1 and an install
    command if golangci-lint is not found on PATH.
  • verify-linter-version: compares the installed version (parsed
    from golangci-lint --version) against GOLANG_CI_LINT_VER
    (parsed from .github/workflows/dapr_cli.yaml) and prints a
    warning with an upgrade command if they differ. This check is
    non-fatal (it does not fail the build) since a version mismatch
    doesn't prevent linting from running, it just risks different
    results than CI.

This is a Makefile-only, developer-tooling change; it does not
touch Go source and does not affect CI itself, since CI's lint
step invokes golangci-lint-action directly rather than make lint.

Validation:

  • go build ./... and go test ./pkg/... both pass (no Go source
    was changed).
  • Manually exercised all three code paths of the new targets:
    • golangci-lint not on PATH: make verify-linter-installed exits
      1 with a helpful install command.
    • golangci-lint v2.10.1 installed (matches GOLANG_CI_LINT_VER):
      make verify-linter-installed verify-linter-version exits 0
      silently.
    • golangci-lint v2.5.0 installed (mismatch): prints a Yours/Theirs
      warning with an upgrade command and exits 0 (non-fatal).

Fixes #1052

Signed-off-by: Pujitha Paladugu 10557236+pujitha24@users.noreply.github.com

Motivation:
`make lint` runs the locally installed `golangci-lint` binary, but
nothing checks that its version matches the one pinned for the
`golangci-lint-action` step in .github/workflows/dapr_cli.yaml
(GOLANG_CI_LINT_VER). A version drift between a contributor's local
lint and CI's lint can produce different results locally vs. in the
pipeline, which is confusing to debug. This mirrors the approach
already adopted in dapr/components-contrib (PR #1861), which the
issue explicitly links as a reference solution.

Approach:
Add two new Makefile targets, wired as prerequisites of `lint`:
- `verify-linter-installed`: fails with exit 1 and an install
  command if `golangci-lint` is not found on PATH.
- `verify-linter-version`: compares the installed version (parsed
  from `golangci-lint --version`) against GOLANG_CI_LINT_VER
  (parsed from .github/workflows/dapr_cli.yaml) and prints a
  warning with an upgrade command if they differ. This check is
  non-fatal (it does not fail the build) since a version mismatch
  doesn't prevent linting from running, it just risks different
  results than CI.

This is a Makefile-only, developer-tooling change; it does not
touch Go source and does not affect CI itself, since CI's lint
step invokes golangci-lint-action directly rather than `make lint`.

Validation:
- `go build ./...` and `go test ./pkg/...` both pass (no Go source
  was changed).
- Manually exercised all three code paths of the new targets:
  - golangci-lint not on PATH: `make verify-linter-installed` exits
    1 with a helpful install command.
  - golangci-lint v2.10.1 installed (matches GOLANG_CI_LINT_VER):
    `make verify-linter-installed verify-linter-version` exits 0
    silently.
  - golangci-lint v2.5.0 installed (mismatch): prints a Yours/Theirs
    warning with an upgrade command and exits 0 (non-fatal).

Fixes dapr#1052

Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
@pujitha24
pujitha24 requested review from a team as code owners July 24, 2026 18:09
Copilot AI review requested due to automatic review settings July 24, 2026 18:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 improves developer experience around make lint by adding checks that (1) ensure golangci-lint is installed locally and (2) warn when the locally installed golangci-lint version differs from the version pinned in the CI workflow (.github/workflows/dapr_cli.yaml), reducing confusion caused by local-vs-CI lint drift.

Changes:

  • Add verify-linter-installed Makefile target to fail fast with installation guidance when golangci-lint is missing.
  • Add verify-linter-version Makefile target to warn (non-fatally) when local golangci-lint differs from CI-pinned version.
  • Wire both targets as prerequisites of lint.

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

Comment thread Makefile
Comment on lines +76 to +83
# Version of golangci-lint used by the GitHub Actions pipeline (.github/workflows/dapr_cli.yaml).
GH_LINT_VERSION := $(shell grep 'GOLANG_CI_LINT_VER:' .github/workflows/dapr_cli.yaml | xargs | cut -d' ' -f2)
LINTER_BINARY := $(shell $(FINDBIN) $(GOLANGCI_LINT) 2>/dev/null)
ifeq (,$(LINTER_BINARY))
INSTALLED_LINT_VERSION := v0.0.0
else
INSTALLED_LINT_VERSION := v$(shell $(GOLANGCI_LINT) --version | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+' | head -1)
endif
Comment thread Makefile
Comment on lines +143 to +150
@if [ "$(GH_LINT_VERSION)" != "$(INSTALLED_LINT_VERSION)" ]; then \
echo "[!] Your locally installed version of golangci-lint is different from the pipeline"; \
echo "[!] This will likely cause linting issues for you locally"; \
echo "[!] Yours: $(INSTALLED_LINT_VERSION)"; \
echo "[!] Theirs: $(GH_LINT_VERSION)"; \
echo "[!] Upgrade: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin $(GH_LINT_VERSION)"; \
sleep 3; \
fi
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.

Verify local Golangci-lint version with GitHub actions

2 participants