Skip to content

Commit e8a6713

Browse files
authored
Merge branch 'coder:main' into main
2 parents e0548a0 + 4983150 commit e8a6713

File tree

171 files changed

+980
-353
lines changed

Some content is hidden

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

171 files changed

+980
-353
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: "Install cosign"
2+
description: |
3+
Cosign Github Action.
4+
runs:
5+
using: "composite"
6+
steps:
7+
- name: Install cosign
8+
uses: sigstore/cosign-installer@d7d6bc7722e3daa8354c50bcb52f4837da5e9b6a # v3.8.1
9+
with:
10+
cosign-release: "v2.4.3"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: "Install syft"
2+
description: |
3+
Downloads Syft to the Action tool cache and provides a reference.
4+
runs:
5+
using: "composite"
6+
steps:
7+
- name: Install syft
8+
uses: anchore/sbom-action/download-syft@f325610c9f50a54015d37c8d16cb3b0e2c8f4de0 # v0.18.0
9+
with:
10+
syft-version: "v1.20.0"

.github/workflows/ci.yaml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ jobs:
178178
echo "LINT_CACHE_DIR=$dir" >> $GITHUB_ENV
179179
180180
- name: golangci-lint cache
181-
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
181+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
182182
with:
183183
path: |
184184
${{ env.LINT_CACHE_DIR }}
@@ -730,15 +730,15 @@ jobs:
730730

731731
- name: Upload Playwright Failed Tests
732732
if: always() && github.actor != 'dependabot[bot]' && runner.os == 'Linux' && !github.event.pull_request.head.repo.fork
733-
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
733+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
734734
with:
735735
name: failed-test-videos${{ matrix.variant.premium && '-premium' || '' }}
736736
path: ./site/test-results/**/*.webm
737737
retention-days: 7
738738

739739
- name: Upload pprof dumps
740740
if: always() && github.actor != 'dependabot[bot]' && runner.os == 'Linux' && !github.event.pull_request.head.repo.fork
741-
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
741+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
742742
with:
743743
name: debug-pprof-dumps${{ matrix.variant.premium && '-premium' || '' }}
744744
path: ./site/test-results/**/debug-pprof-*.txt
@@ -997,7 +997,7 @@ jobs:
997997

998998
- name: Upload build artifacts
999999
if: ${{ github.repository_owner == 'coder' && github.ref == 'refs/heads/main' }}
1000-
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
1000+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
10011001
with:
10021002
name: dylibs
10031003
path: |
@@ -1071,14 +1071,10 @@ jobs:
10711071
run: sudo apt-get install -y zstd
10721072

10731073
- name: Install cosign
1074-
uses: sigstore/cosign-installer@d7d6bc7722e3daa8354c50bcb52f4837da5e9b6a # v3.8.1
1075-
with:
1076-
cosign-release: "v2.4.3"
1074+
uses: ./.github/actions/install-cosign
10771075

10781076
- name: Install syft
1079-
uses: anchore/sbom-action/download-syft@f325610c9f50a54015d37c8d16cb3b0e2c8f4de0 # v0.18.0
1080-
with:
1081-
syft-version: "v1.20.0"
1077+
uses: ./.github/actions/install-syft
10821078

10831079
- name: Setup Windows EV Signing Certificate
10841080
run: |
@@ -1103,7 +1099,7 @@ jobs:
11031099
uses: google-github-actions/setup-gcloud@77e7a554d41e2ee56fc945c52dfd3f33d12def9a # v2.1.4
11041100

11051101
- name: Download dylibs
1106-
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9
1102+
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
11071103
with:
11081104
name: dylibs
11091105
path: ./build
@@ -1330,7 +1326,7 @@ jobs:
13301326

13311327
- name: Upload build artifacts
13321328
if: github.ref == 'refs/heads/main'
1333-
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
1329+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
13341330
with:
13351331
name: coder
13361332
path: |

.github/workflows/docs-ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
- name: Setup Node
2929
uses: ./.github/actions/setup-node
3030

31-
- uses: tj-actions/changed-files@531f5f7d163941f0c1c04e0ff4d8bb243ac4366f # v45.0.7
31+
- uses: tj-actions/changed-files@27ae6b33eaed7bf87272fdeb9f1c54f9facc9d99 # v45.0.7
3232
id: changed-files
3333
with:
3434
files: |

.github/workflows/dogfood.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858

5959
- name: Get branch name
6060
id: branch-name
61-
uses: tj-actions/branch-names@6871f53176ad61624f978536bbf089c574dc19a2 # v8.0.1
61+
uses: tj-actions/branch-names@f44339b51f74753b57583fbbd124e18a81170ab1 # v8.1.0
6262

6363
- name: "Branch name to Docker tag name"
6464
id: docker-tag-name

.github/workflows/release.yaml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ jobs:
101101
AC_CERTIFICATE_PASSWORD_FILE: /tmp/apple_cert_password.txt
102102

103103
- name: Upload build artifacts
104-
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
104+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
105105
with:
106106
name: dylibs
107107
path: |
@@ -251,14 +251,10 @@ jobs:
251251
rm /tmp/rcodesign.tar.gz
252252
253253
- name: Install cosign
254-
uses: sigstore/cosign-installer@d7d6bc7722e3daa8354c50bcb52f4837da5e9b6a # v3.8.1
255-
with:
256-
cosign-release: "v2.4.3"
254+
uses: ./.github/actions/install-cosign
257255

258256
- name: Install syft
259-
uses: anchore/sbom-action/download-syft@f325610c9f50a54015d37c8d16cb3b0e2c8f4de0 # v0.18.0
260-
with:
261-
syft-version: "v1.20.0"
257+
uses: ./.github/actions/install-syft
262258

263259
- name: Setup Apple Developer certificate and API key
264260
run: |
@@ -300,7 +296,7 @@ jobs:
300296
uses: google-github-actions/setup-gcloud@77e7a554d41e2ee56fc945c52dfd3f33d12def9a # v2.1.4
301297

302298
- name: Download dylibs
303-
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9
299+
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
304300
with:
305301
name: dylibs
306302
path: ./build
@@ -661,7 +657,7 @@ jobs:
661657
662658
- name: Upload artifacts to actions (if dry-run)
663659
if: ${{ inputs.dry_run }}
664-
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
660+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
665661
with:
666662
name: release-artifacts
667663
path: |

.github/workflows/scorecard.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ jobs:
3939

4040
# Upload the results as artifacts.
4141
- name: "Upload artifact"
42-
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
42+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
4343
with:
4444
name: SARIF file
4545
path: results.sarif
4646
retention-days: 5
4747

4848
# Upload the results to GitHub's code scanning dashboard.
4949
- name: "Upload to code-scanning"
50-
uses: github/codeql-action/upload-sarif@6bb031afdd8eb862ea3fc1848194185e076637e5 # v3.28.11
50+
uses: github/codeql-action/upload-sarif@5f8171a638ada777af81d42b55959a643bb29017 # v3.28.12
5151
with:
5252
sarif_file: results.sarif

.github/workflows/security.yaml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
uses: ./.github/actions/setup-go
3939

4040
- name: Initialize CodeQL
41-
uses: github/codeql-action/init@6bb031afdd8eb862ea3fc1848194185e076637e5 # v3.28.11
41+
uses: github/codeql-action/init@5f8171a638ada777af81d42b55959a643bb29017 # v3.28.12
4242
with:
4343
languages: go, javascript
4444

@@ -48,7 +48,7 @@ jobs:
4848
rm Makefile
4949
5050
- name: Perform CodeQL Analysis
51-
uses: github/codeql-action/analyze@6bb031afdd8eb862ea3fc1848194185e076637e5 # v3.28.11
51+
uses: github/codeql-action/analyze@5f8171a638ada777af81d42b55959a643bb29017 # v3.28.12
5252

5353
- name: Send Slack notification on failure
5454
if: ${{ failure() }}
@@ -85,6 +85,12 @@ jobs:
8585
- name: Setup sqlc
8686
uses: ./.github/actions/setup-sqlc
8787

88+
- name: Install cosign
89+
uses: ./.github/actions/install-cosign
90+
91+
- name: Install syft
92+
uses: ./.github/actions/install-syft
93+
8894
- name: Install yq
8995
run: go run github.com/mikefarah/yq/v4@v4.44.3
9096
- name: Install mockgen
@@ -144,13 +150,13 @@ jobs:
144150
severity: "CRITICAL,HIGH"
145151

146152
- name: Upload Trivy scan results to GitHub Security tab
147-
uses: github/codeql-action/upload-sarif@6bb031afdd8eb862ea3fc1848194185e076637e5 # v3.28.11
153+
uses: github/codeql-action/upload-sarif@5f8171a638ada777af81d42b55959a643bb29017 # v3.28.12
148154
with:
149155
sarif_file: trivy-results.sarif
150156
category: "Trivy"
151157

152158
- name: Upload Trivy scan results as an artifact
153-
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
159+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
154160
with:
155161
name: trivy
156162
path: trivy-results.sarif

.github/workflows/stale.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ jobs:
103103
- name: Checkout repository
104104
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
105105
- name: Run delete-old-branches-action
106-
uses: beatlabs/delete-old-branches-action@6e94df089372a619c01ae2c2f666bf474f890911 # v0.0.10
106+
uses: beatlabs/delete-old-branches-action@4eeeb8740ff8b3cb310296ddd6b43c3387734588 # v0.0.11
107107
with:
108108
repo_token: ${{ github.token }}
109109
date: "6 months ago"

.github/workflows/weekly-docs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3030

3131
- name: Check Markdown links
32-
uses: umbrelladocs/action-linkspector@de84085e0f51452a470558693d7d308fbb2fa261 # v1.2.5
32+
uses: umbrelladocs/action-linkspector@49cf4f8da82db70e691bb8284053add5028fa244 # v1.3.2
3333
id: markdown-link-check
3434
# checks all markdown files from /docs including all subfolders
3535
with:

Makefile

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@ FIND_EXCLUSIONS= \
5454
-not \( \( -path '*/.git/*' -o -path './build/*' -o -path './vendor/*' -o -path './.coderv2/*' -o -path '*/node_modules/*' -o -path '*/out/*' -o -path './coderd/apidoc/*' -o -path '*/.next/*' -o -path '*/.terraform/*' \) -prune \)
5555
# Source files used for make targets, evaluated on use.
5656
GO_SRC_FILES := $(shell find . $(FIND_EXCLUSIONS) -type f -name '*.go' -not -name '*_test.go')
57+
# Same as GO_SRC_FILES but excluding certain files that have problematic
58+
# Makefile dependencies (e.g. pnpm).
59+
MOST_GO_SRC_FILES := $(shell \
60+
find . \
61+
$(FIND_EXCLUSIONS) \
62+
-type f \
63+
-name '*.go' \
64+
-not -name '*_test.go' \
65+
-not -wholename './agent/agentcontainers/dcspec/dcspec_gen.go' \
66+
)
5767
# All the shell files in the repo, excluding ignored files.
5868
SHELL_SRC_FILES := $(shell find . $(FIND_EXCLUSIONS) -type f -name '*.sh')
5969

@@ -243,7 +253,7 @@ $(CODER_ALL_BINARIES): go.mod go.sum \
243253
fi
244254

245255
# This task builds Coder Desktop dylibs
246-
$(CODER_DYLIBS): go.mod go.sum $(GO_SRC_FILES)
256+
$(CODER_DYLIBS): go.mod go.sum $(MOST_GO_SRC_FILES)
247257
@if [ "$(shell uname)" = "Darwin" ]; then
248258
$(get-mode-os-arch-ext)
249259
./scripts/build_go.sh \
@@ -659,8 +669,12 @@ agent/agentcontainers/acmock/acmock.go: agent/agentcontainers/containers.go
659669
go generate ./agent/agentcontainers/acmock/
660670
touch "$@"
661671

662-
agent/agentcontainers/dcspec/dcspec_gen.go: agent/agentcontainers/dcspec/devContainer.base.schema.json
663-
go generate ./agent/agentcontainers/dcspec/
672+
agent/agentcontainers/dcspec/dcspec_gen.go: \
673+
node_modules/.installed \
674+
agent/agentcontainers/dcspec/devContainer.base.schema.json \
675+
agent/agentcontainers/dcspec/gen.sh \
676+
agent/agentcontainers/dcspec/doc.go
677+
DCSPEC_QUIET=true go generate ./agent/agentcontainers/dcspec/
664678
touch "$@"
665679

666680
$(TAILNETTEST_MOCKS): tailnet/coordinator.go tailnet/service.go

agent/agent.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,10 @@ func (a *agent) run() (retErr error) {
965965
if err != nil {
966966
return xerrors.Errorf("failed to create resources fetcher: %w", err)
967967
}
968-
resourcesFetcher := resourcesmonitor.NewFetcher(statfetcher)
968+
resourcesFetcher, err := resourcesmonitor.NewFetcher(statfetcher)
969+
if err != nil {
970+
return xerrors.Errorf("new resource fetcher: %w", err)
971+
}
969972

970973
resourcesmonitor := resourcesmonitor.NewResourcesMonitor(logger, clk, config, resourcesFetcher, aAPI)
971974
return resourcesmonitor.Start(ctx)

agent/agentcontainers/dcspec/gen.sh

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,36 @@ fi
3030

3131
TMPDIR=$(mktemp -d)
3232
trap 'rm -rfv "$TMPDIR"' EXIT
33-
pnpm exec quicktype \
33+
34+
show_stderr=1
35+
exec 3>&2
36+
if [[ " $* " == *" --quiet "* ]] || [[ ${DCSPEC_QUIET:-false} == "true" ]]; then
37+
# Redirect stderr to log because quicktype can't infer all types and
38+
# we don't care right now.
39+
show_stderr=0
40+
exec 2>"${TMPDIR}/stderr.log"
41+
fi
42+
43+
if ! pnpm exec quicktype \
3444
--src-lang schema \
3545
--lang go \
3646
--just-types-and-package \
3747
--top-level "DevContainer" \
3848
--out "${TMPDIR}/${DEST_FILENAME}" \
3949
--package "dcspec" \
40-
"${SCHEMA_DEST}"
50+
"${SCHEMA_DEST}"; then
51+
echo "quicktype failed to generate Go code." >&3
52+
if [[ "${show_stderr}" -eq 1 ]]; then
53+
cat "${TMPDIR}/stderr.log" >&3
54+
fi
55+
exit 1
56+
fi
57+
58+
if [[ "${show_stderr}" -eq 0 ]]; then
59+
# Restore stderr.
60+
exec 2>&3
61+
fi
62+
exec 3>&-
4163

4264
# Format the generated code.
4365
go run mvdan.cc/gofumpt@v0.4.0 -w -l "${TMPDIR}/${DEST_FILENAME}"

agent/proto/resourcesmonitor/fetcher.go

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,58 @@ import (
66
"github.com/coder/coder/v2/cli/clistat"
77
)
88

9+
type Statter interface {
10+
IsContainerized() (bool, error)
11+
ContainerMemory(p clistat.Prefix) (*clistat.Result, error)
12+
HostMemory(p clistat.Prefix) (*clistat.Result, error)
13+
Disk(p clistat.Prefix, path string) (*clistat.Result, error)
14+
}
15+
916
type Fetcher interface {
1017
FetchMemory() (total int64, used int64, err error)
1118
FetchVolume(volume string) (total int64, used int64, err error)
1219
}
1320

1421
type fetcher struct {
15-
*clistat.Statter
22+
Statter
23+
isContainerized bool
1624
}
1725

1826
//nolint:revive
19-
func NewFetcher(f *clistat.Statter) *fetcher {
20-
return &fetcher{
21-
f,
27+
func NewFetcher(f Statter) (*fetcher, error) {
28+
isContainerized, err := f.IsContainerized()
29+
if err != nil {
30+
return nil, xerrors.Errorf("check is containerized: %w", err)
2231
}
32+
33+
return &fetcher{f, isContainerized}, nil
2334
}
2435

2536
func (f *fetcher) FetchMemory() (total int64, used int64, err error) {
26-
mem, err := f.HostMemory(clistat.PrefixDefault)
27-
if err != nil {
28-
return 0, 0, xerrors.Errorf("failed to fetch memory: %w", err)
37+
var mem *clistat.Result
38+
39+
if f.isContainerized {
40+
mem, err = f.ContainerMemory(clistat.PrefixDefault)
41+
if err != nil {
42+
return 0, 0, xerrors.Errorf("fetch container memory: %w", err)
43+
}
44+
45+
// A container might not have a memory limit set. If this
46+
// happens we want to fallback to querying the host's memory
47+
// to know what the total memory is on the host.
48+
if mem.Total == nil {
49+
hostMem, err := f.HostMemory(clistat.PrefixDefault)
50+
if err != nil {
51+
return 0, 0, xerrors.Errorf("fetch host memory: %w", err)
52+
}
53+
54+
mem.Total = hostMem.Total
55+
}
56+
} else {
57+
mem, err = f.HostMemory(clistat.PrefixDefault)
58+
if err != nil {
59+
return 0, 0, xerrors.Errorf("fetch host memory: %w", err)
60+
}
2961
}
3062

3163
if mem.Total == nil {

0 commit comments

Comments
 (0)