Skip to content

Commit e40010e

Browse files
committed
Upgrade to go 1.24, fix build problems
1 parent 16a6211 commit e40010e

File tree

10 files changed

+69
-89
lines changed

10 files changed

+69
-89
lines changed

.github/workflows/enterprise-release.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ jobs:
3030
# Necessary for Docker manifest
3131
DOCKER_CLI_EXPERIMENTAL: "enabled"
3232
steps:
33-
- uses: actions/checkout@v3
33+
- name: Checkout
34+
uses: actions/checkout@v4
3435
with:
3536
fetch-depth: 0
3637

@@ -43,15 +44,16 @@ jobs:
4344
run: git fetch --tags --force
4445

4546
- name: Docker Login
46-
uses: docker/login-action@v2
47+
uses: docker/login-action@v3
4748
with:
4849
registry: ghcr.io
4950
username: ${{ github.actor }}
5051
password: ${{ secrets.GITHUB_TOKEN }}
5152

52-
- uses: actions/setup-go@v3
53+
- name: Install Go
54+
uses: actions/setup-go@v5
5355
with:
54-
go-version: "^1.21.9"
56+
go-version: "^1.24.5"
5557

5658
- name: Build binaries
5759
run: |

.github/workflows/enterprise.yaml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,13 @@ jobs:
3434
runs-on: ubuntu-latest
3535
timeout-minutes: 20
3636
steps:
37-
- uses: actions/checkout@v3
38-
- uses: actions/setup-go@v3
37+
- name: Checkout
38+
uses: actions/checkout@v4
39+
40+
- name: Install Go
41+
uses: actions/setup-go@v5
3942
with:
40-
go-version: "^1.21.9"
43+
go-version: "^1.24.5"
4144

4245
- name: Echo Go Cache Paths
4346
id: go-cache-paths
@@ -46,13 +49,13 @@ jobs:
4649
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
4750
4851
- name: Go Build Cache
49-
uses: actions/cache@v3
52+
uses: actions/cache@v4
5053
with:
5154
path: ${{ steps.go-cache-paths.outputs.go-build }}
5255
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.**', '**.go') }}
5356

5457
- name: Go Mod Cache
55-
uses: actions/cache@v3
58+
uses: actions/cache@v4
5659
with:
5760
path: ${{ steps.go-cache-paths.outputs.go-mod }}
5861
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}

.github/workflows/gen.yml renamed to .github/workflows/gen.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
runs-on: ubuntu-latest
3232
steps:
3333
- name: Checkout
34-
uses: actions/checkout@v2
34+
uses: actions/checkout@v4
3535

3636
- name: Run make
3737
run: make

.github/workflows/quality.yml renamed to .github/workflows/quality.yaml

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ jobs:
3131
runs-on: ubuntu-latest
3232
steps:
3333
- name: Checkout
34-
uses: actions/checkout@v2
34+
uses: actions/checkout@v4
3535

3636
- name: Install Go
37-
uses: actions/setup-go@v2
37+
uses: actions/setup-go@v5
3838
with:
39-
go-version: "^1.21.9"
39+
go-version: "^1.24.5"
4040

4141
- name: Run make fmt/go
4242
run: make fmt/go
@@ -49,12 +49,12 @@ jobs:
4949
runs-on: ubuntu-latest
5050
steps:
5151
- name: Checkout
52-
uses: actions/checkout@v2
52+
uses: actions/checkout@v4
5353

5454
- name: Install Node.js
55-
uses: actions/setup-node@v2
55+
uses: actions/setup-node@v4
5656
with:
57-
node-version: "18"
57+
node-version: "22"
5858

5959
- name: Install prettier
6060
run: npm install --global prettier
@@ -70,17 +70,16 @@ jobs:
7070
runs-on: ubuntu-latest
7171
steps:
7272
- name: Checkout
73-
uses: actions/checkout@v2
73+
uses: actions/checkout@v4
7474

7575
- name: Install Go
76-
uses: actions/setup-go@v2
76+
uses: actions/setup-go@v5
7777
with:
78-
go-version: "^1.21.9"
78+
go-version: "^1.24.5"
7979

8080
- name: Install golangci-lint
8181
run: |
82-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh \
83-
| sh -s -- -b $(go env GOPATH)/bin v1.57.2
82+
go install github.com/golangci/golangci-lint/cmd/[email protected]
8483
8584
# Linting needs to be done on each build variation of GOOS.
8685
- name: Run make lint/go/linux
@@ -95,10 +94,13 @@ jobs:
9594
runs-on: ubuntu-latest
9695
timeout-minutes: 20
9796
steps:
98-
- uses: actions/checkout@v3
99-
- uses: actions/setup-go@v3
97+
- name: Checkout
98+
uses: actions/checkout@v4
99+
100+
- name: Install Go
101+
uses: actions/setup-go@v5
100102
with:
101-
go-version: "^1.21.9"
103+
go-version: "^1.24.5"
102104

103105
- name: Echo Go Cache Paths
104106
id: go-cache-paths
@@ -107,13 +109,13 @@ jobs:
107109
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
108110
109111
- name: Go Build Cache
110-
uses: actions/cache@v3
112+
uses: actions/cache@v4
111113
with:
112114
path: ${{ steps.go-cache-paths.outputs.go-build }}
113115
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.**', '**.go') }}
114116

115117
- name: Go Mod Cache
116-
uses: actions/cache@v3
118+
uses: actions/cache@v4
117119
with:
118120
path: ${{ steps.go-cache-paths.outputs.go-mod }}
119121
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
@@ -126,7 +128,7 @@ jobs:
126128
runs-on: ubuntu-latest
127129
steps:
128130
- name: Checkout
129-
uses: actions/checkout@v2
131+
uses: actions/checkout@v4
130132

131133
- name: Run make lint/c
132134
run: make lint/c
@@ -144,7 +146,7 @@ jobs:
144146
runs-on: ubuntu-latest
145147
steps:
146148
- name: Checkout
147-
uses: actions/checkout@v2
149+
uses: actions/checkout@v4
148150

149151
- name: Install shellcheck
150152
run: sudo apt install -y shellcheck

.golangci.yaml

Lines changed: 29 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,19 @@
55
# - removed testpackage
66

77
linters-settings:
8+
dupl:
9+
# goal: 100
10+
threshold: 412
11+
812
exhaustruct:
913
include:
1014
# Gradually extend to cover more of the codebase.
1115
- 'httpmw\.\w+'
16+
# We want to enforce all values are specified when inserting or updating
17+
# a database row. Ref: #993
18+
- 'github.com/coder/coder/v2/coderd/database\.[^G][^e][^t]\w+Params'
1219
gocognit:
13-
min-complexity: 46 # Min code complexity (def 30).
20+
min-complexity: 300
1421

1522
goconst:
1623
min-len: 4 # Min length of string consts (def 3).
@@ -20,30 +27,19 @@ linters-settings:
2027
enabled-checks:
2128
# - appendAssign
2229
# - appendCombine
23-
#- argOrder
2430
# - assignOp
2531
# - badCall
26-
#- badCond
2732
- badLock
2833
- badRegexp
2934
- boolExprSimplify
3035
# - builtinShadow
3136
- builtinShadowDecl
32-
#- captLocal
33-
#- caseOrder
34-
#- codegenComment
3537
# - commentedOutCode
3638
- commentedOutImport
37-
#- commentFormatting
38-
#- defaultCaseOrder
3939
- deferUnlambda
4040
# - deprecatedComment
4141
# - docStub
42-
#- dupArg
43-
#- dupBranchBody
44-
#- dupCase
4542
- dupImport
46-
#- dupSubExpr
4743
# - elseif
4844
- emptyFallthrough
4945
# - emptyStringTest
@@ -52,64 +48,47 @@ linters-settings:
5248
# - exitAfterDefer
5349
# - exposedSyncMutex
5450
# - filepathJoin
55-
#- flagDeref
56-
#- flagName
5751
- hexLiteral
5852
# - httpNoBody
5953
# - hugeParam
6054
# - ifElseChain
6155
# - importShadow
6256
- indexAlloc
6357
- initClause
64-
#- mapKey
6558
- methodExprCall
6659
# - nestingReduce
67-
#- newDeref
6860
- nilValReturn
6961
# - octalLiteral
70-
#- offBy1
7162
# - paramTypeCombine
7263
# - preferStringWriter
7364
# - preferWriteByte
7465
# - ptrToRefParam
7566
# - rangeExprCopy
7667
# - rangeValCopy
77-
#- regexpMust
7868
- regexpPattern
7969
# - regexpSimplify
80-
#- ruleguard
81-
#- singleCaseSwitch
82-
#- sloppyLen
70+
# - ruleguard
8371
# - sloppyReassign
84-
#- sloppyTypeAssert
8572
- sortSlice
8673
- sprintfQuotedString
8774
- sqlQuery
8875
# - stringConcatSimplify
8976
# - stringXbytes
9077
# - suspiciousSorting
91-
#- switchTrue
9278
- truncateCmp
9379
- typeAssertChain
9480
# - typeDefFirst
95-
#- typeSwitchVar
9681
# - typeUnparen
97-
#- underef
9882
# - unlabelStmt
9983
# - unlambda
10084
# - unnamedResult
10185
# - unnecessaryBlock
10286
# - unnecessaryDefer
10387
# - unslice
104-
#- valSwap
10588
- weakCond
10689
# - whyNoLint
10790
# - wrapperFunc
10891
# - yodaStyleExpr
109-
#settings:
110-
# ruleguard:
111-
# failOn: all
112-
# rules: "${configDir}/scripts/rules.go"
11392

11493
staticcheck:
11594
# https://staticcheck.io/docs/options#checks
@@ -121,10 +100,6 @@ linters-settings:
121100
goimports:
122101
local-prefixes: coder.com,cdr.dev,go.coder.com,github.com/cdr,github.com/coder
123102

124-
gocyclo:
125-
# goal: 30
126-
min-complexity: 47
127-
128103
importas:
129104
no-unaliased: true
130105

@@ -134,7 +109,8 @@ linters-settings:
134109
- trialer
135110

136111
nestif:
137-
min-complexity: 4 # Min complexity of if statements (def 5, goal 4)
112+
# goal: 10
113+
min-complexity: 20
138114

139115
revive:
140116
# see https://github.com/mgechev/revive#available-rules for details.
@@ -174,8 +150,6 @@ linters-settings:
174150
- name: modifies-value-receiver
175151
- name: package-comments
176152
- name: range
177-
- name: range-val-address
178-
- name: range-val-in-closure
179153
- name: receiver-naming
180154
- name: redefines-builtin-id
181155
- name: string-of-int
@@ -189,11 +163,21 @@ linters-settings:
189163
- name: unnecessary-stmt
190164
- name: unreachable-code
191165
- name: unused-parameter
166+
exclude: "**/*_test.go"
192167
- name: unused-receiver
193168
- name: var-declaration
194169
- name: var-naming
195170
- name: waitgroup-by-value
196171

172+
# irrelevant as of Go v1.22: https://go.dev/blog/loopvar-preview
173+
govet:
174+
disable:
175+
- loopclosure
176+
gosec:
177+
excludes:
178+
# Implicit memory aliasing of items from a range statement (irrelevant as of Go v1.22)
179+
- G601
180+
197181
issues:
198182
# Rules listed here: https://github.com/securego/gosec#available-rules
199183
exclude-rules:
@@ -203,15 +187,6 @@ issues:
203187
- errcheck
204188
- forcetypeassert
205189
- exhaustruct # This is unhelpful in tests.
206-
- path: scripts/*
207-
linters:
208-
- exhaustruct
209-
210-
exclude-files:
211-
- scripts/rules.go
212-
213-
exclude-dirs:
214-
- node_modules
215190

216191
fix: true
217192
max-issues-per-linter: 0
@@ -233,10 +208,14 @@ linters:
233208
- errname
234209
- errorlint
235210
- exhaustruct
236-
- exportloopref
237211
- forcetypeassert
238212
- gocritic
239-
- gocyclo
213+
# gocyclo is may be useful in the future when we start caring
214+
# about testing complexity, but for the time being we should
215+
# create a good culture around cognitive complexity.
216+
# - gocyclo
217+
- gocognit
218+
- nestif
240219
- goimports
241220
- gomodguard
242221
- gosec
@@ -260,15 +239,9 @@ linters:
260239

261240
- staticcheck
262241
- tenv
263-
# In Go, it's possible for a package to test it's internal functionality
264-
# without testing any exported functions. This is enabled to promote
265-
# decomposing a package before testing it's internals. A function caller
266-
# should be able to test most of the functionality from exported functions.
267-
#
268-
# There are edge-cases to this rule, but they should be carefully considered
269-
# to avoid structural inconsistency.
270-
#- testpackage
242+
# - testpackage
271243
- tparallel
272244
- typecheck
273245
- unconvert
274246
- unused
247+
- dupl

0 commit comments

Comments
 (0)