Skip to content

Commit cc911cb

Browse files
committed
migrate golangci-lint config and update workflow
1 parent 5a61214 commit cc911cb

File tree

2 files changed

+54
-28
lines changed

2 files changed

+54
-28
lines changed

.github/workflows/style.yaml

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ name: Code Style
55

66
on:
77
pull_request:
8-
branches: [ 'main', 'release-*' ]
8+
branches:
9+
- 'main'
910
push:
10-
branches: [ 'main', 'release-*' ]
11+
branches:
12+
- 'main'
1113

1214
permissions: {}
1315

@@ -16,8 +18,10 @@ jobs:
1618
gofmt:
1719
name: check gofmt
1820
runs-on: ubuntu-latest
21+
1922
permissions:
2023
contents: read
24+
2125
steps:
2226
- name: Check out code
2327
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -28,15 +32,17 @@ jobs:
2832
go-version-file: './go.mod'
2933
check-latest: true
3034

31-
- uses: chainguard-dev/actions/gofmt@main
35+
- uses: chainguard-dev/actions/gofmt@5363dd9eb48083bbf7674a4bbe62d71c3b230edd # v1.1.2
3236
with:
3337
args: -s
3438

3539
goimports:
3640
name: check goimports
3741
runs-on: ubuntu-latest
42+
3843
permissions:
3944
contents: read
45+
4046
steps:
4147
- name: Check out code
4248
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -47,13 +53,15 @@ jobs:
4753
go-version-file: './go.mod'
4854
check-latest: true
4955

50-
- uses: chainguard-dev/actions/goimports@main
56+
- uses: chainguard-dev/actions/goimports@5363dd9eb48083bbf7674a4bbe62d71c3b230edd # v1.1.2
5157

5258
golangci-lint:
5359
name: golangci-lint
5460
runs-on: ubuntu-latest
61+
5562
permissions:
5663
contents: read
64+
pull-requests: read
5765

5866
steps:
5967
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -69,12 +77,12 @@ jobs:
6977
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
7078
with:
7179
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
72-
version: v1.60
73-
args: --timeout=5m
80+
version: v2.1
7481

7582
lint:
7683
name: Lint
7784
runs-on: ubuntu-latest
85+
7886
permissions:
7987
contents: read
8088

@@ -88,23 +96,23 @@ jobs:
8896
go-version-file: './go.mod'
8997
check-latest: true
9098

91-
- uses: chainguard-dev/actions/trailing-space@main
99+
- uses: chainguard-dev/actions/trailing-space@5363dd9eb48083bbf7674a4bbe62d71c3b230edd # v1.1.2
92100
if: ${{ always() }}
93101

94-
- uses: chainguard-dev/actions/eof-newline@main
102+
- uses: chainguard-dev/actions/eof-newline@5363dd9eb48083bbf7674a4bbe62d71c3b230edd # v1.1.2
95103
if: ${{ always() }}
96104

97105
- uses: reviewdog/action-tflint@41b4770c9d9e50741c20e431986b33124a07ca52 # v1.24.2
98106
if: ${{ always() }}
99107
with:
100108
github_token: ${{ secrets.github_token }}
101-
fail_on_error: true
109+
fail_level: warning
102110

103111
- uses: reviewdog/action-misspell@9daa94af4357dddb6fd3775de806bc0a8e98d3e4 # v1.26.3
104112
if: ${{ always() }}
105113
with:
106114
github_token: ${{ secrets.github_token }}
107-
fail_on_error: true
115+
fail_level: warning
108116
locale: "US"
109117
exclude: |
110118
**/go.sum

.golangci.yml

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,53 @@
1-
# Copyright 2022 Chainguard, Inc.
1+
# Copyright 2025 Chainguard, Inc.
22
# SPDX-License-Identifier: Apache-2.0
33

4+
---
5+
version: "2"
6+
run:
7+
issues-exit-code: 1
8+
timeout: 5m
49
linters:
510
enable:
611
- asciicheck
7-
- unused
8-
- errcheck
912
- errorlint
10-
- gofmt
11-
- goimports
12-
- gosec
1313
- gocritic
14+
- gosec
1415
- importas
16+
- misspell
1517
- prealloc
1618
- revive
17-
- misspell
18-
- stylecheck
19+
- staticcheck
1920
- tparallel
2021
- unconvert
2122
- unparam
2223
- whitespace
23-
output:
24-
uniq-by-line: false
24+
exclusions:
25+
generated: lax
26+
presets:
27+
- comments
28+
- common-false-positives
29+
- legacy
30+
- std-error-handling
31+
rules:
32+
- linters:
33+
- errcheck
34+
- gosec
35+
path: _test\.go
36+
paths:
37+
- third_party$
38+
- builtin$
39+
- examples$
2540
issues:
26-
exclude-rules:
27-
- path: _test\.go
28-
linters:
29-
- errcheck
30-
- gosec
3141
max-issues-per-linter: 0
3242
max-same-issues: 0
33-
run:
34-
issues-exit-code: 1
35-
timeout: 10m
43+
uniq-by-line: false
44+
formatters:
45+
enable:
46+
- gofmt
47+
- goimports
48+
exclusions:
49+
generated: lax
50+
paths:
51+
- third_party$
52+
- builtin$
53+
- examples$

0 commit comments

Comments
 (0)