-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(ci): lint with golangci-lint (#726)
This introduces linting in CI to help maintain code quality and identify issues that may not be caught by tests. To avoid a big PR that resolves all existing linting issues, the CI workflow is configured to only look at files that are changed in a particular PR or commit; we'll need to keep an eye on this to make sure it's working as expected. This will allow us to chip away at existing issues over time. Eventually (ideally within a few months), the CI workflow should be updated to always lint the entire codebase. This PR also introduces a `make lint` task for local execution, but this task lints the entire codebase and, for the time being, will catch some issues that are not flagged for a particular PR or commit in CI.
- Loading branch information
Showing
3 changed files
with
49 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: golangci-lint | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
permissions: | ||
contents: read | ||
pull-requests: read # Remove along with only-new-issues by 2025 | ||
jobs: | ||
golangci: | ||
name: lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: go.mod | ||
- name: Determine golangci-lint version | ||
id: golangcilint | ||
run: | | ||
line=$(grep GOLANGCI_LINT_VERSION= GNUmakefile) | ||
version=$(echo ${line} | cut -d = -f2) | ||
echo "version=$version" >> "$GITHUB_OUTPUT" | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v6 | ||
with: | ||
args: --whole-files # Remove along with only-new-issues by 2025 | ||
version: ${{ steps.golangcilint.outputs.version }} | ||
only-new-issues: true # Remove along with pull-requests: read permission by 2025 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
run: | ||
modules-download-mode: readonly | ||
skip-dirs: | ||
- cmd/migration-tool | ||
linters: | ||
enable: | ||
- errcheck | ||
- goimports | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
- staticcheck | ||
- unused |
This file contains 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