Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 30283f0

Browse files
committed
Merge branch 'main' into mes/use-time-2
2 parents 93f85c4 + 9fe5b71 commit 30283f0

File tree

397 files changed

+11352
-4469
lines changed

Some content is hidden

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

397 files changed

+11352
-4469
lines changed

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

+27-2
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,42 @@ inputs:
55
version:
66
description: "The Go version to use."
77
default: "1.24.2"
8+
use-preinstalled-go:
9+
description: "Whether to use preinstalled Go."
10+
default: "false"
11+
use-temp-cache-dirs:
12+
description: "Whether to use temporary GOCACHE and GOMODCACHE directories."
13+
default: "false"
814
runs:
915
using: "composite"
1016
steps:
17+
- name: Override GOCACHE and GOMODCACHE
18+
shell: bash
19+
if: inputs.use-temp-cache-dirs == 'true'
20+
run: |
21+
# cd to another directory to ensure we're not inside a Go project.
22+
# That'd trigger Go to download the toolchain for that project.
23+
cd "$RUNNER_TEMP"
24+
# RUNNER_TEMP should be backed by a RAM disk on Windows if
25+
# coder/setup-ramdisk-action was used
26+
export GOCACHE_DIR="$RUNNER_TEMP""\go-cache"
27+
export GOMODCACHE_DIR="$RUNNER_TEMP""\go-mod-cache"
28+
export GOPATH_DIR="$RUNNER_TEMP""\go-path"
29+
mkdir -p "$GOCACHE_DIR"
30+
mkdir -p "$GOMODCACHE_DIR"
31+
mkdir -p "$GOPATH_DIR"
32+
go env -w GOCACHE="$GOCACHE_DIR"
33+
go env -w GOMODCACHE="$GOMODCACHE_DIR"
34+
go env -w GOPATH="$GOPATH_DIR"
35+
1136
- name: Setup Go
1237
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
1338
with:
14-
go-version: ${{ inputs.version }}
39+
go-version: ${{ inputs.use-preinstalled-go == 'false' && inputs.version || '' }}
1540

1641
- name: Install gotestsum
1742
shell: bash
18-
run: go install gotest.tools/gotestsum@latest
43+
run: go install gotest.tools/gotestsum@3f7ff0ec4aeb6f95f5d67c998b71f272aa8a8b41 # v1.12.1
1944

2045
# It isn't necessary that we ever do this, but it helps
2146
# separate the "setup" from the "run" times.

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

+41-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ runs:
1010
steps:
1111
- shell: bash
1212
run: |
13+
set -e
14+
1315
owner=${{ github.repository_owner }}
1416
echo "owner: $owner"
1517
if [[ $owner != "coder" ]]; then
@@ -21,8 +23,45 @@ runs:
2123
echo "No API key provided, skipping..."
2224
exit 0
2325
fi
24-
npm install -g @datadog/[email protected]
25-
datadog-ci junit upload --service coder ./gotests.xml \
26+
27+
BINARY_VERSION="v2.48.0"
28+
BINARY_HASH_WINDOWS="b7bebb8212403fddb1563bae84ce5e69a70dac11e35eb07a00c9ef7ac9ed65ea"
29+
BINARY_HASH_MACOS="e87c808638fddb21a87a5c4584b68ba802965eb0a593d43959c81f67246bd9eb"
30+
BINARY_HASH_LINUX="5e700c465728fff8313e77c2d5ba1ce19a736168735137e1ddc7c6346ed48208"
31+
32+
TMP_DIR=$(mktemp -d)
33+
34+
if [[ "${{ runner.os }}" == "Windows" ]]; then
35+
BINARY_PATH="${TMP_DIR}/datadog-ci.exe"
36+
BINARY_URL="https://github.com/DataDog/datadog-ci/releases/download/${BINARY_VERSION}/datadog-ci_win-x64"
37+
elif [[ "${{ runner.os }}" == "macOS" ]]; then
38+
BINARY_PATH="${TMP_DIR}/datadog-ci"
39+
BINARY_URL="https://github.com/DataDog/datadog-ci/releases/download/${BINARY_VERSION}/datadog-ci_darwin-arm64"
40+
elif [[ "${{ runner.os }}" == "Linux" ]]; then
41+
BINARY_PATH="${TMP_DIR}/datadog-ci"
42+
BINARY_URL="https://github.com/DataDog/datadog-ci/releases/download/${BINARY_VERSION}/datadog-ci_linux-x64"
43+
else
44+
echo "Unsupported OS: ${{ runner.os }}"
45+
exit 1
46+
fi
47+
48+
echo "Downloading DataDog CI binary version ${BINARY_VERSION} for ${{ runner.os }}..."
49+
curl -sSL "$BINARY_URL" -o "$BINARY_PATH"
50+
51+
if [[ "${{ runner.os }}" == "Windows" ]]; then
52+
echo "$BINARY_HASH_WINDOWS $BINARY_PATH" | sha256sum --check
53+
elif [[ "${{ runner.os }}" == "macOS" ]]; then
54+
echo "$BINARY_HASH_MACOS $BINARY_PATH" | shasum -a 256 --check
55+
elif [[ "${{ runner.os }}" == "Linux" ]]; then
56+
echo "$BINARY_HASH_LINUX $BINARY_PATH" | sha256sum --check
57+
fi
58+
59+
# Make binary executable (not needed for Windows)
60+
if [[ "${{ runner.os }}" != "Windows" ]]; then
61+
chmod +x "$BINARY_PATH"
62+
fi
63+
64+
"$BINARY_PATH" junit upload --service coder ./gotests.xml \
2665
--tags os:${{runner.os}} --tags runner_name:${{runner.name}}
2766
env:
2867
DATADOG_API_KEY: ${{ inputs.api-key }}

.github/workflows/ci.yaml

+22-3
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ jobs:
313313
run: ./scripts/check_unstaged.sh
314314

315315
test-go:
316-
runs-on: ${{ matrix.os == 'ubuntu-latest' && github.repository_owner == 'coder' && 'depot-ubuntu-22.04-4' || matrix.os == 'macos-latest' && github.repository_owner == 'coder' && 'depot-macos-latest' || matrix.os == 'windows-2022' && github.repository_owner == 'coder' && 'windows-latest-16-cores' || matrix.os }}
316+
runs-on: ${{ matrix.os == 'ubuntu-latest' && github.repository_owner == 'coder' && 'depot-ubuntu-22.04-4' || matrix.os == 'macos-latest' && github.repository_owner == 'coder' && 'depot-macos-latest' || matrix.os == 'windows-2022' && github.repository_owner == 'coder' && 'depot-windows-2022-16' || matrix.os }}
317317
needs: changes
318318
if: needs.changes.outputs.go == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
319319
timeout-minutes: 20
@@ -326,17 +326,31 @@ jobs:
326326
- windows-2022
327327
steps:
328328
- name: Harden Runner
329+
# Harden Runner is only supported on Ubuntu runners.
330+
if: runner.os == 'Linux'
329331
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
330332
with:
331333
egress-policy: audit
332334

335+
# Set up RAM disks to speed up the rest of the job. This action is in
336+
# a separate repository to allow its use before actions/checkout.
337+
- name: Setup RAM Disks
338+
if: runner.os == 'Windows'
339+
uses: coder/setup-ramdisk-action@79dacfe70c47ad6d6c0dd7f45412368802641439
340+
333341
- name: Checkout
334342
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
335343
with:
336344
fetch-depth: 1
337345

338346
- name: Setup Go
339347
uses: ./.github/actions/setup-go
348+
with:
349+
# Runners have Go baked-in and Go will automatically
350+
# download the toolchain configured in go.mod, so we don't
351+
# need to reinstall it. It's faster on Windows runners.
352+
use-preinstalled-go: ${{ runner.os == 'Windows' }}
353+
use-temp-cache-dirs: ${{ runner.os == 'Windows' }}
340354

341355
- name: Setup Terraform
342356
uses: ./.github/actions/setup-tf
@@ -368,8 +382,8 @@ jobs:
368382
touch ~/.bash_profile && echo "export BASH_SILENCE_DEPRECATION_WARNING=1" >> ~/.bash_profile
369383
fi
370384
export TS_DEBUG_DISCO=true
371-
gotestsum --junitfile="gotests.xml" --jsonfile="gotests.json" \
372-
--packages="./..." -- $PARALLEL_FLAG -short -failfast
385+
gotestsum --junitfile="gotests.xml" --jsonfile="gotests.json" --rerun-fails=2 \
386+
--packages="./..." -- $PARALLEL_FLAG -short
373387
374388
- name: Upload Test Cache
375389
uses: ./.github/actions/test-cache/upload
@@ -422,6 +436,7 @@ jobs:
422436
TS_DEBUG_DISCO: "true"
423437
LC_CTYPE: "en_US.UTF-8"
424438
LC_ALL: "en_US.UTF-8"
439+
TEST_RETRIES: 2
425440
shell: bash
426441
run: |
427442
# By default Go will use the number of logical CPUs, which
@@ -485,6 +500,7 @@ jobs:
485500
TS_DEBUG_DISCO: "true"
486501
LC_CTYPE: "en_US.UTF-8"
487502
LC_ALL: "en_US.UTF-8"
503+
TEST_RETRIES: 2
488504
shell: bash
489505
run: |
490506
# By default Go will use the number of logical CPUs, which
@@ -546,6 +562,7 @@ jobs:
546562
env:
547563
POSTGRES_VERSION: "16"
548564
TS_DEBUG_DISCO: "true"
565+
TEST_RETRIES: 2
549566
run: |
550567
make test-postgres
551568
@@ -770,6 +787,7 @@ jobs:
770787
if: ${{ !matrix.variant.premium }}
771788
env:
772789
DEBUG: pw:api
790+
CODER_E2E_TEST_RETRIES: 2
773791
working-directory: site
774792

775793
# Run all of the tests with a premium license
@@ -779,6 +797,7 @@ jobs:
779797
DEBUG: pw:api
780798
CODER_E2E_LICENSE: ${{ secrets.CODER_E2E_LICENSE }}
781799
CODER_E2E_REQUIRE_PREMIUM_TESTS: "1"
800+
CODER_E2E_TEST_RETRIES: 2
782801
working-directory: site
783802

784803
- name: Upload Playwright Failed Tests

CODEOWNERS

+2
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ agent/proto/ @spikecurtis @johnstcn
44
tailnet/proto/ @spikecurtis @johnstcn
55
vpn/vpn.proto @spikecurtis @johnstcn
66
vpn/version.go @spikecurtis @johnstcn
7+
provisionerd/proto/ @spikecurtis @johnstcn
8+
provisionersdk/proto/ @spikecurtis @johnstcn

Makefile

+10-3
Original file line numberDiff line numberDiff line change
@@ -875,12 +875,19 @@ provisioner/terraform/testdata/version:
875875
fi
876876
.PHONY: provisioner/terraform/testdata/version
877877

878+
# Set the retry flags if TEST_RETRIES is set
879+
ifdef TEST_RETRIES
880+
GOTESTSUM_RETRY_FLAGS := --rerun-fails=$(TEST_RETRIES)
881+
else
882+
GOTESTSUM_RETRY_FLAGS :=
883+
endif
884+
878885
test:
879-
$(GIT_FLAGS) gotestsum --format standard-quiet -- -v -short -count=1 ./... $(if $(RUN),-run $(RUN))
886+
$(GIT_FLAGS) gotestsum --format standard-quiet $(GOTESTSUM_RETRY_FLAGS) --packages="./..." -- -v -short -count=1 $(if $(RUN),-run $(RUN))
880887
.PHONY: test
881888

882889
test-cli:
883-
$(GIT_FLAGS) gotestsum --format standard-quiet -- -v -short -count=1 ./cli/...
890+
$(GIT_FLAGS) gotestsum --format standard-quiet $(GOTESTSUM_RETRY_FLAGS) --packages="./cli/..." -- -v -short -count=1
884891
.PHONY: test-cli
885892

886893
# sqlc-cloud-is-setup will fail if no SQLc auth token is set. Use this as a
@@ -919,9 +926,9 @@ test-postgres: test-postgres-docker
919926
$(GIT_FLAGS) DB=ci gotestsum \
920927
--junitfile="gotests.xml" \
921928
--jsonfile="gotests.json" \
929+
$(GOTESTSUM_RETRY_FLAGS) \
922930
--packages="./..." -- \
923931
-timeout=20m \
924-
-failfast \
925932
-count=1
926933
.PHONY: test-postgres
927934

agent/agent.go

+17-7
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ type Options struct {
8989
ServiceBannerRefreshInterval time.Duration
9090
BlockFileTransfer bool
9191
Execer agentexec.Execer
92-
ContainerLister agentcontainers.Lister
9392

9493
ExperimentalDevcontainersEnabled bool
94+
ContainerAPIOptions []agentcontainers.Option // Enable ExperimentalDevcontainersEnabled for these to be effective.
9595
}
9696

9797
type Client interface {
@@ -154,9 +154,6 @@ func New(options Options) Agent {
154154
if options.Execer == nil {
155155
options.Execer = agentexec.DefaultExecer
156156
}
157-
if options.ContainerLister == nil {
158-
options.ContainerLister = agentcontainers.NoopLister{}
159-
}
160157

161158
hardCtx, hardCancel := context.WithCancel(context.Background())
162159
gracefulCtx, gracefulCancel := context.WithCancel(hardCtx)
@@ -192,9 +189,9 @@ func New(options Options) Agent {
192189
prometheusRegistry: prometheusRegistry,
193190
metrics: newAgentMetrics(prometheusRegistry),
194191
execer: options.Execer,
195-
lister: options.ContainerLister,
196192

197193
experimentalDevcontainersEnabled: options.ExperimentalDevcontainersEnabled,
194+
containerAPIOptions: options.ContainerAPIOptions,
198195
}
199196
// Initially, we have a closed channel, reflecting the fact that we are not initially connected.
200197
// Each time we connect we replace the channel (while holding the closeMutex) with a new one
@@ -274,9 +271,10 @@ type agent struct {
274271
// labeled in Coder with the agent + workspace.
275272
metrics *agentMetrics
276273
execer agentexec.Execer
277-
lister agentcontainers.Lister
278274

279275
experimentalDevcontainersEnabled bool
276+
containerAPIOptions []agentcontainers.Option
277+
containerAPI atomic.Pointer[agentcontainers.API] // Set by apiHandler.
280278
}
281279

282280
func (a *agent) TailnetConn() *tailnet.Conn {
@@ -1170,6 +1168,12 @@ func (a *agent) handleManifest(manifestOK *checkpoint) func(ctx context.Context,
11701168
}
11711169
a.metrics.startupScriptSeconds.WithLabelValues(label).Set(dur)
11721170
a.scriptRunner.StartCron()
1171+
if containerAPI := a.containerAPI.Load(); containerAPI != nil {
1172+
// Inform the container API that the agent is ready.
1173+
// This allows us to start watching for changes to
1174+
// the devcontainer configuration files.
1175+
containerAPI.SignalReady()
1176+
}
11731177
})
11741178
if err != nil {
11751179
return xerrors.Errorf("track conn goroutine: %w", err)
@@ -1481,8 +1485,13 @@ func (a *agent) createTailnet(
14811485
}()
14821486
if err = a.trackGoroutine(func() {
14831487
defer apiListener.Close()
1488+
apiHandler, closeAPIHAndler := a.apiHandler()
1489+
defer func() {
1490+
_ = closeAPIHAndler()
1491+
}()
14841492
server := &http.Server{
1485-
Handler: a.apiHandler(),
1493+
BaseContext: func(net.Listener) context.Context { return ctx },
1494+
Handler: apiHandler,
14861495
ReadTimeout: 20 * time.Second,
14871496
ReadHeaderTimeout: 20 * time.Second,
14881497
WriteTimeout: 20 * time.Second,
@@ -1493,6 +1502,7 @@ func (a *agent) createTailnet(
14931502
case <-ctx.Done():
14941503
case <-a.hardCtx.Done():
14951504
}
1505+
_ = closeAPIHAndler()
14961506
_ = server.Close()
14971507
}()
14981508

0 commit comments

Comments
 (0)