Skip to content

Commit 89947c9

Browse files
committed
Merge main
2 parents cc11f71 + c44d036 commit 89947c9

File tree

95 files changed

+14283
-3585
lines changed

Some content is hidden

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

95 files changed

+14283
-3585
lines changed

.github/stale.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
daysUntilStale: 14
33
# Number of days of inactivity before a stale issue is closed
44
daysUntilClose: 5
5+
# Only apply the stale logic to pulls, since we are using issues to manage work
6+
only: pulls
57
# Label to apply when stale.
68
staleLabel: stale
79
# Comment to post when marking an issue as stale. Set to `false` to disable

.github/workflows/coder.yaml

Lines changed: 67 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,9 @@ jobs:
8888
- run: "make --output-sync -j gen"
8989
- run: ./scripts/check_unstaged.sh
9090

91-
style:
92-
name: "style/${{ matrix.style }}"
91+
style-fmt:
92+
name: "style/fmt"
9393
runs-on: ubuntu-latest
94-
strategy:
95-
matrix:
96-
style:
97-
- fmt
98-
fail-fast: false
9994
steps:
10095
- name: Checkout
10196
uses: actions/checkout@v2
@@ -116,8 +111,8 @@ jobs:
116111
run: yarn install
117112
working-directory: site
118113

119-
- name: "make ${{ matrix.style }}"
120-
run: "make --output-sync -j ${{ matrix.style }}"
114+
- name: "make fmt"
115+
run: "make --output-sync -j fmt"
121116

122117
test-go:
123118
name: "test/go"
@@ -155,16 +150,32 @@ jobs:
155150
terraform_wrapper: false
156151

157152
- name: Test with Mock Database
158-
run: gotestsum --jsonfile="gotests.json" --packages="./..." --
159-
-covermode=atomic -coverprofile="gotests.coverage" -timeout=3m
160-
-count=5 -race -short -parallel=2
153+
run: gotestsum --junitfile="gotests.xml" --packages="./..." --
154+
-covermode=atomic -coverprofile="gotests.coverage"
155+
-timeout=3m -count=5 -race -short -parallel=2
156+
157+
- name: Upload DataDog Trace
158+
if: (success() || failure()) && github.actor != 'dependabot[bot]'
159+
env:
160+
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
161+
DD_DATABASE: fake
162+
GIT_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
163+
run: go run scripts/datadog-cireport/main.go gotests.xml
161164

162165
- name: Test with PostgreSQL Database
163166
if: runner.os == 'Linux'
164-
run: DB=true gotestsum --jsonfile="gotests.json" --packages="./..." --
167+
run: DB=true gotestsum --junitfile="gotests.xml" --packages="./..." --
165168
-covermode=atomic -coverprofile="gotests.coverage" -timeout=3m
166169
-count=1 -race -parallel=2
167170

171+
- name: Upload DataDog Trace
172+
if: (success() || failure()) && github.actor != 'dependabot[bot]'
173+
env:
174+
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
175+
DD_DATABASE: postgresql
176+
GIT_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
177+
run: go run scripts/datadog-cireport/main.go gotests.xml
178+
168179
- uses: codecov/codecov-action@v2
169180
if: github.actor != 'dependabot[bot]'
170181
with:
@@ -173,6 +184,46 @@ jobs:
173184
flags: unittest-go-${{ matrix.os }}
174185
fail_ci_if_error: true
175186

187+
deploy:
188+
name: "deploy"
189+
runs-on: ubuntu-latest
190+
if: github.event_name != 'pull_request'
191+
permissions:
192+
contents: read
193+
id-token: write
194+
steps:
195+
- uses: actions/checkout@v2
196+
197+
- name: Authenticate to Google Cloud
198+
uses: google-github-actions/auth@v0
199+
with:
200+
workload_identity_provider: projects/477254869654/locations/global/workloadIdentityPools/github/providers/github
201+
service_account: github-coder@coder-ci.iam.gserviceaccount.com
202+
203+
- name: Set up Google Cloud SDK
204+
uses: google-github-actions/setup-gcloud@v0
205+
206+
- name: Configure Docker for Google Artifact Registry
207+
run: gcloud auth configure-docker us-docker.pkg.dev
208+
209+
- uses: actions/setup-node@v2
210+
with:
211+
node-version: "14"
212+
213+
- run: yarn install
214+
working-directory: site
215+
216+
- uses: actions/setup-go@v2
217+
with:
218+
go-version: "^1.17"
219+
220+
- run: make docker/image/coder
221+
222+
- run: docker push us-docker.pkg.dev/coder-blacktriangle-dev/ci/coder:latest
223+
224+
- name: Update coder service
225+
run: gcloud run services update coder --image us-docker.pkg.dev/coder-blacktriangle-dev/ci/coder:latest --project coder-blacktriangle-dev --tag "git-$(git rev-parse --short HEAD)" --region us-central1
226+
176227
test-js:
177228
name: "test/js"
178229
runs-on: ubuntu-latest
@@ -198,6 +249,9 @@ jobs:
198249
- run: yarn build
199250
working-directory: site
200251

252+
- run: yarn storybook:build
253+
working-directory: site
254+
201255
- run: yarn test:coverage
202256
working-directory: site
203257

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ yarn-error.log
1919
site/.eslintcache
2020
site/.next/
2121
site/node_modules/
22+
site/storybook-static/
2223
site/yarn-error.log
2324
coverage/
2425

.golangci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ linters-settings:
100100
# - whyNoLint
101101
# - wrapperFunc
102102
# - yodaStyleExpr
103+
settings:
104+
ruleguard:
105+
failOn: all
106+
rules: rules.go
103107

104108
goimports:
105109
local-prefixes: coder.com,cdr.dev,go.coder.com,github.com/cdr,github.com/coder
@@ -241,6 +245,7 @@ linters:
241245
- staticcheck
242246
- structcheck
243247
- tenv
248+
- testpackage
244249
- tparallel
245250
- typecheck
246251
- unconvert

.vscode/settings.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@
3434
"goleak",
3535
"hashicorp",
3636
"httpmw",
37+
"Jobf",
3738
"moby",
3839
"nhooyr",
3940
"nolint",
4041
"nosec",
4142
"oneof",
43+
"parameterscopeid",
4244
"protobuf",
4345
"provisionerd",
4446
"provisionersdk",

Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@ bin/coderd:
33
go build -o bin/coderd cmd/coderd/main.go
44
.PHONY: bin/coderd
55

6-
bin/provisionerd:
7-
mkdir -p bin
8-
go build -o bin/provisionerd cmd/provisionerd/main.go
9-
.PHONY: bin/provisionerd
10-
11-
build: site/out bin/coderd bin/provisionerd
6+
build: site/out bin/coderd
127
.PHONY: build
138

149
# Runs migrations to output a dump of the database.
@@ -22,6 +17,11 @@ database/generate: fmt/sql database/dump.sql database/query.sql
2217
cd database && gofmt -w -r 'Queries -> sqlQuerier' *.go
2318
.PHONY: database/generate
2419

20+
docker/image/coder: build
21+
cp ./images/coder/run.sh ./bin
22+
docker build --network=host -t us-docker.pkg.dev/coder-blacktriangle-dev/ci/coder:latest -f images/coder/Dockerfile ./bin
23+
.PHONY: docker/build
24+
2525
fmt/prettier:
2626
@echo "--- prettier"
2727
# Avoid writing files in CI to reduce file write activity

codecov.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ ignore:
3131
- peerbroker/proto
3232
- provisionerd/proto
3333
- provisionersdk/proto
34+
- scripts/datadog-cireport

coderd/coderd.go

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,17 @@ func New(options *Options) http.Handler {
6262
r.Use(httpmw.ExtractProjectParam(options.Database))
6363
r.Get("/", api.projectByOrganization)
6464
r.Get("/workspaces", api.workspacesByProject)
65-
r.Route("/history", func(r chi.Router) {
66-
r.Get("/", api.projectHistoryByOrganization)
67-
r.Post("/", api.postProjectHistoryByOrganization)
68-
r.Route("/{projecthistory}", func(r chi.Router) {
69-
r.Use(httpmw.ExtractProjectHistoryParam(api.Database))
70-
r.Get("/", api.projectHistoryByOrganizationAndName)
65+
r.Route("/parameters", func(r chi.Router) {
66+
r.Get("/", api.parametersByProject)
67+
r.Post("/", api.postParametersByProject)
68+
})
69+
r.Route("/versions", func(r chi.Router) {
70+
r.Get("/", api.projectVersionsByOrganization)
71+
r.Post("/", api.postProjectVersionByOrganization)
72+
r.Route("/{projectversion}", func(r chi.Router) {
73+
r.Use(httpmw.ExtractProjectVersionParam(api.Database))
74+
r.Get("/", api.projectVersionByOrganizationAndName)
75+
r.Get("/parameters", api.projectVersionParametersByOrganizationAndName)
7176
})
7277
})
7378
})
@@ -81,12 +86,11 @@ func New(options *Options) http.Handler {
8186
r.Get("/", api.workspaces)
8287
r.Route("/{user}", func(r chi.Router) {
8388
r.Use(httpmw.ExtractUserParam(options.Database))
84-
r.Get("/", api.workspaces)
8589
r.Post("/", api.postWorkspaceByUser)
8690
r.Route("/{workspace}", func(r chi.Router) {
8791
r.Use(httpmw.ExtractWorkspaceParam(options.Database))
8892
r.Get("/", api.workspaceByUser)
89-
r.Route("/history", func(r chi.Router) {
93+
r.Route("/version", func(r chi.Router) {
9094
r.Post("/", api.postWorkspaceHistoryByUser)
9195
r.Get("/", api.workspaceHistoryByUser)
9296
r.Route("/{workspacehistory}", func(r chi.Router) {
@@ -98,12 +102,31 @@ func New(options *Options) http.Handler {
98102
})
99103
})
100104

101-
r.Route("/provisioners/daemons", func(r chi.Router) {
102-
r.Get("/", api.provisionerDaemons)
103-
r.Get("/serve", api.provisionerDaemonsServe)
105+
r.Route("/files", func(r chi.Router) {
106+
r.Use(httpmw.ExtractAPIKey(options.Database, nil))
107+
r.Post("/", api.postFiles)
108+
})
109+
110+
r.Route("/provisioners", func(r chi.Router) {
111+
r.Route("/daemons", func(r chi.Router) {
112+
r.Get("/", api.provisionerDaemons)
113+
r.Get("/serve", api.provisionerDaemonsServe)
114+
})
115+
r.Route("/jobs/{organization}", func(r chi.Router) {
116+
r.Use(
117+
httpmw.ExtractAPIKey(options.Database, nil),
118+
httpmw.ExtractOrganizationParam(options.Database),
119+
)
120+
r.Post("/import", api.postProvisionerImportJobByOrganization)
121+
r.Route("/{provisionerjob}", func(r chi.Router) {
122+
r.Use(httpmw.ExtractProvisionerJobParam(options.Database))
123+
r.Get("/", api.provisionerJobByOrganization)
124+
r.Get("/logs", api.provisionerJobLogsByID)
125+
})
126+
})
104127
})
105128
})
106-
r.NotFound(site.Handler().ServeHTTP)
129+
r.NotFound(site.Handler(options.Logger).ServeHTTP)
107130
return r
108131
}
109132

coderd/coderd_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package coderd_test
2+
3+
import (
4+
"testing"
5+
6+
"go.uber.org/goleak"
7+
)
8+
9+
func TestMain(m *testing.M) {
10+
goleak.VerifyTestMain(m)
11+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy