Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a0eca97

Browse files
committed
Merge branch 'main' into 465/presleyp/routing
2 parents 0e2315c + 26d24f4 commit a0eca97

File tree

149 files changed

+8003
-2378
lines changed

Some content is hidden

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

149 files changed

+8003
-2378
lines changed

.github/workflows/coder-test-stability.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ jobs:
3939
- 1
4040
- 2
4141
steps:
42-
- uses: actions/checkout@v2
42+
- uses: actions/checkout@v3
4343

4444
- uses: actions/setup-go@v2
4545
with:
4646
go-version: "^1.17"
4747

48-
- uses: actions/cache@v2
48+
- uses: actions/cache@v3
4949
with:
5050
# Go mod cache, Linux build cache, Mac build cache, Windows build cache
5151
path: |

.github/workflows/coder.yaml

+120-40
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555

5656
- name: Cache Node
5757
id: cache-node
58-
uses: actions/cache@v2
58+
uses: actions/cache@v3
5959
with:
6060
path: |
6161
**/node_modules
@@ -104,7 +104,7 @@ jobs:
104104

105105
- name: Cache Node
106106
id: cache-node
107-
uses: actions/cache@v2
107+
uses: actions/cache@v3
108108
with:
109109
path: |
110110
**/node_modules
@@ -135,19 +135,31 @@ jobs:
135135
with:
136136
go-version: "^1.17"
137137

138-
- uses: actions/cache@v2
138+
- name: Echo Go Cache Paths
139+
id: go-cache-paths
140+
run: |
141+
echo "::set-output name=go-build::$(go env GOCACHE)"
142+
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
143+
144+
- name: Go Build Cache
145+
uses: actions/cache@v3
139146
with:
140-
# Go mod cache, Linux build cache, Mac build cache, Windows build cache
141-
path: |
142-
~/go/pkg/mod
143-
~/.cache/go-build
144-
~/Library/Caches/go-build
145-
%LocalAppData%\go-build
146-
key: ${{ matrix.os }}-go-${{ hashFiles('**/go.sum') }}
147-
restore-keys: |
148-
${{ matrix.os }}-go-
147+
path: ${{ steps.go-cache-paths.outputs.go-build }}
148+
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
149149

150-
- run: go install gotest.tools/gotestsum@latest
150+
- name: Go Mod Cache
151+
uses: actions/cache@v3
152+
with:
153+
path: ${{ steps.go-cache-paths.outputs.go-mod }}
154+
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
155+
156+
- name: Install goreleaser
157+
uses: jaxxstorm/[email protected]
158+
env:
159+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
160+
with:
161+
repo: gotestyourself/gotestsum
162+
tag: v1.7.0
151163

152164
- uses: hashicorp/setup-terraform@v1
153165
with:
@@ -157,12 +169,12 @@ jobs:
157169
- name: Test with Mock Database
158170
shell: bash
159171
env:
160-
GOCOUNT: ${{ runner.os == 'Windows' && 3 || 5 }}
172+
GOCOUNT: ${{ runner.os == 'Windows' && 1 || 2 }}
161173
GOMAXPROCS: ${{ runner.os == 'Windows' && 1 || 2 }}
162174
run: gotestsum --junitfile="gotests.xml" --packages="./..." --
163175
-covermode=atomic -coverprofile="gotests.coverage"
164176
-coverpkg=./...,github.com/coder/coder/codersdk
165-
-timeout=3m -count=$GOCOUNT -race -short -failfast
177+
-timeout=3m -count=$GOCOUNT -short -failfast
166178

167179
- name: Upload DataDog Trace
168180
if: (success() || failure()) && github.actor != 'dependabot[bot]'
@@ -173,29 +185,91 @@ jobs:
173185
GIT_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
174186
run: go run scripts/datadog-cireport/main.go gotests.xml
175187

188+
- uses: codecov/codecov-action@v2
189+
if: github.actor != 'dependabot[bot]'
190+
with:
191+
token: ${{ secrets.CODECOV_TOKEN }}
192+
files: ./gotests.coverage
193+
flags: unittest-go-${{ matrix.os }}
194+
fail_ci_if_error: true
195+
196+
test-go-postgres:
197+
name: "test/go/postgres"
198+
runs-on: ubuntu-latest
199+
steps:
200+
- uses: actions/checkout@v3
201+
202+
- uses: actions/setup-go@v2
203+
with:
204+
go-version: "^1.17"
205+
206+
- name: Echo Go Cache Paths
207+
id: go-cache-paths
208+
run: |
209+
echo "::set-output name=go-build::$(go env GOCACHE)"
210+
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
211+
212+
- name: Go Build Cache
213+
uses: actions/cache@v3
214+
with:
215+
path: ${{ steps.go-cache-paths.outputs.go-build }}
216+
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
217+
218+
- name: Go Mod Cache
219+
uses: actions/cache@v3
220+
with:
221+
path: ${{ steps.go-cache-paths.outputs.go-mod }}
222+
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
223+
224+
- name: Install goreleaser
225+
uses: jaxxstorm/[email protected]
226+
env:
227+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
228+
with:
229+
repo: gotestyourself/gotestsum
230+
tag: v1.7.0
231+
232+
- uses: hashicorp/setup-terraform@v1
233+
with:
234+
terraform_version: 1.1.2
235+
terraform_wrapper: false
236+
237+
- name: Start PostgreSQL Database
238+
env:
239+
POSTGRES_PASSWORD: postgres
240+
POSTGRES_USER: postgres
241+
POSTGRES_DB: postgres
242+
PGDATA: /tmp
243+
run: |
244+
docker run \
245+
-e POSTGRES_PASSWORD=postgres \
246+
-e POSTGRES_USER=postgres \
247+
-e POSTGRES_DB=postgres \
248+
-e PGDATA=/tmp \
249+
-p 5432:5432 \
250+
-d postgres:11 \
251+
-c shared_buffers=1GB \
252+
-c max_connections=1000
253+
while ! pg_isready -h 127.0.0.1
254+
do
255+
echo "$(date) - waiting for database to start"
256+
sleep 0.5
257+
done
258+
176259
- name: Test with PostgreSQL Database
177-
if: runner.os == 'Linux'
178-
run: DB=true gotestsum --junitfile="gotests.xml" --packages="./..." --
260+
run: DB=ci gotestsum --junitfile="gotests.xml" --packages="./..." --
179261
-covermode=atomic -coverprofile="gotests.coverage" -timeout=3m
180262
-coverpkg=./...,github.com/coder/coder/codersdk
181-
-count=1 -race -parallel=2 -failfast
263+
-count=1 -parallel=2 -race -failfast
182264

183265
- name: Upload DataDog Trace
184-
if: (success() || failure()) && github.actor != 'dependabot[bot]' && runner.os == 'Linux'
266+
if: (success() || failure()) && github.actor != 'dependabot[bot]'
185267
env:
186268
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
187269
DD_DATABASE: postgresql
188270
GIT_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
189271
run: go run scripts/datadog-cireport/main.go gotests.xml
190272

191-
- uses: codecov/codecov-action@v2
192-
if: github.actor != 'dependabot[bot]'
193-
with:
194-
token: ${{ secrets.CODECOV_TOKEN }}
195-
files: ./gotests.coverage
196-
flags: unittest-go-${{ matrix.os }}
197-
fail_ci_if_error: true
198-
199273
deploy:
200274
name: "deploy"
201275
runs-on: ubuntu-latest
@@ -248,7 +322,7 @@ jobs:
248322

249323
- name: Cache Node
250324
id: cache-node
251-
uses: actions/cache@v2
325+
uses: actions/cache@v3
252326
with:
253327
path: |
254328
**/node_modules
@@ -308,11 +382,11 @@ jobs:
308382
# https://github.com/coder/coder/issues/384
309383
# - windows-2022
310384
steps:
311-
- uses: actions/checkout@v2
385+
- uses: actions/checkout@v3
312386

313387
- name: Cache Node
314388
id: cache-node
315-
uses: actions/cache@v2
389+
uses: actions/cache@v3
316390
with:
317391
path: |
318392
**/node_modules
@@ -339,17 +413,23 @@ jobs:
339413
with:
340414
install-only: true
341415

342-
- uses: actions/cache@v2
416+
- name: Echo Go Cache Paths
417+
id: go-cache-paths
418+
run: |
419+
echo "::set-output name=go-build::$(go env GOCACHE)"
420+
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
421+
422+
- name: Go Build Cache
423+
uses: actions/cache@v3
343424
with:
344-
# Go mod cache, Linux build cache, Mac build cache, Windows build cache
345-
path: |
346-
~/go/pkg/mod
347-
~/.cache/go-build
348-
~/Library/Caches/go-build
349-
%LocalAppData%\go-build
350-
key: ${{ matrix.os }}-go-${{ hashFiles('**/go.sum') }}
351-
restore-keys: |
352-
${{ matrix.os }}-go-
425+
path: ${{ steps.go-cache-paths.outputs.go-build }}
426+
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
427+
428+
- name: Go Mod Cache
429+
uses: actions/cache@v3
430+
with:
431+
path: ${{ steps.go-cache-paths.outputs.go-mod }}
432+
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
353433

354434
- run: make build
355435

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,8 @@ site/**/*.typegen.ts
2828
# Build
2929
dist/
3030
site/out/
31+
32+
*.tfstate
33+
*.tfplan
34+
*.lock.hcl
35+
.terraform/

.goreleaser.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
archives:
2-
- builds:
2+
- id: coder
3+
builds:
34
- coder
45
files:
56
- README.md
@@ -12,18 +13,18 @@ before:
1213
builds:
1314
- id: coder-slim
1415
dir: cmd/coder
15-
flags: [-tags=slim]
1616
ldflags: ["-s -w"]
1717
env: [CGO_ENABLED=0]
1818
goos: [darwin, linux, windows]
1919
goarch: [amd64, arm64]
2020
hooks:
2121
# The "trimprefix" appends ".exe" on Windows.
2222
post: |
23-
cp {{.Path}} site/out/bin/coder_{{ .Os }}_{{ .Arch }}{{ trimprefix .Name "coder" }}
23+
cp {{.Path}} site/out/bin/coder-{{ .Os }}-{{ .Arch }}{{ trimprefix .Name "coder" }}
2424
2525
- id: coder
2626
dir: cmd/coder
27+
flags: [-tags=embed]
2728
ldflags: ["-s -w"]
2829
env: [CGO_ENABLED=0]
2930
goos: [darwin, linux, windows]

.vscode/settings.json

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"cSpell.words": [
3+
"cliui",
34
"coderd",
45
"coderdtest",
56
"codersdk",
@@ -12,8 +13,10 @@
1213
"goleak",
1314
"gossh",
1415
"hashicorp",
16+
"hclsyntax",
1517
"httpmw",
1618
"idtoken",
19+
"Iflag",
1720
"incpatch",
1821
"isatty",
1922
"Jobf",
@@ -40,11 +43,14 @@
4043
"retrier",
4144
"sdkproto",
4245
"stretchr",
46+
"TCGETS",
4347
"tcpip",
48+
"TCSETS",
4449
"tfexec",
4550
"tfstate",
4651
"trimprefix",
4752
"unconvert",
53+
"Untar",
4854
"webrtc",
4955
"xerrors",
5056
"yamux"
@@ -61,13 +67,15 @@
6167
"files.exclude": {
6268
"**/node_modules": true
6369
},
70+
// Ensure files always have a newline.
71+
"files.insertFinalNewline": true,
6472
"go.lintTool": "golangci-lint",
6573
"go.lintFlags": ["--fast"],
6674
"go.lintOnSave": "package",
6775
"go.coverOnSave": true,
6876
// The codersdk is used by coderd another other packages extensively.
6977
// To reduce redundancy in tests, it's covered by other packages.
70-
"go.testFlags": ["-coverpkg=./.,github.com/coder/coder/codersdk"],
78+
"go.testFlags": ["-short", "-coverpkg=./.,github.com/coder/coder/codersdk"],
7179
"go.coverageDecorator": {
7280
"type": "gutter",
7381
"coveredHighlightColor": "rgba(64,128,128,0.5)",
@@ -79,5 +87,5 @@
7987
},
8088
// We often use a version of TypeScript that's ahead of the version shipped
8189
// with VS Code.
82-
"typescript.tsdk": "./site/node_modules/typescript/lib"
90+
"typescript.tsdk": "./site/node_modules/typescript/lib",
8391
}

Makefile

+5-5
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,14 @@ gen: database/generate peerbroker/proto provisionersdk/proto provisionerd/proto
5151

5252
install: bin
5353
@echo "--- Copying from bin to $(INSTALL_DIR)"
54-
cp -r ./dist/coder_$(GOOS)_$(GOARCH) $(INSTALL_DIR)
54+
cp -r ./dist/coder_$(GOOS)_$(GOARCH)/* $(INSTALL_DIR)
5555
@echo "-- CLI available at $(shell ls $(INSTALL_DIR)/coder*)"
5656
.PHONY: install
5757

58+
package:
59+
goreleaser release --snapshot --rm-dist
60+
.PHONY: package
61+
5862
peerbroker/proto: peerbroker/proto/peerbroker.proto
5963
protoc \
6064
--go_out=. \
@@ -89,7 +93,3 @@ site/out:
8993
# Restores GITKEEP files!
9094
git checkout HEAD site/out
9195
.PHONY: site/out
92-
93-
snapshot:
94-
goreleaser release --snapshot --rm-dist
95-
.PHONY: snapshot

0 commit comments

Comments
 (0)