Skip to content

Instantly share code, notes, and snippets.

@rhcarvalho
Created August 3, 2022 10:46
Show Gist options
  • Save rhcarvalho/9f2ae0742f5496271526b3e572da1d34 to your computer and use it in GitHub Desktop.
Save rhcarvalho/9f2ae0742f5496271526b3e572da1d34 to your computer and use it in GitHub Desktop.
Building golangci-lint from source in a GitHub Workflow
# .github/workflows/test.yml
# ...
jobs:
# ...
lint-go:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
# go-version: 1.19
go-version-file: go.mod
# The builtin cache feature ensures that installing golangci-lint
# is consistently fast.
cache: true
cache-dependency-path: go.sum
- name: Install golangci-lint
# Install golangci-lint from source instead of using
# golangci-lint-action to ensure the golangci-lint binary is built with
# the same Go version we're targeting.
# Avoids incompatibility issues such as:
# - https://github.com/golangci/golangci-lint/issues/2922
# - https://github.com/golangci/golangci-lint/issues/2673
# - https://github.com/golangci/golangci-lint-action/issues/442
run: go install github.com/golangci/golangci-lint/cmd/[email protected]
- name: Run golangci-lint
run: golangci-lint run --version --verbose --out-format=github-actions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment