Skip to content

Commit 8114407

Browse files
committed
Merge branch 'main' into workflow
2 parents c2a7119 + 64d9d00 commit 8114407

Some content is hidden

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

79 files changed

+1840
-925
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# This workflow (aka The Gauntlet) is a high-iteration run of our tests,
2+
# used to evaluate stability and shake out intermittent failures.
3+
name: coder-test-stability
4+
on:
5+
schedule:
6+
# Run everyday around midnight Central.
7+
- cron: "0 6 * * *"
8+
9+
pull_request:
10+
branches:
11+
- main
12+
paths:
13+
- .github/workflows/coder-test-stability.yaml
14+
workflow_dispatch:
15+
inputs:
16+
iterationCount:
17+
description: 'Iteration Count'
18+
required: false
19+
default: '10'
20+
21+
# Cancel in-progress runs for pull requests when developers push
22+
# additional changes, and serialize builds in branches.
23+
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-concurrency-to-cancel-any-in-progress-job-or-run
24+
concurrency:
25+
group: ${{ github.workflow }}-${{ github.ref }}
26+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
27+
28+
jobs:
29+
coder-test-stability:
30+
name: "test/go/stability/${{ matrix.os }}/${{ matrix.instance }}"
31+
runs-on: ${{ matrix.os }}
32+
strategy:
33+
matrix:
34+
os:
35+
- ubuntu-latest
36+
- macos-latest
37+
- windows-2022
38+
instance:
39+
- 1
40+
- 2
41+
steps:
42+
- uses: actions/checkout@v2
43+
44+
- uses: actions/setup-go@v2
45+
with:
46+
go-version: "^1.17"
47+
48+
- uses: actions/cache@v2
49+
with:
50+
# Go mod cache, Linux build cache, Mac build cache, Windows build cache
51+
path: |
52+
~/go/pkg/mod
53+
~/.cache/go-build
54+
~/Library/Caches/go-build
55+
%LocalAppData%\go-build
56+
key: ${{ matrix.os }}-go-${{ hashFiles('**/go.sum') }}
57+
restore-keys: |
58+
${{ matrix.os }}-go-
59+
60+
- run: go install gotest.tools/gotestsum@latest
61+
62+
- uses: hashicorp/setup-terraform@v1
63+
with:
64+
terraform_version: 1.1.2
65+
terraform_wrapper: false
66+
67+
- name: Test with Mock Database
68+
shell: bash
69+
env:
70+
GOCOUNT: ${{ github.event.inputs.iterationCount || 10 }}
71+
GOMAXPROCS: ${{ runner.os == 'Windows' && 1 || 2 }}
72+
run: gotestsum --junitfile="gotests.xml" --packages="./..." --
73+
-covermode=atomic -coverprofile="gotests.coverage"
74+
-timeout=15m -count=$GOCOUNT -race -short -failfast
75+
76+
- name: Upload DataDog Trace
77+
if: (success() || failure()) && github.actor != 'dependabot[bot]'
78+
env:
79+
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
80+
DD_DATABASE: fake
81+
GIT_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
82+
run: go run scripts/datadog-cireport/main.go gotests.xml
83+
84+
- name: Test with PostgreSQL Database
85+
if: runner.os == 'Linux'
86+
env:
87+
GOCOUNT: ${{ github.event.inputs.iterationCount || 10 }}
88+
run: DB=true gotestsum --junitfile="gotests.xml" --packages="./..." --
89+
-covermode=atomic -coverprofile="gotests.coverage" -timeout=30m
90+
-count=$GOCOUNT -race -parallel=2 -failfast
91+
92+
- name: Upload DataDog Trace
93+
if: (success() || failure()) && github.actor != 'dependabot[bot]' && runner.os == 'Linux'
94+
env:
95+
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
96+
DD_DATABASE: postgresql
97+
GIT_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
98+
run: go run scripts/datadog-cireport/main.go gotests.xml

.github/workflows/coder.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ jobs:
7979
- name: Install Protoc
8080
uses: arduino/setup-protoc@v1
8181
with:
82-
version: "3.6.1"
82+
version: "3.19.4"
8383
- uses: actions/setup-go@v2
8484
with:
8585
go-version: "^1.17"
@@ -370,4 +370,4 @@ jobs:
370370
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
371371
DD_CATEGORY: e2e
372372
GIT_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
373-
run: go run scripts/datadog-cireport/main.go site/test-results/junit.xml
373+
run: go run scripts/datadog-cireport/main.go site/test-results/junit.xml

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ site/storybook-static/
2323
site/test-results/
2424
site/yarn-error.log
2525
coverage/
26+
site/**/*.typegen.ts
2627

2728
# Build
2829
dist/

.golangci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,15 @@ linters-settings:
184184
- r
185185
- i
186186
- db
187+
- t
187188
# Optional list of variable declarations that should be ignored completely. (defaults to empty list)
188189
# Entries must be in the form of "<variable name> <type>" or "<variable name> *<type>" for
189190
# variables, or "const <name>" for constants.
190191
ignore-decls:
191192
- rw http.ResponseWriter
192193
- r *http.Request
193194
- t testing.T
195+
- t testing.TB
194196

195197
issues:
196198
# Rules listed here: https://github.com/securego/gosec#available-rules

.vscode/settings.json

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,4 @@
11
{
2-
"files.exclude": {
3-
"**/node_modules": true
4-
},
5-
"go.lintTool": "golangci-lint",
6-
"go.lintFlags": ["--fast"],
7-
"go.lintOnSave": "package",
8-
"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": ["-short", "-coverpkg=./.,github.com/coder/coder/codersdk"],
12-
"go.coverageDecorator": {
13-
"type": "gutter",
14-
"coveredHighlightColor": "rgba(64,128,128,0.5)",
15-
"uncoveredHighlightColor": "rgba(128,64,64,0.25)",
16-
"coveredBorderColor": "rgba(64,128,128,0.5)",
17-
"uncoveredBorderColor": "rgba(128,64,64,0.25)",
18-
"coveredGutterStyle": "blockgreen",
19-
"uncoveredGutterStyle": "blockred"
20-
},
21-
"emeraldwalk.runonsave": {
22-
"commands": [
23-
{
24-
"match": "database/query.sql",
25-
"cmd": "make gen"
26-
}
27-
]
28-
},
292
"cSpell.words": [
303
"cliui",
314
"coderd",
@@ -82,5 +55,35 @@
8255
"xerrors",
8356
"yamux"
8457
],
85-
"eslint.workingDirectories": ["./site"]
58+
"emeraldwalk.runonsave": {
59+
"commands": [
60+
{
61+
"match": "database/query.sql",
62+
"cmd": "make gen"
63+
}
64+
]
65+
},
66+
"eslint.workingDirectories": ["./site"],
67+
"files.exclude": {
68+
"**/node_modules": true
69+
},
70+
"go.lintTool": "golangci-lint",
71+
"go.lintFlags": ["--fast"],
72+
"go.lintOnSave": "package",
73+
"go.coverOnSave": true,
74+
// The codersdk is used by coderd another other packages extensively.
75+
// To reduce redundancy in tests, it's covered by other packages.
76+
"go.testFlags": ["-short", "-coverpkg=./.,github.com/coder/coder/codersdk"],
77+
"go.coverageDecorator": {
78+
"type": "gutter",
79+
"coveredHighlightColor": "rgba(64,128,128,0.5)",
80+
"uncoveredHighlightColor": "rgba(128,64,64,0.25)",
81+
"coveredBorderColor": "rgba(64,128,128,0.5)",
82+
"uncoveredBorderColor": "rgba(128,64,64,0.25)",
83+
"coveredGutterStyle": "blockgreen",
84+
"uncoveredGutterStyle": "blockred"
85+
},
86+
// We often use a version of TypeScript that's ahead of the version shipped
87+
// with VS Code.
88+
"typescript.tsdk": "./site/node_modules/typescript/lib"
8689
}

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ provisionersdk/proto: provisionersdk/proto/provisioner.proto
8888

8989
site/out:
9090
./scripts/yarn_install.sh
91+
cd site && yarn typegen
9192
cd site && yarn build
9293
# Restores GITKEEP files!
9394
git checkout HEAD site/out

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ To manually run the server and go through first-time set up, run the following c
4848

4949
You'll now be able to login and access the server.
5050

51-
To create a project, run:
5251
- `dist/coder_linux_amd64/coder projects create -d /path/to/project`
5352

5453
### Development
@@ -63,6 +62,10 @@ The `develop.sh` script does three things:
6362

6463
This is the recommend flow for working on the front-end, as hot-reload is set up as part of the webpack config.
6564

65+
Note that `./develop.sh` creates a user and allows you to log into the UI, but does not log you into the CLI, which is required for creating a project. Use the `login` command above before the `projects create` command.
66+
67+
While we're working on automating XState typegen, you may need to run `yarn typegen` from `site`.
68+
6669
## Front-End Plan
6770

6871
For the front-end team, we're planning on 2 phases to the 'v2' work:

codecov.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,5 @@ ignore:
3535
- provisionerd/proto
3636
- provisionersdk/proto
3737
- scripts/datadog-cireport
38+
- site/.storybook
3839
- rules.go

coderd/coderd.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ type Options struct {
2929

3030
// New constructs the Coder API into an HTTP handler.
3131
//
32-
// A wait function is returned to handle awaiting closure
33-
// of hijacked HTTP requests.
32+
// A wait function is returned to handle awaiting closure of hijacked HTTP
33+
// requests.
3434
func New(options *Options) (http.Handler, func()) {
3535
if options.AgentConnectionUpdateFrequency == 0 {
3636
options.AgentConnectionUpdateFrequency = 3 * time.Second

coderd/coderdtest/coderdtest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func New(t *testing.T, options *Options) *codersdk.Client {
6161
t.Cleanup(func() {
6262
_ = sqlDB.Close()
6363
})
64-
err = database.Migrate(sqlDB)
64+
err = database.MigrateUp(sqlDB)
6565
require.NoError(t, err)
6666
db = database.New(sqlDB)
6767

0 commit comments

Comments
 (0)