Skip to content

Commit 3a724e4

Browse files
committed
Merge main
2 parents b85dcf1 + 3eb6fb7 commit 3a724e4

File tree

151 files changed

+6680
-5612
lines changed

Some content is hidden

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

151 files changed

+6680
-5612
lines changed

.github/workflows/coder.yaml

Lines changed: 84 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
name: style/lint/golangci
3838
runs-on: ubuntu-latest
3939
steps:
40-
- uses: actions/checkout@v2
40+
- uses: actions/checkout@v3
4141
- uses: actions/setup-go@v2
4242
with:
4343
go-version: "^1.17"
@@ -51,7 +51,7 @@ jobs:
5151
runs-on: ubuntu-latest
5252
steps:
5353
- name: Checkout
54-
uses: actions/checkout@v2
54+
uses: actions/checkout@v3
5555

5656
- name: Cache Node
5757
id: cache-node
@@ -73,7 +73,7 @@ jobs:
7373
name: "style/gen"
7474
runs-on: ubuntu-latest
7575
steps:
76-
- uses: actions/checkout@v2
76+
- uses: actions/checkout@v3
7777
- name: Install Protoc
7878
uses: arduino/setup-protoc@v1
7979
with:
@@ -95,7 +95,7 @@ jobs:
9595
runs-on: ubuntu-latest
9696
steps:
9797
- name: Checkout
98-
uses: actions/checkout@v2
98+
uses: actions/checkout@v3
9999
with:
100100
fetch-depth: 0
101101
submodules: true
@@ -125,7 +125,7 @@ jobs:
125125
- macos-latest
126126
- windows-2022
127127
steps:
128-
- uses: actions/checkout@v2
128+
- uses: actions/checkout@v3
129129

130130
- uses: actions/setup-go@v2
131131
with:
@@ -157,20 +157,23 @@ jobs:
157157
GOMAXPROCS: ${{ runner.os == 'Windows' && 1 || 2 }}
158158
run: gotestsum --junitfile="gotests.xml" --packages="./..." --
159159
-covermode=atomic -coverprofile="gotests.coverage"
160+
-coverpkg=./...,github.com/coder/coder/codersdk
160161
-timeout=3m -count=$GOCOUNT -race -short -failfast
161162

162163
- name: Upload DataDog Trace
163164
if: (success() || failure()) && github.actor != 'dependabot[bot]'
164165
env:
165166
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
166167
DD_DATABASE: fake
168+
DD_CATEGORY: unit
167169
GIT_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
168170
run: go run scripts/datadog-cireport/main.go gotests.xml
169171

170172
- name: Test with PostgreSQL Database
171173
if: runner.os == 'Linux'
172174
run: DB=true gotestsum --junitfile="gotests.xml" --packages="./..." --
173175
-covermode=atomic -coverprofile="gotests.coverage" -timeout=3m
176+
-coverpkg=./...,github.com/coder/coder/codersdk
174177
-count=1 -race -parallel=2 -failfast
175178

176179
- name: Upload DataDog Trace
@@ -197,7 +200,7 @@ jobs:
197200
contents: read
198201
id-token: write
199202
steps:
200-
- uses: actions/checkout@v2
203+
- uses: actions/checkout@v3
201204

202205
- name: Authenticate to Google Cloud
203206
uses: google-github-actions/auth@v0
@@ -233,7 +236,7 @@ jobs:
233236
name: "test/js"
234237
runs-on: ubuntu-latest
235238
steps:
236-
- uses: actions/checkout@v2
239+
- uses: actions/checkout@v3
237240

238241
- name: Cache Node
239242
id: cache-node
@@ -279,6 +282,78 @@ jobs:
279282
if: (success() || failure()) && github.actor != 'dependabot[bot]'
280283
env:
281284
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
282-
DD_DATABASE: postgresql
285+
DD_CATEGORY: unit
286+
GIT_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
287+
run: go run scripts/datadog-cireport/main.go site/test-results/junit.xml
288+
289+
test-e2e:
290+
name: "test/e2e/${{ matrix.os }}"
291+
runs-on: ${{ matrix.os }}
292+
strategy:
293+
matrix:
294+
os:
295+
- ubuntu-latest
296+
- macos-latest
297+
# TODO: Get `make build` running on Windows 2022
298+
# https://github.com/coder/coder/issues/384
299+
# - windows-2022
300+
steps:
301+
- uses: actions/checkout@v2
302+
303+
- name: Cache Node
304+
id: cache-node
305+
uses: actions/cache@v2
306+
with:
307+
path: |
308+
**/node_modules
309+
.eslintcache
310+
key: js-${{ runner.os }}-test-${{ hashFiles('**/yarn.lock') }}
311+
312+
# Go is required for uploading the test results to datadog
313+
- uses: actions/setup-go@v2
314+
with:
315+
go-version: "^1.17"
316+
317+
- uses: hashicorp/setup-terraform@v1
318+
with:
319+
terraform_version: 1.1.2
320+
terraform_wrapper: false
321+
322+
- uses: actions/setup-node@v3
323+
with:
324+
node-version: "14"
325+
326+
- uses: goreleaser/goreleaser-action@v2
327+
with:
328+
install-only: true
329+
330+
- uses: actions/cache@v2
331+
with:
332+
# Go mod cache, Linux build cache, Mac build cache, Windows build cache
333+
path: |
334+
~/go/pkg/mod
335+
~/.cache/go-build
336+
~/Library/Caches/go-build
337+
%LocalAppData%\go-build
338+
key: ${{ matrix.os }}-go-${{ hashFiles('**/go.sum') }}
339+
restore-keys: |
340+
${{ matrix.os }}-go-
341+
342+
- run: make build
343+
344+
- run: yarn playwright:install
345+
working-directory: site
346+
347+
- run: yarn playwright:install-deps
348+
working-directory: site
349+
350+
- run: yarn playwright:test
351+
working-directory: site
352+
353+
- name: Upload DataDog Trace
354+
if: (success() || failure()) && github.actor != 'dependabot[bot]' && runner.os == 'Linux'
355+
env:
356+
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
357+
DD_CATEGORY: e2e
283358
GIT_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
284-
run: go run scripts/datadog-cireport/main.go site/test_results/junit.xml
359+
run: go run scripts/datadog-cireport/main.go site/test-results/junit.xml

.github/workflows/release.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: release
2+
on:
3+
push:
4+
tags:
5+
- "v*"
6+
jobs:
7+
goreleaser:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
with:
12+
fetch-depth: 0
13+
- uses: actions/setup-go@v2
14+
with:
15+
go-version: "^1.17"
16+
17+
- name: Run GoReleaser
18+
uses: goreleaser/goreleaser-action@v2.9.1
19+
with:
20+
version: latest
21+
args: release --rm-dist
22+
env:
23+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ site/.eslintcache
2020
site/.next/
2121
site/node_modules/
2222
site/storybook-static/
23-
site/test_results/
23+
site/test-results/
2424
site/yarn-error.log
2525
coverage/
2626

2727
# Build
28-
bin/
28+
dist/
2929
site/out/

.goreleaser.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
archives:
2+
- builds:
3+
- coder
4+
files:
5+
- README.md
6+
7+
before:
8+
hooks:
9+
- go mod tidy
10+
- rm -f site/out/bin/coder*
11+
12+
builds:
13+
- id: coder-slim
14+
dir: cmd/coder
15+
flags: [-tags=slim]
16+
ldflags: ["-s -w"]
17+
env: [CGO_ENABLED=0]
18+
goos: [darwin, linux, windows]
19+
goarch: [amd64, arm64]
20+
hooks:
21+
# The "trimprefix" appends ".exe" on Windows.
22+
post: |
23+
cp {{.Path}} site/out/bin/coder_{{ .Os }}_{{ .Arch }}{{ trimprefix .Name "coder" }}
24+
25+
- id: coder
26+
dir: cmd/coder
27+
ldflags: ["-s -w"]
28+
env: [CGO_ENABLED=0]
29+
goos: [darwin, linux, windows]
30+
goarch: [amd64, arm64]
31+
32+
nfpms:
33+
- vendor: Coder
34+
homepage: https://coder.com
35+
maintainer: Coder <support@coder.com>
36+
description: |
37+
Provision development environments with infrastructure with code
38+
formats:
39+
- apk
40+
- deb
41+
- rpm
42+
suggests:
43+
- postgresql
44+
builds:
45+
- coder
46+
47+
release:
48+
ids: [coder]

.vscode/settings.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
"go.lintFlags": ["--fast"],
77
"go.lintOnSave": "package",
88
"go.coverOnSave": true,
9+
// The codersdk is used by coderd another other packages extensively.
10+
// To reduce redundancy in tests, it's covered by other packages.
11+
"go.testFlags": ["-coverpkg=./.,github.com/coder/coder/codersdk"],
912
"go.coverageDecorator": {
1013
"type": "gutter",
1114
"coveredHighlightColor": "rgba(64,128,128,0.5)",
@@ -32,18 +35,22 @@
3235
"drpcmux",
3336
"drpcserver",
3437
"fatih",
38+
"goarch",
3539
"goleak",
3640
"gossh",
3741
"hashicorp",
3842
"httpmw",
3943
"idtoken",
44+
"incpatch",
4045
"isatty",
4146
"Jobf",
4247
"kirsle",
48+
"ldflags",
4349
"manifoldco",
4450
"mattn",
4551
"mitchellh",
4652
"moby",
53+
"nfpms",
4754
"nhooyr",
4855
"nolint",
4956
"nosec",
@@ -63,6 +70,7 @@
6370
"tcpip",
6471
"tfexec",
6572
"tfstate",
73+
"trimprefix",
6674
"unconvert",
6775
"webrtc",
6876
"xerrors",

Makefile

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,11 @@ INSTALL_DIR=$(shell go env GOPATH)/bin
22
GOOS=$(shell go env GOOS)
33
GOARCH=$(shell go env GOARCH)
44

5-
bin/coder:
6-
mkdir -p bin
7-
GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o bin/coder-$(GOOS)-$(GOARCH) cmd/coder/main.go
8-
.PHONY: bin/coder
5+
bin:
6+
goreleaser build --single-target --snapshot --rm-dist
7+
.PHONY: bin
98

10-
bin/coderd:
11-
mkdir -p bin
12-
go build -o bin/coderd cmd/coderd/main.go
13-
.PHONY: bin/coderd
14-
15-
bin/terraform-provider-coder:
16-
mkdir -p bin
17-
go build -o bin/terraform-provider-coder cmd/terraform-provider-coder/main.go
18-
.PHONY: bin/terraform-provider-coder
19-
20-
build: site/out bin/coder bin/coderd bin/terraform-provider-coder
9+
build: site/out bin
2110
.PHONY: build
2211

2312
# Runs migrations to output a dump of the database.
@@ -60,17 +49,12 @@ fmt: fmt/prettier fmt/sql
6049
gen: database/generate peerbroker/proto provisionersdk/proto provisionerd/proto
6150
.PHONY: gen
6251

63-
install:
52+
install: bin
6453
@echo "--- Copying from bin to $(INSTALL_DIR)"
65-
cp -r ./bin $(INSTALL_DIR)
54+
cp -r ./dist/coder_$(GOOS)_$(GOARCH) $(INSTALL_DIR)
6655
@echo "-- CLI available at $(shell ls $(INSTALL_DIR)/coder*)"
6756
.PHONY: install
6857

69-
install/terraform-provider-coder: bin/terraform-provider-coder
70-
$(eval OS_ARCH := $(shell go env GOOS)_$(shell go env GOARCH))
71-
mkdir -p ~/.terraform.d/plugins/coder.com/internal/coder/0.2/$(OS_ARCH)
72-
cp bin/terraform-provider-coder ~/.terraform.d/plugins/coder.com/internal/coder/0.2/$(OS_ARCH)
73-
7458
peerbroker/proto: peerbroker/proto/peerbroker.proto
7559
protoc \
7660
--go_out=. \
@@ -102,4 +86,10 @@ site/out:
10286
./scripts/yarn_install.sh
10387
cd site && yarn build
10488
# cd site && yarn export
89+
# Restores GITKEEP files!
90+
git checkout HEAD site/out
10591
.PHONY: site/out
92+
93+
snapshot:
94+
goreleaser release --snapshot --rm-dist
95+
.PHONY: snapshot

0 commit comments

Comments
 (0)