Skip to content

Commit d6220a0

Browse files
committed
Merge branch 'main' of https://github.com/coder/coder into bq/refactor-groups
2 parents 9bfb06e + ed25f14 commit d6220a0

File tree

118 files changed

+3780
-1321
lines changed

Some content is hidden

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

118 files changed

+3780
-1321
lines changed

.github/actions/upload-datadog/action.yaml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Upload tests to datadog
1+
name: Upload tests to Datadog
22
if: always()
33
inputs:
44
api-key:
@@ -7,8 +7,26 @@ inputs:
77
runs:
88
using: "composite"
99
steps:
10+
- name: Set work dir
11+
shell: bash
12+
run: |
13+
WORK_DIR=${{ runner.temp }}/datadog-ci
14+
mkdir -p $WORK_DIR
15+
echo "WORK_DIR=$WORK_DIR" >> $GITHUB_ENV
16+
# The npm install was taking 30s to 1m, accounting for 20+% of the total
17+
# job time.
18+
- name: Cache datadog-ci
19+
uses: buildjet/cache@v3
20+
with:
21+
path: |
22+
${{ env.WORK_DIR }}
23+
key: datadog-ci-${{ runner.os }}
24+
restore-keys: |
25+
datadog-ci-${{ runner.os }}-
26+
datadog-ci-
1027
- shell: bash
1128
run: |
29+
cd ${{ env.WORK_DIR }}
1230
owner=${{ github.repository_owner }}
1331
echo "owner: $owner"
1432
if [[ $owner != "coder" ]]; then
@@ -20,8 +38,8 @@ runs:
2038
echo "No API key provided, skipping..."
2139
exit 0
2240
fi
23-
npm install -g @datadog/datadog-ci@2.10.0
24-
datadog-ci junit upload --service coder ./gotests.xml \
41+
npm install @datadog/datadog-ci@2.10.0
42+
npm x -- datadog-ci junit upload --service coder ./gotests.xml \
2543
--tags os:${{runner.os}} --tags runner_name:${{runner.name}}
2644
env:
2745
DATADOG_API_KEY: ${{ inputs.api-key }}

.github/dependabot.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ updates:
9292
- dependency-name: "@types/node"
9393
update-types:
9494
- version-update:semver-major
95+
open-pull-requests-limit: 15
9596
groups:
9697
react:
9798
patterns:

.github/workflows/ci.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ jobs:
5353
docs:
5454
- "docs/**"
5555
- "README.md"
56-
- "examples/templates/**"
5756
- "examples/web-server/**"
5857
- "examples/monitoring/**"
5958
- "examples/lima/**"
@@ -741,7 +740,7 @@ jobs:
741740
uses: ./.github/actions/setup-sqlc
742741

743742
- name: GHCR Login
744-
uses: docker/login-action@v2
743+
uses: docker/login-action@v3
745744
with:
746745
registry: ghcr.io
747746
username: ${{ github.actor }}

.github/workflows/contrib.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
steps:
3535
- name: cla
3636
if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target'
37-
uses: contributor-assistant/github-action@v2.3.0
37+
uses: contributor-assistant/github-action@v2.3.1
3838
env:
3939
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4040
# the below token should have repo scope and must be manually added by you in the repository's secret

.github/workflows/docker-base.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
uses: actions/checkout@v4
3636

3737
- name: Docker login
38-
uses: docker/login-action@v2
38+
uses: docker/login-action@v3
3939
with:
4040
registry: ghcr.io
4141
username: ${{ github.actor }}

.github/workflows/dogfood.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
- run: nix build .#devEnvImage && ./result | docker load
4747

4848
- name: Login to DockerHub
49-
uses: docker/login-action@v2
49+
uses: docker/login-action@v3
5050
with:
5151
username: ${{ secrets.DOCKERHUB_USERNAME }}
5252
password: ${{ secrets.DOCKERHUB_PASSWORD }}

.github/workflows/pr-deploy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ jobs:
216216
uses: ./.github/actions/setup-sqlc
217217

218218
- name: GHCR Login
219-
uses: docker/login-action@v2
219+
uses: docker/login-action@v3
220220
with:
221221
registry: ghcr.io
222222
username: ${{ github.actor }}

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ jobs:
8585
cat "$CODER_RELEASE_NOTES_FILE"
8686
8787
- name: Docker Login
88-
uses: docker/login-action@v2
88+
uses: docker/login-action@v3
8989
with:
9090
registry: ghcr.io
9191
username: ${{ github.actor }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,6 @@ scaletest/terraform/secrets.tfvars
6464

6565
# Nix
6666
result
67+
68+
# Data dumps from unit tests
69+
**/*.test.sql

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ scaletest/terraform/secrets.tfvars
6767

6868
# Nix
6969
result
70+
71+
# Data dumps from unit tests
72+
**/*.test.sql
7073
# .prettierignore.include:
7174
# Helm templates contain variables that are invalid YAML and can't be formatted
7275
# by Prettier.

cli/exp_scaletest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ func (r *RootCmd) scaletestCreateWorkspaces() *clibase.Cmd {
857857
Flag: "use-host-login",
858858
Env: "CODER_SCALETEST_USE_HOST_LOGIN",
859859
Default: "false",
860-
Description: "Use the use logged in on the host machine, instead of creating users.",
860+
Description: "Use the user logged in on the host machine, instead of creating users.",
861861
Value: clibase.BoolOf(&useHostUser),
862862
},
863863
}

cli/exp_scaletest_test.go

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import (
77

88
"github.com/stretchr/testify/require"
99

10+
"cdr.dev/slog/sloggers/slogtest"
11+
1012
"github.com/coder/coder/v2/cli/clitest"
1113
"github.com/coder/coder/v2/coderd/coderdtest"
1214
"github.com/coder/coder/v2/pty/ptytest"
@@ -21,7 +23,12 @@ func TestScaleTestCreateWorkspaces(t *testing.T) {
2123
ctx, cancelFunc := context.WithTimeout(context.Background(), testutil.WaitLong)
2224
defer cancelFunc()
2325

24-
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
26+
log := slogtest.Make(t, &slogtest.Options{IgnoreErrors: true})
27+
client := coderdtest.New(t, &coderdtest.Options{
28+
// We are not including any provisioner daemons because we do not actually
29+
// build any workspaces here.
30+
Logger: &log,
31+
})
2532
_ = coderdtest.CreateFirstUser(t, client)
2633

2734
// Write a parameters file.
@@ -59,7 +66,10 @@ func TestScaleTestWorkspaceTraffic(t *testing.T) {
5966
ctx, cancelFunc := context.WithTimeout(context.Background(), testutil.WaitMedium)
6067
defer cancelFunc()
6168

62-
client := coderdtest.New(t, nil)
69+
log := slogtest.Make(t, &slogtest.Options{IgnoreErrors: true})
70+
client := coderdtest.New(t, &coderdtest.Options{
71+
Logger: &log,
72+
})
6373
_ = coderdtest.CreateFirstUser(t, client)
6474

6575
inv, root := clitest.New(t, "exp", "scaletest", "workspace-traffic",
@@ -82,21 +92,20 @@ func TestScaleTestWorkspaceTraffic(t *testing.T) {
8292
// This test just validates that the CLI command accepts its known arguments.
8393
func TestScaleTestDashboard(t *testing.T) {
8494
t.Parallel()
85-
if testutil.RaceEnabled() {
86-
t.Skip("Flakes under race detector, see https://github.com/coder/coder/issues/9168")
87-
}
88-
8995
ctx, cancelFunc := context.WithTimeout(context.Background(), testutil.WaitMedium)
9096
defer cancelFunc()
9197

92-
client := coderdtest.New(t, nil)
98+
log := slogtest.Make(t, &slogtest.Options{IgnoreErrors: true})
99+
client := coderdtest.New(t, &coderdtest.Options{
100+
Logger: &log,
101+
})
93102
_ = coderdtest.CreateFirstUser(t, client)
94103

95104
inv, root := clitest.New(t, "exp", "scaletest", "dashboard",
96105
"--count", "1",
97106
"--min-wait", "100ms",
98107
"--max-wait", "1s",
99-
"--timeout", "1s",
108+
"--timeout", "5s",
100109
"--scaletest-prometheus-address", "127.0.0.1:0",
101110
"--scaletest-prometheus-wait", "0s",
102111
)

cli/testdata/coder_templates_init_--help.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ USAGE:
66
Get started with a templated template.
77

88
OPTIONS:
9-
--id aws-ecs-container|aws-linux|aws-windows|azure-linux|do-linux|docker|docker-with-dotfiles|fly-docker-image|gcp-linux|gcp-vm-container|gcp-windows|kubernetes
9+
--id aws-ecs-container|aws-linux|aws-windows|azure-linux|do-linux|docker|docker-with-dotfiles|gcp-linux|gcp-vm-container|gcp-windows|kubernetes
1010
Specify a given example template by ID.
1111

1212
———

coderd/database/dbauthz/dbauthz.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,15 @@ func (q *querier) ActivityBumpWorkspace(ctx context.Context, arg uuid.UUID) erro
664664
return update(q.log, q.auth, fetch, q.db.ActivityBumpWorkspace)(ctx, arg)
665665
}
666666

667+
func (q *querier) AllUserIDs(ctx context.Context) ([]uuid.UUID, error) {
668+
// Although this technically only reads users, only system-related functions should be
669+
// allowed to call this.
670+
if err := q.authorizeContext(ctx, rbac.ActionRead, rbac.ResourceSystem); err != nil {
671+
return nil, err
672+
}
673+
return q.db.AllUserIDs(ctx)
674+
}
675+
667676
func (q *querier) CleanTailnetCoordinators(ctx context.Context) error {
668677
if err := q.authorizeContext(ctx, rbac.ActionDelete, rbac.ResourceTailnetCoordinator); err != nil {
669678
return err

coderd/database/dbfake/dbfake.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,16 @@ func (q *FakeQuerier) ActivityBumpWorkspace(ctx context.Context, workspaceID uui
812812
return sql.ErrNoRows
813813
}
814814

815+
func (q *FakeQuerier) AllUserIDs(_ context.Context) ([]uuid.UUID, error) {
816+
q.mutex.RLock()
817+
defer q.mutex.RUnlock()
818+
userIDs := make([]uuid.UUID, 0, len(q.users))
819+
for idx := range q.users {
820+
userIDs[idx] = q.users[idx].ID
821+
}
822+
return userIDs, nil
823+
}
824+
815825
func (*FakeQuerier) CleanTailnetCoordinators(_ context.Context) error {
816826
return ErrUnimplemented
817827
}

coderd/database/dbgen/dbgen.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ func User(t testing.TB, db database.Store, orig database.User) database.User {
227227

228228
user, err = db.UpdateUserStatus(genCtx, database.UpdateUserStatusParams{
229229
ID: user.ID,
230-
Status: database.UserStatusActive,
230+
Status: takeFirst(orig.Status, database.UserStatusActive),
231231
UpdatedAt: dbtime.Now(),
232232
})
233233
require.NoError(t, err, "insert user")
@@ -240,6 +240,14 @@ func User(t testing.TB, db database.Store, orig database.User) database.User {
240240
})
241241
require.NoError(t, err, "user last seen")
242242
}
243+
244+
if orig.Deleted {
245+
err = db.UpdateUserDeletedByID(genCtx, database.UpdateUserDeletedByIDParams{
246+
ID: user.ID,
247+
Deleted: orig.Deleted,
248+
})
249+
require.NoError(t, err, "set user as deleted")
250+
}
243251
return user
244252
}
245253

coderd/database/dbmetrics/dbmetrics.go

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

coderd/database/dbmock/dbmock.go

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

0 commit comments

Comments
 (0)