Skip to content

Commit 614065b

Browse files
committed
Merge branch 'main' into dbcrypt
2 parents 2e19360 + 9df9ad4 commit 614065b

File tree

335 files changed

+13289
-9941
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

335 files changed

+13289
-9941
lines changed

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

Lines changed: 45 additions & 16 deletions
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

Lines changed: 48 additions & 62 deletions
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,17 +183,24 @@ 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
196190
uses: actions/checkout@v3
191+
192+
- uses: buildjet/setup-node@v3
197193
with:
198-
fetch-depth: 0
199-
submodules: true
194+
node-version: 16.16.0
200195

201-
- uses: ./.github/actions/setup-node
202-
- uses: ./.github/actions/setup-go
196+
- uses: buildjet/setup-go@v4
197+
with:
198+
# This doesn't need caching. It's super fast anyways!
199+
cache: false
200+
go-version: 1.20.5
201+
202+
- name: Install prettier
203+
run: npm install -g prettier
203204

204205
- name: Install shfmt
205206
run: go install mvdan.cc/sh/v3/cmd/shfmt@v3.5.0
@@ -250,11 +251,6 @@ jobs:
250251
# By default Go will use the number of logical CPUs, which
251252
# is a fine default.
252253
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
258254
259255
export TS_DEBUG_DISCO=true
260256
gotestsum --junitfile="gotests.xml" --jsonfile="gotests.json" \
@@ -268,7 +264,7 @@ jobs:
268264
go run ./scripts/ci-report/main.go gotests.json | tee gotests_stats.json
269265
270266
- uses: ./.github/actions/upload-datadog
271-
if: always()
267+
if: success() || failure()
272268
with:
273269
api-key: ${{ secrets.DATADOG_API_KEY }}
274270

@@ -315,15 +311,8 @@ jobs:
315311
# so we need to print the test stats to the log.
316312
go run ./scripts/ci-report/main.go gotests.json | tee gotests_stats.json
317313
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-
325314
- uses: ./.github/actions/upload-datadog
326-
if: always()
315+
if: success() || failure()
327316
with:
328317
api-key: ${{ secrets.DATADOG_API_KEY }}
329318

@@ -349,11 +338,6 @@ jobs:
349338

350339
- uses: ./.github/actions/setup-go
351340

352-
- uses: hashicorp/setup-terraform@v2
353-
with:
354-
terraform_version: 1.1.9
355-
terraform_wrapper: false
356-
357341
- name: Run Tests
358342
run: |
359343
gotestsum --junitfile="gotests.xml" -- -race ./...
@@ -565,14 +549,16 @@ jobs:
565549

566550
required:
567551
runs-on: ubuntu-latest
568-
needs: [gen, test-go, test-go-pg, test-go-race, test-js]
552+
needs: [fmt, lint, gen, test-go, test-go-pg, test-go-race, test-js]
569553
# Allow this job to run even if the needed jobs fail, are skipped or
570554
# cancelled.
571555
if: always()
572556
steps:
573557
- name: Ensure required checks
574558
run: |
575559
echo "Checking required checks"
560+
echo "- fmt: ${{ needs.fmt.result }}"
561+
echo "- lint: ${{ needs.lint.result }}"
576562
echo "- gen: ${{ needs.gen.result }}"
577563
echo "- test-go: ${{ needs.test-go.result }}"
578564
echo "- test-go-pg: ${{ needs.test-go-pg.result }}"

.github/workflows/security.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010

1111
schedule:
1212
# Run every 6 hours Monday-Friday!
13-
- cron: "0 0,6,12,18 * * 1-5"
13+
- cron: "0 0/6 * * 1-5"
1414

1515
# Cancel in-progress runs for pull requests when developers push
1616
# additional changes
@@ -117,8 +117,16 @@ jobs:
117117
make -j "$image_job"
118118
echo "image=$(cat "$image_job")" >> $GITHUB_OUTPUT
119119
120+
- name: Run Prisma Cloud image scan
121+
uses: PaloAltoNetworks/prisma-cloud-scan@v1
122+
with:
123+
pcc_console_url: ${{ secrets.PRISMA_CLOUD_URL }}
124+
pcc_user: ${{ secrets.PRISMA_CLOUD_ACCESS_KEY }}
125+
pcc_pass: ${{ secrets.PRISMA_CLOUD_SECRET_KEY }}
126+
image_name: ${{ steps.build.outputs.image }}
127+
120128
- name: Run Trivy vulnerability scanner
121-
uses: aquasecurity/trivy-action@e5f43133f6e8736992c9f3c1b3296e24b37e17f2
129+
uses: aquasecurity/trivy-action@41f05d9ecffa2ed3f1580af306000f734b733e54
122130
with:
123131
image-ref: ${{ steps.build.outputs.image }}
124132
format: sarif

.golangci.yaml

Lines changed: 1 addition & 2 deletions
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.

.vscode/settings.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,5 @@
212212
// We often use a version of TypeScript that's ahead of the version shipped
213213
// with VS Code.
214214
"typescript.tsdk": "./site/node_modules/typescript/lib",
215-
"grammarly.selectors": [
216-
{
217-
"language": "markdown",
218-
"scheme": "file",
219-
"pattern": "docs/contributing/frontend.md"
220-
}
221-
]
215+
"prettier.prettierPath": "./node_modules/prettier"
222216
}

0 commit comments

Comments
 (0)