Skip to content

Commit a829552

Browse files
Merge pull request #248 from sapcc/golangci-lint-timeout-option
make timeout for golangci-lint configurable
2 parents 4787293 + bdb3316 commit a829552

File tree

5 files changed

+18
-5
lines changed

5 files changed

+18
-5
lines changed

.github/workflows/checks.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ jobs:
3333
- name: Run golangci-lint
3434
uses: golangci/golangci-lint-action@v6
3535
with:
36+
verify: false
3637
version: latest
3738
- name: Dependency Licenses Review
3839
run: make check-dependency-licenses

.golangci.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# SPDX-License-Identifier: Apache-2.0
88

99
run:
10-
timeout: 3m # 1m by default
10+
timeout: 3m0s # 1m by default
1111
modules-download-mode: vendor
1212

1313
output:

internal/core/config.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package core
66
import (
77
"os/exec"
88
"strings"
9+
"time"
910

1011
"github.com/sapcc/go-bits/logg"
1112
)
@@ -90,9 +91,10 @@ type GolangConfiguration struct {
9091

9192
// GolangciLintConfiguration appears in type Configuration.
9293
type GolangciLintConfiguration struct {
93-
CreateConfig bool `yaml:"createConfig"`
94-
ErrcheckExcludes []string `yaml:"errcheckExcludes"`
95-
SkipDirs []string `yaml:"skipDirs"`
94+
CreateConfig bool `yaml:"createConfig"`
95+
ErrcheckExcludes []string `yaml:"errcheckExcludes"`
96+
SkipDirs []string `yaml:"skipDirs"`
97+
Timeout time.Duration `yaml:"timeout"`
9698
}
9799

98100
type GoReleaserConfiguration struct {

internal/ghworkflow/workflow_checks.go

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ func checksWorkflow(cfg core.Configuration) {
2323
Name: "Run golangci-lint",
2424
Uses: core.GolangciLintAction,
2525
With: map[string]any{
26+
// disabled until https://github.com/golangci/golangci-lint/pull/5501 is resolved
27+
"verify": false,
2628
"version": "latest",
2729
},
2830
})

internal/golangcilint/golangci_lint.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"strconv"
1010
"strings"
1111
"text/template"
12+
"time"
1213

1314
"github.com/sapcc/go-bits/must"
1415

@@ -18,7 +19,7 @@ import (
1819

1920
var configTmpl = template.Must(template.New("golangci").Parse(strings.TrimSpace(strings.ReplaceAll(`
2021
run:
21-
timeout: 3m # 1m by default
22+
timeout: {{ .Timeout }} # 1m by default
2223
modules-download-mode: {{ .ModDownloadMode }}
2324
2425
output:
@@ -215,6 +216,7 @@ type configTmplData struct {
215216
MisspellIgnoreWords []string
216217
ErrcheckExcludes []string
217218
SkipDirs []string
219+
Timeout time.Duration
218220
}
219221

220222
func RenderConfig(cfg core.Configuration, sr golang.ScanResult) {
@@ -223,6 +225,11 @@ func RenderConfig(cfg core.Configuration, sr golang.ScanResult) {
223225
mode = "vendor"
224226
}
225227

228+
timeout := 3 * time.Minute
229+
if cfg.GolangciLint.Timeout != 0 {
230+
timeout = cfg.GolangciLint.Timeout
231+
}
232+
226233
f := must.Return(os.Create(".golangci.yaml"))
227234
fmt.Fprintln(f, core.AutogeneratedHeader+"\n")
228235
must.Succeed(configTmpl.Execute(f, configTmplData{
@@ -232,6 +239,7 @@ func RenderConfig(cfg core.Configuration, sr golang.ScanResult) {
232239
MisspellIgnoreWords: cfg.SpellCheck.IgnoreWords,
233240
ErrcheckExcludes: cfg.GolangciLint.ErrcheckExcludes,
234241
SkipDirs: cfg.GolangciLint.SkipDirs,
242+
Timeout: timeout,
235243
}))
236244
fmt.Fprintln(f) // empty line at end
237245

0 commit comments

Comments
 (0)