-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: Integrate GitHub Action for golangci-lint Annotations (#106)
This PR adds a GitHub action check with annotations supported by golangci-lint. For now I have set `-issues-exit-code=1` (workflow shows failure if even a single lint error) and to show all lint error annotations (this works for us because we will always be in a lint-error free state). In case we want to suppress lint errors we just use `nolint:xyz` (also won't show up in annotations either).
- Loading branch information
1 parent
4e89168
commit 6765046
Showing
2 changed files
with
59 additions
and
3 deletions.
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
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,59 @@ | ||
name: golangci-lint | ||
|
||
on: | ||
pull_request: | ||
|
||
push: | ||
tags: | ||
- v* | ||
branches: | ||
- master | ||
- develop | ||
|
||
permissions: | ||
# Optional: allow read access to pull request. Need this if we use the `only-new-issues` option. | ||
pull-requests: read | ||
contents: read | ||
|
||
jobs: | ||
golangci: | ||
strategy: | ||
matrix: | ||
go-version: [1.17.5] | ||
os: [ubuntu-latest] | ||
|
||
name: lint | ||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v2 | ||
|
||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v2 | ||
|
||
with: | ||
# Required: the version of golangci-lint is required. | ||
# Note: The version should not pick the patch version as the latest patch | ||
# version is what will always be used. | ||
version: v1.43 | ||
|
||
# Optional: working directory, useful for monorepos or if we wanted to run this | ||
# on a non-root directory. | ||
# working-directory: ./ | ||
|
||
# Optional: golangci-lint command line arguments. | ||
# Note: we can set `--issues-exit-code=0` if we want a successcode always, | ||
# indicating that the linter ran successfully (weather or not linter errors | ||
# exist or not doesn't matter). But the good think is that the annotations | ||
# will still show up. I think this can be useful if we don't want the pipeline | ||
# to stop just because we had some linter errors. | ||
args: --issues-exit-code=1 --config .golangci.sourceinc.yaml | ||
|
||
# Optional: we can set the below to `true` if we only want to see newly introduced | ||
# linter errors, however I found that in practive that option is a bit gimmicky, | ||
# as it passes the linter check despite having new linter errors in some cases. | ||
# So we opt in for all annotations of linter errors to show up, this is actually | ||
# nicer because we suppress our linter errors manually anyways so there shouldn't | ||
# be any linter errors anyways. The enforces us to always have a clean lint state. | ||
only-new-issues: false |