Skip to content

Commit 0ed1c89

Browse files
Use golangci-lint instead of golint (#400)
1 parent f9ae024 commit 0ed1c89

File tree

4 files changed

+19
-51
lines changed

4 files changed

+19
-51
lines changed

workflow-templates/assets/check-go-task/Taskfile.yml

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,9 @@ tasks:
2222
dir: "{{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}}"
2323
cmds:
2424
- |
25-
if ! which golint &>/dev/null; then
26-
echo "golint not installed or not in PATH. Please install: https://github.com/golang/lint#installation"
25+
if ! which golangci-lint &>/dev/null; then
26+
echo "golangci-lint not installed or not in PATH."
27+
echo "Please install: https://golangci-lint.run/usage/install/#local-installation"
2728
exit 1
2829
fi
29-
- |
30-
golint \
31-
{{default "-min_confidence 0.8 -set_exit_status" .GO_LINT_FLAGS}} \
32-
{{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
33-
34-
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
35-
go:vet:
36-
desc: Check for errors in Go code
37-
dir: "{{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}}"
38-
cmds:
39-
- go vet {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
30+
- golangci-lint run
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/go/.golangci.yml
2+
# See: https://golangci-lint.run/usage/configuration/
3+
issues:
4+
exclude-use-default: false
5+
linters:
6+
enable:
7+
- revive

workflow-templates/check-go-task.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Install the [`check-go-task.yml`](check-go-task.yml) GitHub Actions workflow to
1212

1313
- [`Taskfile.yml`](assets/check-go-task/Taskfile.yml) - Linting and formatting [tasks](https://taskfile.dev/).
1414
- Install to: repository root (or merge into the existing `Taskfile.yml`).
15+
- [`.golangci.yml`](assets/go/.golangci.yml) - Contains all the go-linting configurations.
16+
- Install to: repository root as `.golangci.yml`
1517
- [`Taskfile.yml`](assets/go-task/Taskfile.yml) - `DEFAULT_GO_MODULE_PATH` and `DEFAULT_GO_PACKAGES` variables
1618
- Merge into `Taskfile.yml`
1719

workflow-templates/check-go-task.yml

Lines changed: 6 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ on:
1212
paths:
1313
- ".github/workflows/check-go-task.ya?ml"
1414
- "Taskfile.ya?ml"
15+
- ".golangci.ya?ml"
1516
- "**/go.mod"
1617
- "**/go.sum"
1718
- "**.go"
1819
pull_request:
1920
paths:
2021
- ".github/workflows/check-go-task.ya?ml"
2122
- "Taskfile.ya?ml"
23+
- ".golangci.ya?ml"
2224
- "**/go.mod"
2325
- "**/go.sum"
2426
- "**.go"
@@ -53,42 +55,6 @@ jobs:
5355
5456
echo "result=$RESULT" >> $GITHUB_OUTPUT
5557
56-
check-errors:
57-
name: check-errors (${{ matrix.module.path }})
58-
needs: run-determination
59-
if: needs.run-determination.outputs.result == 'true'
60-
runs-on: ubuntu-latest
61-
permissions:
62-
contents: read
63-
64-
strategy:
65-
fail-fast: false
66-
67-
matrix:
68-
module:
69-
# TODO: add paths of all Go modules here
70-
- path: ./
71-
72-
steps:
73-
- name: Checkout repository
74-
uses: actions/checkout@v4
75-
76-
- name: Install Go
77-
uses: actions/setup-go@v4
78-
with:
79-
go-version: ${{ env.GO_VERSION }}
80-
81-
- name: Install Task
82-
uses: arduino/setup-task@v1
83-
with:
84-
repo-token: ${{ secrets.GITHUB_TOKEN }}
85-
version: 3.x
86-
87-
- name: Check for errors
88-
env:
89-
GO_MODULE_PATH: ${{ matrix.module.path }}
90-
run: task go:vet
91-
9258
check-outdated:
9359
name: check-outdated (${{ matrix.module.path }})
9460
needs: run-determination
@@ -159,8 +125,10 @@ jobs:
159125
repo-token: ${{ secrets.GITHUB_TOKEN }}
160126
version: 3.x
161127

162-
- name: Install golint
163-
run: go install golang.org/x/lint/golint@latest
128+
- name: Install golangci-lint
129+
uses: golangci/golangci-lint-action@v3
130+
with:
131+
version: v1.54
164132

165133
- name: Check style
166134
env:

0 commit comments

Comments
 (0)