Skip to content

Commit 8cc120d

Browse files
committed
Merge branch 'main' into 7582-validation-min-max-fix
2 parents 85a7bd3 + 2b63492 commit 8cc120d

Some content is hidden

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

54 files changed

+847
-649
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,8 @@ runs:
88
with:
99
cache: true
1010
go-version: "~1.20"
11+
- name: Install gotestsum
12+
uses: jaxxstorm/action-install-gh-release@v1.10.0
13+
with:
14+
repo: gotestyourself/gotestsum
15+
tag: v1.9.0
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Upload tests to datadog
2+
if: always()
3+
inputs:
4+
api-key:
5+
description: "Datadog API key"
6+
required: true
7+
runs:
8+
using: "composite"
9+
steps:
10+
- shell: bash
11+
run: |
12+
npm install -g @datadog/datadog-ci
13+
datadog-ci junit upload --service coder ./gotests.xml \
14+
--tags os:${{runner.os}} --tags runner_name:${{runner.name}}
15+
env:
16+
DATADOG_API_KEY: ${{ inputs.api-key }}

.github/workflows/ci.yaml

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -199,14 +199,6 @@ jobs:
199199

200200
- uses: ./.github/actions/setup-go
201201

202-
- name: Install gotestsum
203-
uses: jaxxstorm/action-install-gh-release@v1.10.0
204-
env:
205-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
206-
with:
207-
repo: gotestyourself/gotestsum
208-
tag: v1.9.0
209-
210202
- uses: hashicorp/setup-terraform@v2
211203
with:
212204
terraform_version: 1.1.9
@@ -243,6 +235,11 @@ jobs:
243235
path: ./gotests.xml
244236
retention-days: 30
245237

238+
- uses: ./.github/actions/upload-datadog
239+
if: always()
240+
with:
241+
api-key: ${{ secrets.DATADOG_API_KEY }}
242+
246243
- uses: codecov/codecov-action@v3
247244
# This action has a tendency to error out unexpectedly, it has
248245
# the `fail_ci_if_error` option that defaults to `false`, but
@@ -267,14 +264,6 @@ jobs:
267264

268265
- uses: ./.github/actions/setup-go
269266

270-
- name: Install gotestsum
271-
uses: jaxxstorm/action-install-gh-release@v1.10.0
272-
env:
273-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
274-
with:
275-
repo: gotestyourself/gotestsum
276-
tag: v1.9.0
277-
278267
- uses: hashicorp/setup-terraform@v2
279268
with:
280269
terraform_version: 1.1.9
@@ -299,6 +288,11 @@ jobs:
299288
path: ./gotests.xml
300289
retention-days: 30
301290

291+
- uses: ./.github/actions/upload-datadog
292+
if: always()
293+
with:
294+
api-key: ${{ secrets.DATADOG_API_KEY }}
295+
302296
- uses: codecov/codecov-action@v3
303297
# This action has a tendency to error out unexpectedly, it has
304298
# the `fail_ci_if_error` option that defaults to `false`, but
@@ -326,7 +320,12 @@ jobs:
326320

327321
- name: Run Tests
328322
run: |
329-
go test -race ./...
323+
gotestsum --junitfile="gotests.xml" -- -race ./...
324+
325+
- uses: ./.github/actions/upload-datadog
326+
if: always()
327+
with:
328+
api-key: ${{ secrets.DATADOG_API_KEY }}
330329

331330
deploy:
332331
name: "deploy"

cli/server_createadminuser.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ func (r *RootCmd) newCreateAdminUserCommand() *clibase.Cmd {
238238

239239
createAdminUserCommand.Options.Add(
240240
clibase.Option{
241-
Env: "CODER_POSTGRES_URL",
241+
Env: "CODER_PG_CONNECTION_URL",
242242
Flag: "postgres-url",
243243
Description: "URL of a PostgreSQL database. If empty, the built-in PostgreSQL deployment will be used (Coder must not be already running in this case).",
244244
Value: clibase.StringOf(&newUserDBURL),

cli/server_createadminuser_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ func TestServerCreateAdminUser(t *testing.T) {
157157
defer cancel()
158158

159159
inv, _ := clitest.New(t, "server", "create-admin-user")
160-
inv.Environ.Set("CODER_POSTGRES_URL", connectionURL)
160+
inv.Environ.Set("CODER_PG_CONNECTION_URL", connectionURL)
161161
inv.Environ.Set("CODER_SSH_KEYGEN_ALGORITHM", "ed25519")
162162
inv.Environ.Set("CODER_USERNAME", username)
163163
inv.Environ.Set("CODER_EMAIL", email)

cli/testdata/coder_server_create-admin-user_--help.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ to every organization.
1212
The password of the new user. If not specified, you will be prompted
1313
via stdin.
1414

15-
--postgres-url string, $CODER_POSTGRES_URL
15+
--postgres-url string, $CODER_PG_CONNECTION_URL
1616
URL of a PostgreSQL database. If empty, the built-in PostgreSQL
1717
deployment will be used (Coder must not be already running in this
1818
case).

coderd/apidoc/docs.go

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/coderd.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ type Options struct {
130130
// AppSecurityKey is the crypto key used to sign and encrypt tokens related to
131131
// workspace applications. It consists of both a signing and encryption key.
132132
AppSecurityKey workspaceapps.SecurityKey
133-
HealthcheckFunc func(ctx context.Context, apiKey string) (*healthcheck.Report, error)
133+
HealthcheckFunc func(ctx context.Context, apiKey string) *healthcheck.Report
134134
HealthcheckTimeout time.Duration
135135
HealthcheckRefresh time.Duration
136136

@@ -266,7 +266,7 @@ func New(options *Options) *API {
266266
options.TemplateScheduleStore.Store(&v)
267267
}
268268
if options.HealthcheckFunc == nil {
269-
options.HealthcheckFunc = func(ctx context.Context, apiKey string) (*healthcheck.Report, error) {
269+
options.HealthcheckFunc = func(ctx context.Context, apiKey string) *healthcheck.Report {
270270
return healthcheck.Run(ctx, &healthcheck.ReportOptions{
271271
AccessURL: options.AccessURL,
272272
DERPMap: options.DERPMap.Clone(),

coderd/coderdtest/coderdtest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ type Options struct {
107107
TrialGenerator func(context.Context, string) error
108108
TemplateScheduleStore schedule.TemplateScheduleStore
109109

110-
HealthcheckFunc func(ctx context.Context, apiKey string) (*healthcheck.Report, error)
110+
HealthcheckFunc func(ctx context.Context, apiKey string) *healthcheck.Report
111111
HealthcheckTimeout time.Duration
112112
HealthcheckRefresh time.Duration
113113

coderd/database/dbfake/databasefake.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ func (q *fakeQuerier) GetTemplateDAUs(_ context.Context, arg database.GetTemplat
453453
continue
454454
}
455455

456-
date := as.CreatedAt.UTC().Add(time.Duration(arg.TzOffset) * time.Hour).Truncate(time.Hour * 24)
456+
date := as.CreatedAt.UTC().Add(time.Duration(arg.TzOffset) * time.Hour * -1).Truncate(time.Hour * 24)
457457

458458
dateEntry := seens[date]
459459
if dateEntry == nil {
@@ -492,7 +492,7 @@ func (q *fakeQuerier) GetDeploymentDAUs(_ context.Context, tzOffset int32) ([]da
492492
if as.ConnectionCount == 0 {
493493
continue
494494
}
495-
date := as.CreatedAt.UTC().Add(time.Duration(tzOffset) * time.Hour).Truncate(time.Hour * 24)
495+
date := as.CreatedAt.UTC().Add(time.Duration(tzOffset) * -1 * time.Hour).Truncate(time.Hour * 24)
496496

497497
dateEntry := seens[date]
498498
if dateEntry == nil {

coderd/debug.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,9 @@ func (api *API) debugDeploymentHealth(rw http.ResponseWriter, r *http.Request) {
4747
ctx, cancel := context.WithTimeout(context.Background(), api.HealthcheckTimeout)
4848
defer cancel()
4949

50-
report, err := api.HealthcheckFunc(ctx, apiKey)
51-
if err == nil {
52-
api.healthCheckCache.Store(report)
53-
}
54-
return report, err
50+
report := api.HealthcheckFunc(ctx, apiKey)
51+
api.healthCheckCache.Store(report)
52+
return report, nil
5553
})
5654

5755
select {

coderd/debug_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ func TestDebugHealth(t *testing.T) {
2424
ctx, cancel = context.WithTimeout(context.Background(), testutil.WaitShort)
2525
sessionToken string
2626
client = coderdtest.New(t, &coderdtest.Options{
27-
HealthcheckFunc: func(_ context.Context, apiKey string) (*healthcheck.Report, error) {
27+
HealthcheckFunc: func(_ context.Context, apiKey string) *healthcheck.Report {
2828
assert.Equal(t, sessionToken, apiKey)
29-
return &healthcheck.Report{}, nil
29+
return &healthcheck.Report{}
3030
},
3131
})
3232
_ = coderdtest.CreateFirstUser(t, client)
@@ -48,15 +48,15 @@ func TestDebugHealth(t *testing.T) {
4848
ctx, cancel = context.WithTimeout(context.Background(), testutil.WaitShort)
4949
client = coderdtest.New(t, &coderdtest.Options{
5050
HealthcheckTimeout: time.Microsecond,
51-
HealthcheckFunc: func(context.Context, string) (*healthcheck.Report, error) {
51+
HealthcheckFunc: func(context.Context, string) *healthcheck.Report {
5252
t := time.NewTimer(time.Second)
5353
defer t.Stop()
5454

5555
select {
5656
case <-ctx.Done():
57-
return nil, ctx.Err()
57+
return &healthcheck.Report{}
5858
case <-t.C:
59-
return &healthcheck.Report{}, nil
59+
return &healthcheck.Report{}
6060
}
6161
},
6262
})
@@ -80,11 +80,11 @@ func TestDebugHealth(t *testing.T) {
8080
client = coderdtest.New(t, &coderdtest.Options{
8181
HealthcheckRefresh: time.Hour,
8282
HealthcheckTimeout: time.Hour,
83-
HealthcheckFunc: func(context.Context, string) (*healthcheck.Report, error) {
83+
HealthcheckFunc: func(context.Context, string) *healthcheck.Report {
8484
calls++
8585
return &healthcheck.Report{
8686
Time: time.Now(),
87-
}, nil
87+
}
8888
},
8989
})
9090
_ = coderdtest.CreateFirstUser(t, client)

coderd/healthcheck/derp.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
)
2626

2727
type DERPReport struct {
28-
mu sync.Mutex
2928
Healthy bool `json:"healthy"`
3029

3130
Regions map[int]*DERPRegionReport `json:"regions"`
@@ -78,6 +77,7 @@ func (r *DERPReport) Run(ctx context.Context, opts *DERPReportOptions) {
7877
r.Regions = map[int]*DERPRegionReport{}
7978

8079
wg := &sync.WaitGroup{}
80+
mu := sync.Mutex{}
8181

8282
wg.Add(len(opts.DERPMap.Regions))
8383
for _, region := range opts.DERPMap.Regions {
@@ -97,19 +97,19 @@ func (r *DERPReport) Run(ctx context.Context, opts *DERPReportOptions) {
9797

9898
regionReport.Run(ctx)
9999

100-
r.mu.Lock()
100+
mu.Lock()
101101
r.Regions[region.RegionID] = &regionReport
102102
if !regionReport.Healthy {
103103
r.Healthy = false
104104
}
105-
r.mu.Unlock()
105+
mu.Unlock()
106106
}()
107107
}
108108

109109
ncLogf := func(format string, args ...interface{}) {
110-
r.mu.Lock()
110+
mu.Lock()
111111
r.NetcheckLogs = append(r.NetcheckLogs, fmt.Sprintf(format, args...))
112-
r.mu.Unlock()
112+
mu.Unlock()
113113
}
114114
nc := &netcheck.Client{
115115
PortMapper: portmapper.NewClient(tslogger.WithPrefix(ncLogf, "portmap: "), nil),

0 commit comments

Comments
 (0)