Skip to content

Commit fb6fb0f

Browse files
authored
Merge branch 'coder:main' into fix-kubernetes-template-example-labels
2 parents bf1ea39 + 2c13797 commit fb6fb0f

File tree

352 files changed

+22341
-12073
lines changed

Some content is hidden

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

352 files changed

+22341
-12073
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ runs:
1313
- name: Install pnpm
1414
uses: pnpm/action-setup@v3
1515
with:
16-
version: 8
16+
version: 9.6
1717
- name: Setup Node
18-
uses: actions/setup-node@v4.0.1
18+
uses: actions/setup-node@v4.0.3
1919
with:
20-
node-version: 18.19.0
20+
node-version: 20.16.0
2121
# See https://github.com/actions/setup-node#caching-global-packages-data
2222
cache: "pnpm"
2323
cache-dependency-path: ${{ inputs.directory }}/pnpm-lock.yaml

.github/dependabot.yaml

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -86,37 +86,30 @@ updates:
8686
- "@mui*"
8787
react:
8888
patterns:
89-
- "react*"
90-
- "@types/react*"
89+
- "react"
90+
- "react-dom"
91+
- "@types/react"
92+
- "@types/react-dom"
9193
emotion:
9294
patterns:
9395
- "@emotion*"
96+
exclude-patterns:
97+
- "jest-runner-eslint"
9498
eslint:
9599
patterns:
96100
- "eslint*"
97101
- "@typescript-eslint*"
98102
jest:
99103
patterns:
100-
- "jest*"
104+
- "jest"
101105
- "@types/jest"
102106
vite:
103107
patterns:
104108
- "vite*"
105109
- "@vitejs/plugin-react"
106110
ignore:
107-
# Ignore patch updates for all dependencies
111+
# Ignore major version updates to avoid breaking changes
108112
- dependency-name: "*"
109-
update-types:
110-
- version-update:semver-patch
111-
# Ignore major updates to Node.js types, because they need to
112-
# correspond to the Node.js engine version
113-
- dependency-name: "@types/node"
114113
update-types:
115114
- version-update:semver-major
116-
# Ignore @storybook updates, run `pnpm dlx storybook@latest upgrade` to upgrade manually
117-
- dependency-name: "*storybook*" # matches @storybook/* and storybook*
118-
update-types:
119-
- version-update:semver-major
120-
- version-update:semver-minor
121-
- version-update:semver-patch
122115
open-pull-requests-limit: 15

.github/workflows/ci.yaml

Lines changed: 15 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,28 @@ jobs:
126126
uses: actions/checkout@v4
127127
with:
128128
fetch-depth: 1
129+
# See: https://github.com/stefanzweifel/git-auto-commit-action?tab=readme-ov-file#commits-made-by-this-action-do-not-trigger-new-workflow-runs
130+
token: ${{ secrets.CDRCI_GITHUB_TOKEN }}
129131

130132
- name: Setup Go
131133
uses: ./.github/actions/setup-go
132134

133135
- name: Update Nix Flake SRI Hash
134136
run: ./scripts/update-flake.sh
135137

138+
# auto update flake for dependabot
139+
- uses: stefanzweifel/git-auto-commit-action@v5
140+
if: github.actor == 'dependabot[bot]'
141+
with:
142+
# Allows dependabot to still rebase!
143+
commit_message: "[dependabot skip] Update Nix Flake SRI Hash"
144+
commit_user_name: "dependabot[bot]"
145+
commit_user_email: "49699333+dependabot[bot]@users.noreply.github.com>"
146+
commit_author: "dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>"
147+
148+
# require everyone else to update it themselves
136149
- name: Ensure No Changes
150+
if: github.actor != 'dependabot[bot]'
137151
run: git diff --exit-code
138152

139153
lint:
@@ -170,7 +184,7 @@ jobs:
170184
171185
# Check for any typos
172186
- name: Check for typos
173-
uses: crate-ci/typos@v1.23.2
187+
uses: crate-ci/typos@v1.23.6
174188
with:
175189
config: .github/workflows/typos.toml
176190

@@ -695,7 +709,6 @@ jobs:
695709
- test-e2e
696710
- offlinedocs
697711
- sqlc-vet
698-
- dependency-license-review
699712
# Allow this job to run even if the needed jobs fail, are skipped or
700713
# cancelled.
701714
if: always()
@@ -712,7 +725,6 @@ jobs:
712725
echo "- test-js: ${{ needs.test-js.result }}"
713726
echo "- test-e2e: ${{ needs.test-e2e.result }}"
714727
echo "- offlinedocs: ${{ needs.offlinedocs.result }}"
715-
echo "- dependency-license-review: ${{ needs.dependency-license-review.result }}"
716728
echo
717729
718730
# We allow skipped jobs to pass, but not failed or cancelled jobs.
@@ -954,63 +966,3 @@ jobs:
954966
- name: Setup and run sqlc vet
955967
run: |
956968
make sqlc-vet
957-
958-
# dependency-license-review checks that no license-incompatible dependencies have been introduced.
959-
# This action is not intended to do a vulnerability check since that is handled by a separate action.
960-
dependency-license-review:
961-
runs-on: ubuntu-latest
962-
if: github.ref != 'refs/heads/main' && github.actor != 'dependabot[bot]'
963-
steps:
964-
- name: "Checkout Repository"
965-
uses: actions/checkout@v4
966-
- name: "Dependency Review"
967-
id: review
968-
uses: actions/dependency-review-action@v4.3.2
969-
with:
970-
allow-licenses: Apache-2.0, 0BSD, BSD-2-Clause, BSD-3-Clause, CC0-1.0, ISC, MIT, MIT-0, MPL-2.0
971-
allow-dependencies-licenses: "pkg:golang/github.com/coder/wgtunnel@0.1.13-0.20240522110300-ade90dfb2da0, pkg:npm/pako@1.0.11, pkg:npm/caniuse-lite@1.0.30001639, pkg:githubactions/alwaysmeticulous/report-diffs-action/cloud-compute"
972-
license-check: true
973-
vulnerability-check: false
974-
- name: "Report"
975-
# make sure this step runs even if the previous failed
976-
if: always()
977-
shell: bash
978-
env:
979-
VULNERABLE_CHANGES: ${{ steps.review.outputs.invalid-license-changes }}
980-
run: |
981-
fields=( "unlicensed" "unresolved" "forbidden" )
982-
983-
# This is unfortunate that we have to do this but the action does not support failing on
984-
# an unknown license. The unknown dependency could easily have a GPL license which
985-
# would be problematic for us.
986-
# Track https://github.com/actions/dependency-review-action/issues/672 for when
987-
# we can remove this brittle workaround.
988-
for field in "${fields[@]}"; do
989-
# Use jq to check if the array is not empty
990-
if [[ $(echo "$VULNERABLE_CHANGES" | jq ".${field} | length") -ne 0 ]]; then
991-
echo "Invalid or unknown licenses detected, contact @sreya to ensure your added dependency falls under one of our allowed licenses."
992-
echo "$VULNERABLE_CHANGES" | jq
993-
exit 1
994-
fi
995-
done
996-
echo "No incompatible licenses detected"
997-
meticulous:
998-
runs-on: ubuntu-latest
999-
steps:
1000-
- name: "Checkout Repository"
1001-
uses: actions/checkout@v4
1002-
- name: Setup Node
1003-
uses: ./.github/actions/setup-node
1004-
- name: Build
1005-
working-directory: ./site
1006-
run: pnpm build
1007-
- name: Serve
1008-
working-directory: ./site
1009-
run: |
1010-
pnpm vite preview &
1011-
sleep 5
1012-
- name: Run Meticulous tests
1013-
uses: alwaysmeticulous/report-diffs-action/cloud-compute@v1
1014-
with:
1015-
api-token: ${{ secrets.METICULOUS_API_TOKEN }}
1016-
app-url: "http://127.0.0.1:4173/"

.github/workflows/dogfood.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ on:
1919

2020
jobs:
2121
build_image:
22+
if: github.actor != 'dependabot[bot]' # Skip Dependabot PRs
2223
runs-on: ubuntu-latest
2324
steps:
2425
- name: Checkout

.github/workflows/meticulous.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Workflow for serving the webapp locally & running Meticulous tests against it.
2+
3+
name: Meticulous
4+
5+
on:
6+
push:
7+
branches:
8+
- main
9+
paths:
10+
- "site/**"
11+
pull_request:
12+
paths:
13+
- "site/**"
14+
# Meticulous needs the workflow to be triggered on workflow_dispatch events,
15+
# so that Meticulous can run the workflow on the base commit to compare
16+
# against if an existing workflow hasn't run.
17+
workflow_dispatch:
18+
19+
permissions:
20+
actions: write
21+
contents: read
22+
issues: write
23+
pull-requests: write
24+
statuses: read
25+
26+
jobs:
27+
meticulous:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: "Checkout Repository"
31+
uses: actions/checkout@v4
32+
- name: Setup Node
33+
uses: ./.github/actions/setup-node
34+
- name: Build
35+
working-directory: ./site
36+
run: pnpm build
37+
- name: Serve
38+
working-directory: ./site
39+
run: |
40+
pnpm vite preview &
41+
sleep 5
42+
- name: Run Meticulous tests
43+
uses: alwaysmeticulous/report-diffs-action/cloud-compute@v1
44+
with:
45+
api-token: ${{ secrets.METICULOUS_API_TOKEN }}
46+
app-url: "http://127.0.0.1:4173/"

agent/agent.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,10 +588,12 @@ func (a *agent) reportMetadata(ctx context.Context, conn drpc.Conn) error {
588588
updatedMetadata[mr.key] = mr.result
589589
continue
590590
case err := <-reportError:
591-
a.logger.Debug(ctx, "batch update metadata complete", slog.Error(err))
591+
logMsg := "batch update metadata complete"
592592
if err != nil {
593+
a.logger.Debug(ctx, logMsg, slog.Error(err))
593594
return xerrors.Errorf("failed to report metadata: %w", err)
594595
}
596+
a.logger.Debug(ctx, logMsg)
595597
reportInFlight = false
596598
case <-report:
597599
if len(updatedMetadata) == 0 {

cli/autoupdate_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func TestAutoUpdate(t *testing.T) {
2424
version := coderdtest.CreateTemplateVersion(t, client, owner.OrganizationID, nil)
2525
coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
2626
template := coderdtest.CreateTemplate(t, client, owner.OrganizationID, version.ID)
27-
workspace := coderdtest.CreateWorkspace(t, member, owner.OrganizationID, template.ID)
27+
workspace := coderdtest.CreateWorkspace(t, member, template.ID)
2828
coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, workspace.LatestBuild.ID)
2929
require.Equal(t, codersdk.AutomaticUpdatesNever, workspace.AutomaticUpdates)
3030

cli/clitest/golden.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ func prepareTestData(t *testing.T) (*codersdk.Client, map[string]string) {
195195
template := coderdtest.CreateTemplate(t, rootClient, firstUser.OrganizationID, version.ID, func(req *codersdk.CreateTemplateRequest) {
196196
req.Name = "test-template"
197197
})
198-
workspace := coderdtest.CreateWorkspace(t, rootClient, firstUser.OrganizationID, template.ID, func(req *codersdk.CreateWorkspaceRequest) {
198+
workspace := coderdtest.CreateWorkspace(t, rootClient, template.ID, func(req *codersdk.CreateWorkspaceRequest) {
199199
req.Name = "test-workspace"
200200
})
201201
workspaceBuild := coderdtest.AwaitWorkspaceBuildJobCompleted(t, rootClient, workspace.LatestBuild.ID)

cli/delete_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func TestDelete(t *testing.T) {
2727
version := coderdtest.CreateTemplateVersion(t, client, owner.OrganizationID, nil)
2828
coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
2929
template := coderdtest.CreateTemplate(t, client, owner.OrganizationID, version.ID)
30-
workspace := coderdtest.CreateWorkspace(t, member, owner.OrganizationID, template.ID)
30+
workspace := coderdtest.CreateWorkspace(t, member, template.ID)
3131
coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, workspace.LatestBuild.ID)
3232
inv, root := clitest.New(t, "delete", workspace.Name, "-y")
3333
clitest.SetupConfig(t, member, root)
@@ -52,7 +52,7 @@ func TestDelete(t *testing.T) {
5252
version := coderdtest.CreateTemplateVersion(t, client, owner.OrganizationID, nil)
5353
coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
5454
template := coderdtest.CreateTemplate(t, client, owner.OrganizationID, version.ID)
55-
workspace := coderdtest.CreateWorkspace(t, client, owner.OrganizationID, template.ID)
55+
workspace := coderdtest.CreateWorkspace(t, client, template.ID)
5656
coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, workspace.LatestBuild.ID)
5757
inv, root := clitest.New(t, "delete", workspace.Name, "-y", "--orphan")
5858

@@ -86,8 +86,7 @@ func TestDelete(t *testing.T) {
8686
version := coderdtest.CreateTemplateVersion(t, client, owner.OrganizationID, nil)
8787
coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
8888
template := coderdtest.CreateTemplate(t, client, owner.OrganizationID, version.ID)
89-
90-
workspace := coderdtest.CreateWorkspace(t, deleteMeClient, owner.OrganizationID, template.ID)
89+
workspace := coderdtest.CreateWorkspace(t, deleteMeClient, template.ID)
9190
coderdtest.AwaitWorkspaceBuildJobCompleted(t, deleteMeClient, workspace.LatestBuild.ID)
9291

9392
// The API checks if the user has any workspaces, so we cannot delete a user
@@ -128,7 +127,7 @@ func TestDelete(t *testing.T) {
128127
version := coderdtest.CreateTemplateVersion(t, adminClient, orgID, nil)
129128
coderdtest.AwaitTemplateVersionJobCompleted(t, adminClient, version.ID)
130129
template := coderdtest.CreateTemplate(t, adminClient, orgID, version.ID)
131-
workspace := coderdtest.CreateWorkspace(t, client, orgID, template.ID)
130+
workspace := coderdtest.CreateWorkspace(t, client, template.ID)
132131
coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, workspace.LatestBuild.ID)
133132

134133
inv, root := clitest.New(t, "delete", user.Username+"/"+workspace.Name, "-y")

cli/notifications_test.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ import (
1616
"github.com/coder/coder/v2/testutil"
1717
)
1818

19+
func createOpts(t *testing.T) *coderdtest.Options {
20+
t.Helper()
21+
22+
dt := coderdtest.DeploymentValues(t)
23+
dt.Experiments = []string{string(codersdk.ExperimentNotifications)}
24+
return &coderdtest.Options{
25+
DeploymentValues: dt,
26+
}
27+
}
28+
1929
func TestNotifications(t *testing.T) {
2030
t.Parallel()
2131

@@ -42,7 +52,7 @@ func TestNotifications(t *testing.T) {
4252
t.Parallel()
4353

4454
// given
45-
ownerClient, db := coderdtest.NewWithDatabase(t, nil)
55+
ownerClient, db := coderdtest.NewWithDatabase(t, createOpts(t))
4656
_ = coderdtest.CreateFirstUser(t, ownerClient)
4757

4858
// when
@@ -72,7 +82,7 @@ func TestPauseNotifications_RegularUser(t *testing.T) {
7282
t.Parallel()
7383

7484
// given
75-
ownerClient, db := coderdtest.NewWithDatabase(t, nil)
85+
ownerClient, db := coderdtest.NewWithDatabase(t, createOpts(t))
7686
owner := coderdtest.CreateFirstUser(t, ownerClient)
7787
anotherClient, _ := coderdtest.CreateAnotherUser(t, ownerClient, owner.OrganizationID)
7888

@@ -87,7 +97,7 @@ func TestPauseNotifications_RegularUser(t *testing.T) {
8797
require.Error(t, err)
8898
require.ErrorAsf(t, err, &sdkError, "error should be of type *codersdk.Error")
8999
assert.Equal(t, http.StatusForbidden, sdkError.StatusCode())
90-
assert.Contains(t, sdkError.Message, "Insufficient permissions to update notifications settings.")
100+
assert.Contains(t, sdkError.Message, "Forbidden.")
91101

92102
// then
93103
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)

cli/organizationmembers_test.go

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -34,49 +34,3 @@ func TestListOrganizationMembers(t *testing.T) {
3434
require.Contains(t, buf.String(), owner.UserID.String())
3535
})
3636
}
37-
38-
func TestRemoveOrganizationMembers(t *testing.T) {
39-
t.Parallel()
40-
41-
t.Run("OK", func(t *testing.T) {
42-
t.Parallel()
43-
44-
ownerClient := coderdtest.New(t, &coderdtest.Options{})
45-
owner := coderdtest.CreateFirstUser(t, ownerClient)
46-
orgAdminClient, _ := coderdtest.CreateAnotherUser(t, ownerClient, owner.OrganizationID, rbac.ScopedRoleOrgAdmin(owner.OrganizationID))
47-
_, user := coderdtest.CreateAnotherUser(t, ownerClient, owner.OrganizationID)
48-
49-
ctx := testutil.Context(t, testutil.WaitMedium)
50-
51-
inv, root := clitest.New(t, "organization", "members", "remove", "-O", owner.OrganizationID.String(), user.Username)
52-
clitest.SetupConfig(t, orgAdminClient, root)
53-
54-
buf := new(bytes.Buffer)
55-
inv.Stdout = buf
56-
err := inv.WithContext(ctx).Run()
57-
require.NoError(t, err)
58-
59-
members, err := orgAdminClient.OrganizationMembers(ctx, owner.OrganizationID)
60-
require.NoError(t, err)
61-
62-
require.Len(t, members, 2)
63-
})
64-
65-
t.Run("UserNotExists", func(t *testing.T) {
66-
t.Parallel()
67-
68-
ownerClient := coderdtest.New(t, &coderdtest.Options{})
69-
owner := coderdtest.CreateFirstUser(t, ownerClient)
70-
orgAdminClient, _ := coderdtest.CreateAnotherUser(t, ownerClient, owner.OrganizationID, rbac.ScopedRoleOrgAdmin(owner.OrganizationID))
71-
72-
ctx := testutil.Context(t, testutil.WaitMedium)
73-
74-
inv, root := clitest.New(t, "organization", "members", "remove", "-O", owner.OrganizationID.String(), "random_name")
75-
clitest.SetupConfig(t, orgAdminClient, root)
76-
77-
buf := new(bytes.Buffer)
78-
inv.Stdout = buf
79-
err := inv.WithContext(ctx).Run()
80-
require.ErrorContains(t, err, "must be an existing uuid or username")
81-
})
82-
}

0 commit comments

Comments
 (0)