Skip to content

Commit e605a15

Browse files
committed
Merge branch 'main' into mafredri/feat-coderd-add-template-variable-usage-to-insights
2 parents 2e37d6a + 7493b28 commit e605a15

File tree

155 files changed

+23079
-18963
lines changed

Some content is hidden

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

155 files changed

+23079
-18963
lines changed

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

+11-10
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,25 @@ runs:
3939
path: |
4040
${{ env.GOMODCACHE }}
4141
key: gomodcache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}-${{ github.job }}
42-
restore-keys: |
43-
gomodcache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}-
44-
gomodcache-${{ runner.os }}-
42+
# restore-keys aren't used because it causes the cache to grow
43+
# infinitely. go.sum changes very infrequently, so rebuilding from
44+
# scratch every now and then isn't terrible.
4545

4646
- name: Cache $GOCACHE
4747
uses: buildjet/cache@v3
4848
with:
4949
path: |
5050
${{ env.GOCACHE }}
51-
# Job name must be included in the key for effective
52-
# test cache reuse.
51+
# Job name must be included in the key for effective test cache reuse.
5352
# The key format is intentionally different than GOMODCACHE, because any
54-
# time a Go file changes we invalidate this cache, whereas GOMODCACHE
55-
# is only invalidated when go.sum changes.
56-
key: gocache-${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/*.go', 'go.**') }}
53+
# time a Go file changes we invalidate this cache, whereas GOMODCACHE is
54+
# only invalidated when go.sum changes.
55+
# The number in the key is incremented when the cache gets too large,
56+
# since this technically grows without bound.
57+
key: gocache2-${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/*.go', 'go.**') }}
5758
restore-keys: |
58-
gocache-${{ runner.os }}-${{ github.job }}-
59-
gocache-${{ runner.os }}-
59+
gocache2-${{ runner.os }}-${{ github.job }}-
60+
gocache2-${{ runner.os }}-
6061
6162
- name: Install gotestsum
6263
shell: bash

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

+11-3
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,22 @@ inputs:
1010
runs:
1111
using: "composite"
1212
steps:
13+
- name: Install pnpm
14+
uses: pnpm/action-setup@v2
15+
with:
16+
version: 8
1317
- name: Setup Node
1418
uses: buildjet/setup-node@v3
1519
with:
1620
node-version: 18.17.0
1721
# See https://github.com/actions/setup-node#caching-global-packages-data
18-
cache: "yarn"
19-
cache-dependency-path: ${{ inputs.directory }}/yarn.lock
22+
cache: "pnpm"
23+
cache-dependency-path: ${{ inputs.directory }}/pnpm-lock.yaml
24+
- name: Install root node_modules
25+
shell: bash
26+
run: ./scripts/pnpm_install.sh
27+
2028
- name: Install node_modules
2129
shell: bash
22-
run: ../scripts/yarn_install.sh
30+
run: ../scripts/pnpm_install.sh
2331
working-directory: ${{ inputs.directory }}

.github/workflows/ci.yaml

+72-29
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ permissions:
1414
contents: read
1515
deployments: none
1616
issues: none
17-
packages: none
17+
packages: write
1818
pull-requests: none
1919
repository-projects: none
2020
security-events: none
@@ -40,6 +40,8 @@ jobs:
4040
steps:
4141
- name: Checkout
4242
uses: actions/checkout@v3
43+
with:
44+
fetch-depth: 1
4345
# For pull requests it's not necessary to checkout the code
4446
- name: check changed files
4547
uses: dorny/paths-filter@v2
@@ -109,6 +111,8 @@ jobs:
109111
steps:
110112
- name: Checkout
111113
uses: actions/checkout@v3
114+
with:
115+
fetch-depth: 1
112116

113117
- name: Setup Node
114118
uses: ./.github/actions/setup-node
@@ -162,6 +166,8 @@ jobs:
162166
steps:
163167
- name: Checkout
164168
uses: actions/checkout@v3
169+
with:
170+
fetch-depth: 1
165171

166172
- name: Setup Node
167173
uses: ./.github/actions/setup-node
@@ -207,6 +213,8 @@ jobs:
207213
steps:
208214
- name: Checkout
209215
uses: actions/checkout@v3
216+
with:
217+
fetch-depth: 1
210218

211219
- name: Setup Node
212220
uses: ./.github/actions/setup-node
@@ -218,18 +226,6 @@ jobs:
218226
cache: false
219227
go-version: 1.20.6
220228

221-
- name: Install prettier
222-
# We only need prettier for fmt, so do not install all dependencies.
223-
# There is no way to install a single package with yarn, so we have to
224-
# make a new package.json with only prettier listed as a dependency.
225-
# Then running `yarn` will only install prettier.
226-
run: |
227-
cd site
228-
mv package.json package.json.bak
229-
jq '{dependencies: {prettier: .devDependencies.prettier}}' < package.json.bak > package.json
230-
yarn --frozen-lockfile
231-
mv package.json.bak package.json
232-
233229
- name: Install shfmt
234230
run: go install mvdan.cc/sh/v3/cmd/shfmt@v3.5.0
235231

@@ -256,6 +252,8 @@ jobs:
256252
steps:
257253
- name: Checkout
258254
uses: actions/checkout@v3
255+
with:
256+
fetch-depth: 1
259257

260258
- name: Setup Go
261259
uses: ./.github/actions/setup-go
@@ -323,6 +321,8 @@ jobs:
323321
steps:
324322
- name: Checkout
325323
uses: actions/checkout@v3
324+
with:
325+
fetch-depth: 1
326326

327327
- name: Setup Go
328328
uses: ./.github/actions/setup-go
@@ -369,6 +369,8 @@ jobs:
369369
steps:
370370
- name: Checkout
371371
uses: actions/checkout@v3
372+
with:
373+
fetch-depth: 1
372374

373375
- name: Setup Go
374376
uses: ./.github/actions/setup-go
@@ -488,11 +490,13 @@ jobs:
488490
steps:
489491
- name: Checkout
490492
uses: actions/checkout@v3
493+
with:
494+
fetch-depth: 1
491495

492496
- name: Setup Node
493497
uses: ./.github/actions/setup-node
494498

495-
- run: yarn test:ci --max-workers $(nproc)
499+
- run: pnpm test:ci --max-workers $(nproc)
496500
working-directory: site
497501

498502
- name: Check code coverage
@@ -516,6 +520,8 @@ jobs:
516520
steps:
517521
- name: Checkout
518522
uses: actions/checkout@v3
523+
with:
524+
fetch-depth: 1
519525

520526
- name: Setup Node
521527
uses: ./.github/actions/setup-node
@@ -528,13 +534,12 @@ jobs:
528534

529535
- name: Build
530536
run: |
531-
sudo npm install -g prettier
532537
make -B site/out/index.html
533538
534-
- run: yarn playwright:install
539+
- run: pnpm playwright:install
535540
working-directory: site
536541

537-
- run: yarn playwright:test
542+
- run: pnpm playwright:test
538543
env:
539544
DEBUG: pw:api
540545
working-directory: site
@@ -619,6 +624,7 @@ jobs:
619624
- name: Checkout
620625
uses: actions/checkout@v3
621626
with:
627+
# 0 is required here for version.sh to work.
622628
fetch-depth: 0
623629

624630
- name: Setup Node
@@ -638,28 +644,19 @@ jobs:
638644
with:
639645
sqlc-version: "1.19.1"
640646

641-
- name: Install dependencies
642-
run: |
643-
cd offlinedocs
644-
yarn
645-
# Install prettier globally
646-
prettier_version=$(jq -r '.devDependencies.prettier' < package.json)
647-
yarn global add "prettier@${prettier_version}"
648-
649647
- name: Format
650648
run: |
651649
cd offlinedocs
652-
yarn format:check
650+
pnpm format:check
653651
654652
- name: Lint
655653
run: |
656654
cd offlinedocs
657-
yarn lint
655+
pnpm lint
658656
659657
- name: Build
660658
run: |
661-
version="$(./scripts/version.sh)"
662-
make -j build/coder_docs_"$version".tgz
659+
make -j build/coder_docs_"$(./scripts/version.sh)".tgz
663660
664661
required:
665662
runs-on: ubuntu-latest
@@ -695,3 +692,49 @@ jobs:
695692
fi
696693
697694
echo "Required checks have passed"
695+
696+
build-main-image:
697+
# This build and publihes ghcr.io/coder/coder-preview:main for each merge commit to main branch.
698+
# We are only building this for amd64 plateform. (>95% pulls are for amd64)
699+
needs: changes
700+
if: github.ref == 'refs/heads/main' && needs.changes.outputs.docs-only == 'false'
701+
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
702+
env:
703+
DOCKER_CLI_EXPERIMENTAL: "enabled"
704+
steps:
705+
- name: Checkout
706+
uses: actions/checkout@v3
707+
with:
708+
fetch-depth: 0
709+
710+
- name: Setup Node
711+
uses: ./.github/actions/setup-node
712+
713+
- name: Setup Go
714+
uses: ./.github/actions/setup-go
715+
716+
- name: Setup sqlc
717+
uses: ./.github/actions/setup-sqlc
718+
719+
- name: GHCR Login
720+
uses: docker/login-action@v2
721+
with:
722+
registry: ghcr.io
723+
username: ${{ github.actor }}
724+
password: ${{ secrets.GITHUB_TOKEN }}
725+
726+
- name: Build and push Linux amd64 Docker image
727+
run: |
728+
set -euxo pipefail
729+
go mod download
730+
make gen/mark-fresh
731+
export DOCKER_IMAGE_NO_PREREQUISITES=true
732+
version="$(./scripts/version.sh)"
733+
export CODER_IMAGE_BUILD_BASE_TAG="$(CODER_IMAGE_BASE=coder-base ./scripts/image_tag.sh --version "$version")"
734+
make -j build/coder_linux_amd64
735+
./scripts/build_docker.sh \
736+
--arch amd64 \
737+
--target ghcr.io/coder/coder-preview:main \
738+
--version $version \
739+
--push \
740+
build/coder_linux_amd64

.github/workflows/pr-cleanup.yaml

+17
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,20 @@ jobs:
4848
- name: "Remove PR namespace"
4949
run: |
5050
kubectl delete namespace "pr${{ steps.pr_number.outputs.PR_NUMBER }}" || echo "namespace not found"
51+
52+
- name: "Remove DNS records"
53+
run: |
54+
set -euxo pipefail
55+
# Get identifier for the record
56+
record_id=$(curl -X GET "https://api.cloudflare.com/client/v4/zones/${{ secrets.PR_DEPLOYMENTS_ZONE_ID }}/dns_records?name=%2A.pr${{ steps.pr_number.outputs.PR_NUMBER }}.${{ secrets.PR_DEPLOYMENTS_DOMAIN }}" \
57+
-H "Authorization: Bearer ${{ secrets.PR_DEPLOYMENTS_CLOUDFLARE_API_TOKEN }}" \
58+
-H "Content-Type:application/json" | jq -r '.result[0].id') || echo "DNS record not found"
59+
60+
echo "::add-mask::$record_id"
61+
62+
# Delete the record
63+
(
64+
curl -X DELETE "https://api.cloudflare.com/client/v4/zones/${{ secrets.PR_DEPLOYMENTS_ZONE_ID }}/dns_records/$record_id" \
65+
-H "Authorization: Bearer ${{ secrets.PR_DEPLOYMENTS_CLOUDFLARE_API_TOKEN }}" \
66+
-H "Content-Type:application/json"
67+
) || echo "DNS record not found"

0 commit comments

Comments
 (0)