Skip to content

Commit 7f7d854

Browse files
make timeout for golangci-lint configurable
1 parent f2d80f2 commit 7f7d854

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

.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/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)