Skip to content

Commit c2424b3

Browse files
committed
Merge branch 'main' into colorful-rebased
2 parents c5e2338 + 9f5a59d commit c2424b3

File tree

404 files changed

+13963
-7660
lines changed

Some content is hidden

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

404 files changed

+13963
-7660
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ runs:
1717
- name: Setup Node
1818
uses: buildjet/setup-node@v3
1919
with:
20-
node-version: 18.17.0
20+
node-version: 18.19.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: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,12 @@ updates:
3838
commit-message:
3939
prefix: "chore"
4040
labels: []
41+
open-pull-requests-limit: 15
4142
ignore:
4243
# Ignore patch updates for all dependencies
4344
- dependency-name: "*"
4445
update-types:
4546
- version-update:semver-patch
46-
groups:
47-
go:
48-
patterns:
49-
- "*"
5047

5148
# Update our Dockerfile.
5249
- package-ecosystem: "docker"

.github/workflows/ci.yaml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,7 @@ jobs:
6060
- "examples/lima/**"
6161
db:
6262
- "**.sql"
63-
- "coderd/database/queries/**"
64-
- "coderd/database/migrations"
65-
- "coderd/database/sqlc.yaml"
66-
- "coderd/database/dump.sql"
63+
- "coderd/database/**"
6764
go:
6865
- "**.sql"
6966
- "**.go"
@@ -144,7 +141,7 @@ jobs:
144141
145142
# Check for any typos
146143
- name: Check for typos
147-
uses: crate-ci/typos@v1.16.25
144+
uses: crate-ci/typos@v1.17.0
148145
with:
149146
config: .github/workflows/typos.toml
150147

@@ -191,7 +188,7 @@ jobs:
191188
go install storj.io/drpc/cmd/protoc-gen-go-drpc@v0.0.33
192189
go install golang.org/x/tools/cmd/goimports@latest
193190
go install github.com/mikefarah/yq/v4@v4.30.6
194-
go install github.com/golang/mock/mockgen@v1.6.0
191+
go install go.uber.org/mock/mockgen@v0.4.0
195192
196193
- name: Install Protoc
197194
run: |
@@ -224,7 +221,7 @@ jobs:
224221
uses: ./.github/actions/setup-node
225222

226223
- name: Setup Go
227-
uses: buildjet/setup-go@v4
224+
uses: buildjet/setup-go@v5
228225
with:
229226
# This doesn't need caching. It's super fast anyways!
230227
cache: false
@@ -324,7 +321,6 @@ jobs:
324321
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
325322
needs:
326323
- changes
327-
- sqlc-vet # No point in testing the DB if the queries are invalid
328324
if: needs.changes.outputs.go == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
329325
# This timeout must be greater than the timeout set by `go test` in
330326
# `make test-postgres` to ensure we receive a trace of running
@@ -454,7 +450,7 @@ jobs:
454450
go install storj.io/drpc/cmd/protoc-gen-go-drpc@v0.0.33
455451
go install golang.org/x/tools/cmd/goimports@latest
456452
go install github.com/mikefarah/yq/v4@v4.30.6
457-
go install github.com/golang/mock/mockgen@v1.6.0
453+
go install go.uber.org/mock/mockgen@v0.4.0
458454
459455
- name: Install Protoc
460456
run: |
@@ -596,7 +592,7 @@ jobs:
596592
go install storj.io/drpc/cmd/protoc-gen-go-drpc@v0.0.33
597593
go install golang.org/x/tools/cmd/goimports@latest
598594
go install github.com/mikefarah/yq/v4@v4.30.6
599-
go install github.com/golang/mock/mockgen@v1.6.0
595+
go install go.uber.org/mock/mockgen@v0.4.0
600596
601597
- name: Setup sqlc
602598
uses: ./.github/actions/setup-sqlc
@@ -685,7 +681,7 @@ jobs:
685681
uses: ./.github/actions/setup-go
686682

687683
- name: Install nfpm
688-
run: go install github.com/goreleaser/nfpm/v2/cmd/nfpm@v2.16.0
684+
run: go install github.com/goreleaser/nfpm/v2/cmd/nfpm@v2.35.1
689685

690686
- name: Install zstd
691687
run: sudo apt-get install -y zstd

.github/workflows/dogfood.yaml

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,15 @@ on:
77
paths:
88
- "dogfood/**"
99
- ".github/workflows/dogfood.yaml"
10-
# Uncomment these lines when testing with CI.
11-
# pull_request:
12-
# paths:
13-
# - "dogfood/**"
14-
# - ".github/workflows/dogfood.yaml"
10+
pull_request:
11+
paths:
12+
- "dogfood/**"
13+
- ".github/workflows/dogfood.yaml"
1514
workflow_dispatch:
1615

1716
jobs:
18-
deploy_image:
19-
runs-on: buildjet-4vcpu-ubuntu-2204
17+
build_image:
18+
runs-on: ubuntu-latest
2019
steps:
2120
- name: Checkout
2221
uses: actions/checkout@v4
@@ -33,27 +32,29 @@ jobs:
3332
tag=${tag//\//--}
3433
echo "tag=${tag}" >> $GITHUB_OUTPUT
3534
36-
- name: Set up Docker Buildx
37-
uses: docker/setup-buildx-action@v3
35+
- name: Set up Depot CLI
36+
uses: depot/setup-action@v1
3837

3938
- name: Login to DockerHub
39+
if: github.ref == 'refs/heads/main'
4040
uses: docker/login-action@v3
4141
with:
4242
username: ${{ secrets.DOCKERHUB_USERNAME }}
4343
password: ${{ secrets.DOCKERHUB_PASSWORD }}
4444

4545
- name: Build and push
46-
uses: docker/build-push-action@v5
46+
uses: depot/build-push-action@v1
4747
with:
48+
project: b4q6ltmpzh
49+
token: ${{ secrets.DEPOT_TOKEN }}
4850
context: "{{defaultContext}}:dogfood"
4951
pull: true
50-
push: true
52+
push: ${{ github.ref == 'refs/heads/main' }}
5153
tags: "codercom/oss-dogfood:${{ steps.docker-tag-name.outputs.tag }},codercom/oss-dogfood:latest"
52-
cache-from: type=registry,ref=codercom/oss-dogfood:latest
53-
cache-to: type=inline
5454

5555
deploy_template:
56-
needs: deploy_image
56+
needs: build_image
57+
if: github.ref == 'refs/heads/main'
5758
runs-on: ubuntu-latest
5859
steps:
5960
- name: Checkout
@@ -74,7 +75,7 @@ jobs:
7475
7576
- name: "Push template"
7677
run: |
77-
./coder templates push $CODER_TEMPLATE_NAME --directory $CODER_TEMPLATE_DIR --yes --name=$CODER_TEMPLATE_VERSION --message="$CODER_TEMPLATE_MESSAGE"
78+
./coder templates push $CODER_TEMPLATE_NAME --directory $CODER_TEMPLATE_DIR --yes --name=$CODER_TEMPLATE_VERSION --message="$CODER_TEMPLATE_MESSAGE" --variable jfrog_url=${{ secrets.JFROG_URL }}
7879
env:
7980
# Consumed by Coder CLI
8081
CODER_URL: https://dev.coder.com

.github/workflows/pr-deploy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ jobs:
416416
417417
# Create template
418418
cd ./.github/pr-deployments/template
419-
coder templates create -y --variable namespace=pr${{ env.PR_NUMBER }} kubernetes
419+
coder templates push -y --variable namespace=pr${{ env.PR_NUMBER }} kubernetes
420420
421421
# Create workspace
422422
coder create --template="kubernetes" kube --parameter cpu=2 --parameter memory=4 --parameter home_disk_size=2 -y

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ jobs:
103103
- name: Install nfpm
104104
run: |
105105
set -euo pipefail
106-
wget -O /tmp/nfpm.deb https://github.com/goreleaser/nfpm/releases/download/v2.18.1/nfpm_amd64.deb
106+
wget -O /tmp/nfpm.deb https://github.com/goreleaser/nfpm/releases/download/v2.35.1/nfpm_2.35.1_amd64.deb
107107
sudo dpkg -i /tmp/nfpm.deb
108108
rm /tmp/nfpm.deb
109109

.github/workflows/security.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ jobs:
7575
- name: Install yq
7676
run: go run github.com/mikefarah/yq/v4@v4.30.6
7777
- name: Install mockgen
78-
run: go install github.com/golang/mock/mockgen@v1.6.0
78+
run: go install go.uber.org/mock/mockgen@v0.4.0
7979
- name: Install protoc-gen-go
8080
run: go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.30
8181
- name: Install protoc-gen-go-drpc
@@ -122,7 +122,7 @@ jobs:
122122
image_name: ${{ steps.build.outputs.image }}
123123

124124
- name: Run Trivy vulnerability scanner
125-
uses: aquasecurity/trivy-action@91713af97dc80187565512baba96e4364e983601
125+
uses: aquasecurity/trivy-action@d43c1f16c00cfd3978dde6c07f4bbcf9eb6993ca
126126
with:
127127
image-ref: ${{ steps.build.outputs.image }}
128128
format: sarif

.github/workflows/stale.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
repo: context.repo.repo,
6969
issue_number: issue.number,
7070
state: 'closed',
71-
state_reason: 'not planned'
71+
state_reason: 'not_planned'
7272
});
7373
}
7474
} else {

.vscode/settings.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
"contravariance",
2222
"cronstrue",
2323
"databasefake",
24-
"dbmem",
2524
"dbgen",
25+
"dbmem",
2626
"dbtype",
2727
"DERP",
2828
"derphttp",
@@ -60,6 +60,7 @@
6060
"idtoken",
6161
"Iflag",
6262
"incpatch",
63+
"initialisms",
6364
"ipnstate",
6465
"isatty",
6566
"Jobf",
@@ -118,13 +119,13 @@
118119
"stretchr",
119120
"STTY",
120121
"stuntest",
121-
"tanstack",
122122
"tailbroker",
123123
"tailcfg",
124124
"tailexchange",
125125
"tailnet",
126126
"tailnettest",
127127
"Tailscale",
128+
"tanstack",
128129
"tbody",
129130
"TCGETS",
130131
"tcpip",
@@ -141,6 +142,7 @@
141142
"tios",
142143
"tmpdir",
143144
"tokenconfig",
145+
"Topbar",
144146
"tparallel",
145147
"trialer",
146148
"trimprefix",

agent/agent.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,6 +1188,7 @@ func (a *agent) handleReconnectingPTY(ctx context.Context, logger slog.Logger, m
11881188
// startReportingConnectionStats runs the connection stats reporting goroutine.
11891189
func (a *agent) startReportingConnectionStats(ctx context.Context) {
11901190
reportStats := func(networkStats map[netlogtype.Connection]netlogtype.Counts) {
1191+
a.logger.Debug(ctx, "computing stats report")
11911192
stats := &agentsdk.Stats{
11921193
ConnectionCount: int64(len(networkStats)),
11931194
ConnectionsByProto: map[string]int64{},
@@ -1209,6 +1210,7 @@ func (a *agent) startReportingConnectionStats(ctx context.Context) {
12091210
stats.SessionCountReconnectingPTY = a.connCountReconnectingPTY.Load()
12101211

12111212
// Compute the median connection latency!
1213+
a.logger.Debug(ctx, "starting peer latency measurement for stats")
12121214
var wg sync.WaitGroup
12131215
var mu sync.Mutex
12141216
status := a.network.Status()
@@ -1257,13 +1259,17 @@ func (a *agent) startReportingConnectionStats(ctx context.Context) {
12571259

12581260
metricsCtx, cancelFunc := context.WithTimeout(ctx, 5*time.Second)
12591261
defer cancelFunc()
1262+
a.logger.Debug(ctx, "collecting agent metrics for stats")
12601263
stats.Metrics = a.collectMetrics(metricsCtx)
12611264

12621265
a.latestStat.Store(stats)
12631266

1267+
a.logger.Debug(ctx, "about to send stats")
12641268
select {
12651269
case a.connStatsChan <- stats:
1270+
a.logger.Debug(ctx, "successfully sent stats")
12661271
case <-a.closed:
1272+
a.logger.Debug(ctx, "didn't send stats because we are closed")
12671273
}
12681274
}
12691275

agent/agent_test.go

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import (
2727
"time"
2828

2929
"github.com/bramvdbogaerde/go-scp"
30-
"github.com/golang/mock/gomock"
3130
"github.com/google/uuid"
3231
"github.com/pion/udp"
3332
"github.com/pkg/sftp"
@@ -37,6 +36,7 @@ import (
3736
"github.com/stretchr/testify/assert"
3837
"github.com/stretchr/testify/require"
3938
"go.uber.org/goleak"
39+
"go.uber.org/mock/gomock"
4040
"golang.org/x/crypto/ssh"
4141
"golang.org/x/exp/slices"
4242
"golang.org/x/xerrors"
@@ -174,10 +174,10 @@ func TestAgent_Stats_Magic(t *testing.T) {
174174
require.NoError(t, err)
175175
err = session.Shell()
176176
require.NoError(t, err)
177-
var s *agentsdk.Stats
178177
require.Eventuallyf(t, func() bool {
179-
var ok bool
180-
s, ok = <-stats
178+
s, ok := <-stats
179+
t.Logf("got stats: ok=%t, ConnectionCount=%d, RxBytes=%d, TxBytes=%d, SessionCountVSCode=%d, ConnectionMedianLatencyMS=%f",
180+
ok, s.ConnectionCount, s.RxBytes, s.TxBytes, s.SessionCountVSCode, s.ConnectionMedianLatencyMS)
181181
return ok && s.ConnectionCount > 0 && s.RxBytes > 0 && s.TxBytes > 0 &&
182182
// Ensure that the connection didn't count as a "normal" SSH session.
183183
// This was a special one, so it should be labeled specially in the stats!
@@ -186,7 +186,7 @@ func TestAgent_Stats_Magic(t *testing.T) {
186186
// If it isn't, it's set to -1.
187187
s.ConnectionMedianLatencyMS >= 0
188188
}, testutil.WaitLong, testutil.IntervalFast,
189-
"never saw stats: %+v", s,
189+
"never saw stats",
190190
)
191191
// The shell will automatically exit if there is no stdin!
192192
_ = stdin.Close()
@@ -240,14 +240,14 @@ func TestAgent_Stats_Magic(t *testing.T) {
240240
_ = tunneledConn.Close()
241241
})
242242

243-
var s *agentsdk.Stats
244243
require.Eventuallyf(t, func() bool {
245-
var ok bool
246-
s, ok = <-stats
244+
s, ok := <-stats
245+
t.Logf("got stats with conn open: ok=%t, ConnectionCount=%d, SessionCountJetBrains=%d",
246+
ok, s.ConnectionCount, s.SessionCountJetBrains)
247247
return ok && s.ConnectionCount > 0 &&
248248
s.SessionCountJetBrains == 1
249249
}, testutil.WaitLong, testutil.IntervalFast,
250-
"never saw stats with conn open: %+v", s,
250+
"never saw stats with conn open",
251251
)
252252

253253
// Kill the server and connection after checking for the echo.
@@ -256,12 +256,13 @@ func TestAgent_Stats_Magic(t *testing.T) {
256256
_ = tunneledConn.Close()
257257

258258
require.Eventuallyf(t, func() bool {
259-
var ok bool
260-
s, ok = <-stats
261-
return ok && s.ConnectionCount == 0 &&
259+
s, ok := <-stats
260+
t.Logf("got stats after disconnect %t, %d",
261+
ok, s.SessionCountJetBrains)
262+
return ok &&
262263
s.SessionCountJetBrains == 0
263264
}, testutil.WaitLong, testutil.IntervalFast,
264-
"never saw stats after conn closes: %+v", s,
265+
"never saw stats after conn closes",
265266
)
266267
})
267268
}
@@ -925,7 +926,7 @@ func TestAgent_EnvironmentVariableExpansion(t *testing.T) {
925926
func TestAgent_CoderEnvVars(t *testing.T) {
926927
t.Parallel()
927928

928-
for _, key := range []string{"CODER"} {
929+
for _, key := range []string{"CODER", "CODER_WORKSPACE_NAME", "CODER_WORKSPACE_AGENT_NAME"} {
929930
key := key
930931
t.Run(key, func(t *testing.T) {
931932
t.Parallel()
@@ -2014,6 +2015,12 @@ func setupAgent(t *testing.T, metadata agentsdk.Manifest, ptyTimeout time.Durati
20142015
if metadata.AgentID == uuid.Nil {
20152016
metadata.AgentID = uuid.New()
20162017
}
2018+
if metadata.AgentName == "" {
2019+
metadata.AgentName = "test-agent"
2020+
}
2021+
if metadata.WorkspaceName == "" {
2022+
metadata.WorkspaceName = "test-workspace"
2023+
}
20172024
coordinator := tailnet.NewCoordinator(logger)
20182025
t.Cleanup(func() {
20192026
_ = coordinator.Close()

0 commit comments

Comments
 (0)