Skip to content

Commit b6d4d88

Browse files
authored
Merge branch 'main' into mafredri/fix-coderd-metadata-test
2 parents 76a17d7 + aa9dbf2 commit b6d4d88

File tree

6 files changed

+94
-79
lines changed

6 files changed

+94
-79
lines changed

.github/actions/setup-go/action.yaml

+45-16
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,65 @@
11
name: "Setup Go"
22
description: |
33
Sets up the Go environment for tests, builds, etc.
4+
inputs:
5+
version:
6+
description: "The Go version to use."
7+
default: "1.20.5"
48
runs:
59
using: "composite"
610
steps:
11+
- name: Cache go toolchain
12+
uses: buildjet/cache@v3
13+
with:
14+
path: |
15+
${{ runner.tool_cache }}/go/${{ inputs.version }}
16+
key: gotoolchain-${{ runner.os }}-${{ inputs.version }}
17+
restore-keys: |
18+
gotoolchain-${{ runner.os }}-
19+
720
- uses: buildjet/setup-go@v4
821
with:
9-
cache: true
10-
go-version: "1.20.5"
22+
# We do our own caching for implementation clarity.
23+
cache: false
24+
go-version: ${{ inputs.version }}
25+
26+
- name: Get cache dirs
27+
shell: bash
28+
run: |
29+
set -x
30+
echo "GOMODCACHE=$(go env GOMODCACHE)" >> $GITHUB_ENV
31+
echo "GOCACHE=$(go env GOCACHE)" >> $GITHUB_ENV
32+
33+
# We split up GOMODCACHE from GOCACHE because the latter must be invalidated
34+
# on code change, but the former can be kept.
35+
- name: Cache $GOMODCACHE
36+
uses: buildjet/cache@v3
37+
with:
38+
path: |
39+
${{ env.GOMODCACHE }}
40+
key: gomodcache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}-${{ github.job }}
41+
restore-keys: |
42+
gomodcache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}-
43+
gomodcache-${{ runner.os }}-
1144
12-
- name: Cache go
45+
- name: Cache $GOCACHE
1346
uses: buildjet/cache@v3
1447
with:
15-
# ~/go/pkg is the same across operating systems.
1648
path: |
17-
~/go/pkg
18-
~/.cache/go-build
19-
~/AppData/Local/go-build
20-
~/Library/Caches/go-build
49+
${{ env.GOCACHE }}
2150
# Job name must be included in the key for effective
2251
# test cache reuse.
23-
key: go-${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/*.go', 'go.**') }}
52+
# The key format is intentionally different than GOMODCACHE, because any
53+
# time a Go file changes we invalidate this cache, whereas GOMODCACHE
54+
# is only invalidated when go.sum changes.
55+
key: gocache-${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/*.go', 'go.**') }}
2456
restore-keys: |
25-
go-${{ runner.os }}-${{ github.job }}-
26-
go-${{ runner.os }}-
27-
go-
57+
gocache-${{ runner.os }}-${{ github.job }}-
58+
gocache-${{ runner.os }}-
2859
2960
- name: Install gotestsum
30-
uses: jaxxstorm/action-install-gh-release@v1.10.0
31-
with:
32-
repo: gotestyourself/gotestsum
33-
tag: v1.9.0
61+
shell: bash
62+
run: go install gotest.tools/gotestsum@latest
3463

3564
# It isn't necessary that we ever do this, but it helps
3665
# separate the "setup" from the "run" times.

.github/workflows/ci.yaml

+34-57
Original file line numberDiff line numberDiff line change
@@ -100,49 +100,45 @@ jobs:
100100

101101
- uses: ./.github/actions/setup-go
102102

103-
# Check for any typos!
103+
- uses: ./.github/actions/setup-node
104+
105+
- name: Get golangci-lint cache dir
106+
run: |
107+
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53.2
108+
dir=$(golangci-lint cache status | awk '/Dir/ { print $2 }')
109+
echo "LINT_CACHE_DIR=$dir" >> $GITHUB_ENV
110+
111+
- name: golangci-lint cache
112+
uses: buildjet/cache@v3
113+
with:
114+
path: |
115+
${{ env.LINT_CACHE_DIR }}
116+
key: golangci-lint-${{ runner.os }}-${{ hashFiles('**/*.go') }}
117+
restore-keys: |
118+
golangci-lint-${{ runner.os }}-
119+
120+
# Check for any typos
104121
- name: Check for typos
105122
uses: crate-ci/typos@v1.14.12
106123
with:
107124
config: .github/workflows/typos.toml
125+
108126
- name: Fix the typos
109127
if: ${{ failure() }}
110128
run: |
111129
echo "::notice:: you can automatically fix typos from your CLI:
112130
cargo install typos-cli
113131
typos -c .github/workflows/typos.toml -w"
114132
115-
# Check for Go linting errors!
116-
- name: Lint Go
117-
uses: golangci/golangci-lint-action@v3.5.0
118-
with:
119-
version: v1.52.2
120-
121-
- name: Lint shell scripts
122-
uses: ludeeus/action-shellcheck@2.0.0
123-
env:
124-
SHELLCHECK_OPTS: --external-sources
125-
with:
126-
ignore: node_modules
127-
128-
- uses: ./.github/actions/setup-node
129-
- name: Lint TypeScript
130-
run: yarn lint
131-
working-directory: site
132-
133-
# Make sure the Helm chart is linted!
133+
# Needed for helm chart linting
134134
- name: Install helm
135135
uses: azure/setup-helm@v3
136136
with:
137137
version: v3.9.2
138-
- name: Lint Helm chart
139-
run: |
140-
cd helm
141-
make lint
142138

143-
# Ensure AGPL and Enterprise are separated!
144-
- name: Check for AGPL code importing Enterprise...
145-
run: ./scripts/check_enterprise_imports.sh
139+
- name: make lint
140+
run: |
141+
make --output-sync=line -j lint
146142
147143
gen:
148144
timeout-minutes: 8
@@ -158,16 +154,14 @@ jobs:
158154
- name: Install sqlc
159155
run: |
160156
curl -sSL https://github.com/kyleconroy/sqlc/releases/download/v1.17.2/sqlc_1.17.2_linux_amd64.tar.gz | sudo tar -C /usr/bin -xz sqlc
161-
- name: Install protoc-gen-go
162-
run: go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.30
163-
- name: Install protoc-gen-go-drpc
164-
run: go install storj.io/drpc/cmd/protoc-gen-go-drpc@v0.0.33
165-
- name: Install goimports
166-
run: go install golang.org/x/tools/cmd/goimports@latest
167-
- name: Install yq
168-
run: go run github.com/mikefarah/yq/v4@v4.30.6
169-
- name: Install mockgen
170-
run: go install github.com/golang/mock/mockgen@v1.6.0
157+
158+
- name: go install tools
159+
run: |
160+
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.30
161+
go install storj.io/drpc/cmd/protoc-gen-go-drpc@v0.0.33
162+
go install golang.org/x/tools/cmd/goimports@latest
163+
go install github.com/mikefarah/yq/v4@v4.30.6
164+
go install github.com/golang/mock/mockgen@v1.6.0
171165
172166
- name: Install Protoc
173167
run: |
@@ -189,7 +183,7 @@ jobs:
189183
run: ./scripts/check_unstaged.sh
190184

191185
fmt:
192-
runs-on: ubuntu-latest
186+
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
193187
timeout-minutes: 5
194188
steps:
195189
- name: Checkout
@@ -250,11 +244,6 @@ jobs:
250244
# By default Go will use the number of logical CPUs, which
251245
# is a fine default.
252246
PARALLEL_FLAG=""
253-
if [ "${{ matrix.os }}" == "windows-2019" ]; then
254-
# Windows appears more I/O bound, so we increase parallelism
255-
# to make better use of CPU.
256-
PARALLEL_FLAG="-parallel=16"
257-
fi
258247
259248
export TS_DEBUG_DISCO=true
260249
gotestsum --junitfile="gotests.xml" --jsonfile="gotests.json" \
@@ -268,7 +257,7 @@ jobs:
268257
go run ./scripts/ci-report/main.go gotests.json | tee gotests_stats.json
269258
270259
- uses: ./.github/actions/upload-datadog
271-
if: always()
260+
if: success() || failure()
272261
with:
273262
api-key: ${{ secrets.DATADOG_API_KEY }}
274263

@@ -315,15 +304,8 @@ jobs:
315304
# so we need to print the test stats to the log.
316305
go run ./scripts/ci-report/main.go gotests.json | tee gotests_stats.json
317306
318-
- uses: actions/upload-artifact@v3
319-
if: success() || failure()
320-
with:
321-
name: gotests-postgres.xml
322-
path: ./gotests.xml
323-
retention-days: 30
324-
325307
- uses: ./.github/actions/upload-datadog
326-
if: always()
308+
if: success() || failure()
327309
with:
328310
api-key: ${{ secrets.DATADOG_API_KEY }}
329311

@@ -349,11 +331,6 @@ jobs:
349331

350332
- uses: ./.github/actions/setup-go
351333

352-
- uses: hashicorp/setup-terraform@v2
353-
with:
354-
terraform_version: 1.1.9
355-
terraform_wrapper: false
356-
357334
- name: Run Tests
358335
run: |
359336
gotestsum --junitfile="gotests.xml" -- -race ./...

.github/workflows/security.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ jobs:
118118
echo "image=$(cat "$image_job")" >> $GITHUB_OUTPUT
119119
120120
- name: Run Trivy vulnerability scanner
121-
uses: aquasecurity/trivy-action@e5f43133f6e8736992c9f3c1b3296e24b37e17f2
121+
uses: aquasecurity/trivy-action@41f05d9ecffa2ed3f1580af306000f734b733e54
122122
with:
123123
image-ref: ${{ steps.build.outputs.image }}
124124
format: sarif

.golangci.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,11 @@ issues:
200200
max-same-issues: 0
201201

202202
run:
203-
concurrency: 4
204203
skip-dirs:
205204
- node_modules
206205
skip-files:
207206
- scripts/rules.go
208-
timeout: 5m
207+
timeout: 10m
209208

210209
# Over time, add more and more linters from
211210
# https://golangci-lint.run/usage/linters/ as the code improves.

Makefile

+12-1
Original file line numberDiff line numberDiff line change
@@ -402,11 +402,17 @@ else
402402
endif
403403
.PHONY: fmt/shfmt
404404

405-
lint: lint/shellcheck lint/go
405+
lint: lint/shellcheck lint/go lint/ts lint/helm
406406
.PHONY: lint
407407

408+
lint/ts:
409+
cd site
410+
yarn && yarn lint
411+
.PHONY: lint/ts
412+
408413
lint/go:
409414
./scripts/check_enterprise_imports.sh
415+
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53.2
410416
golangci-lint run
411417
.PHONY: lint/go
412418

@@ -416,6 +422,11 @@ lint/shellcheck: $(SHELL_SRC_FILES)
416422
shellcheck --external-sources $(SHELL_SRC_FILES)
417423
.PHONY: lint/shellcheck
418424

425+
lint/helm:
426+
cd helm
427+
make lint
428+
.PHONY: lint/helm
429+
419430
# all gen targets should be added here and to gen/mark-fresh
420431
gen: \
421432
coderd/database/dump.sql \

enterprise/cli/root_internal_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ package cli
33
import (
44
"testing"
55

6-
"github.com/coder/coder/cli"
76
"github.com/stretchr/testify/require"
87

8+
"github.com/coder/coder/cli"
99
"github.com/coder/coder/cli/clibase"
10-
1110
"github.com/coder/coder/cli/clitest"
1211
)
1312

0 commit comments

Comments
 (0)