Skip to content

Commit 5205602

Browse files
committed
Add a golint action
Signed-off-by: apostasie <[email protected]>
1 parent cb49ffc commit 5205602

File tree

4 files changed

+58
-48
lines changed

4 files changed

+58
-48
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: "lint-go"
2+
description: "This action will install go linting tools (golangci-lint and goimports-reviser), and executes them on the codebase."
3+
inputs:
4+
cache-dependency-path:
5+
description: 'Used to specify the path to a dependency file - go.sum'
6+
strategy:
7+
description: "See install-go for info"
8+
_golangci_version:
9+
description: "Internal: the golangci version we want"
10+
default: "89476e7a1eaa0a8a06c17343af960a5fd9e7edb7" # v1.62.2
11+
_goimports_version:
12+
description: "Internal: the goimports reviser version we want"
13+
default: "f034195cc8a7ffc7cc70d60aa3a25500874eaf04" # v3.8.2
14+
15+
runs:
16+
using: composite
17+
steps:
18+
- name: "Install golang"
19+
uses: ./.github/actions/install-go
20+
with:
21+
strategy: ${{ inputs.strategy }}
22+
- name: "`go install` needed tools"
23+
shell: bash
24+
run: |
25+
# go install golangci-lint and goimports-reviser
26+
err="$(go install -v github.com/golangci/golangci-lint/cmd/golangci-lint@${{ inputs._golangci_version }} 2>&1)" || {
27+
echo "Failed installing golangci:"
28+
echo "$err"
29+
exit 1
30+
}
31+
err="$(go install -v github.com/incu6us/goimports-reviser/v3@${{ inputs._goimports_version }} 2>&1)" || {
32+
echo "Failed installing goimports-reviser:"
33+
echo "$err"
34+
exit 1
35+
}

.github/actions/lint-go/action.yml

-26
This file was deleted.

.github/workflows/lint.yml

+18-20
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ jobs:
1212
timeout-minutes: 5
1313
name: "go | ${{ matrix.goos }} | ${{ matrix.goversion }}"
1414
runs-on: "${{ matrix.os }}"
15-
defaults:
16-
run:
17-
shell: bash
1815
strategy:
1916
matrix:
2017
include:
@@ -32,37 +29,38 @@ jobs:
3229
- os: ubuntu-24.04
3330
goos: linux
3431
goversion: canary
35-
env:
36-
GOOS: "${{ matrix.goos }}"
3732
steps:
3833
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3934
with:
4035
fetch-depth: 1
41-
- name: "Install go"
42-
uses: ./.github/actions/install-go
36+
- name: "Install go linters"
37+
uses: ./.github/actions/install-go-linters
4338
with:
4439
strategy: ${{ matrix.goversion }}
45-
- name: golangci-lint
46-
uses: golangci/golangci-lint-action@774c35bcccffb734694af9e921f12f57d882ef74 # v6.1.1
47-
with:
48-
args: --verbose
40+
- name: "`make lint-imports`"
41+
# Import ordering is not influenced by GOOS - running it multiple times is thus unnecessary
42+
# Note we are picking freebsd as the GOOS to run it on, as linux is running multiple times (eg: canary)
43+
if: ${{ inputs.goos=='freebsd' }}
44+
shell: bash
45+
run: |
46+
make lint-imports
47+
- name: "`make lint-go` for ${{ inputs.goos }} and $GO_VERSION"
48+
env:
49+
VERBOSE: true
50+
GOOS: ${{ inputs.goos }}
51+
shell: bash
52+
run: |
53+
make lint-go
54+
4955
other:
5056
timeout-minutes: 5
51-
name: yaml | shell | imports order
57+
name: yaml | shell
5258
runs-on: ubuntu-24.04
5359
steps:
5460
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
5561
with:
5662
fetch-depth: 1
57-
- name: "Install go"
58-
uses: ./.github/actions/install-go
59-
with:
60-
strategy: latest-stable
6163
- name: yaml
6264
run: make lint-yaml
6365
- name: shell
6466
run: make lint-shell
65-
- name: go imports ordering
66-
run: |
67-
go install -v github.com/incu6us/goimports-reviser/v3@latest
68-
make lint-imports

Makefile

+5-2
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,16 @@ clean:
6767
find . -name \#\* -delete
6868
rm -rf $(CURDIR)/_output/* $(MAKEFILE_DIR)/vendor
6969

70-
lint: lint-go lint-imports lint-yaml lint-shell
70+
lint: lint-go-all lint-imports lint-yaml lint-shell
7171

72-
lint-go:
72+
lint-go-all:
7373
cd $(MAKEFILE_DIR) && GOOS=linux golangci-lint run $(VERBOSE_FLAG_LONG) ./... && \
7474
GOOS=windows golangci-lint run $(VERBOSE_FLAG_LONG) ./... && \
7575
GOOS=freebsd golangci-lint run $(VERBOSE_FLAG_LONG) ./...
7676

77+
lint-go:
78+
cd $(MAKEFILE_DIR) && golangci-lint run $(VERBOSE_FLAG_LONG) ./...
79+
7780
lint-imports:
7881
cd $(MAKEFILE_DIR) && ./hack/lint-imports.sh
7982

0 commit comments

Comments
 (0)