Skip to content

Commit f9bc441

Browse files
authored
Merge branch 'main' into oidc-copy-2
2 parents 8994846 + 00a8221 commit f9bc441

File tree

300 files changed

+29777
-20632
lines changed

Some content is hidden

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

300 files changed

+29777
-20632
lines changed

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

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: |
44
inputs:
55
version:
66
description: "The Go version to use."
7-
default: "1.20.6"
7+
default: "1.20.7"
88
runs:
99
using: "composite"
1010
steps:
@@ -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

Lines changed: 11 additions & 3 deletions
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

Lines changed: 92 additions & 31 deletions
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
@@ -133,7 +137,7 @@ jobs:
133137
134138
# Check for any typos
135139
- name: Check for typos
136-
uses: crate-ci/typos@v1.16.1
140+
uses: crate-ci/typos@v1.16.2
137141
with:
138142
config: .github/workflows/typos.toml
139143

@@ -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
@@ -216,19 +224,7 @@ jobs:
216224
with:
217225
# This doesn't need caching. It's super fast anyways!
218226
cache: false
219-
go-version: 1.20.6
220-
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
227+
go-version: 1.20.7
232228

233229
- name: Install shfmt
234230
run: go install mvdan.cc/sh/v3/cmd/shfmt@v3.5.0
@@ -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
@@ -671,6 +668,7 @@ jobs:
671668
- test-go-pg
672669
- test-go-race
673670
- test-js
671+
- test-e2e
674672
- offlinedocs
675673
# Allow this job to run even if the needed jobs fail, are skipped or
676674
# cancelled.
@@ -695,3 +693,66 @@ jobs:
695693
fi
696694
697695
echo "Required checks have passed"
696+
697+
build-main-image:
698+
# This build and publihes ghcr.io/coder/coder-preview:main for each merge commit to main branch.
699+
# We are only building this for amd64 plateform. (>95% pulls are for amd64)
700+
needs: changes
701+
if: github.ref == 'refs/heads/main' && needs.changes.outputs.docs-only == 'false'
702+
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
703+
env:
704+
DOCKER_CLI_EXPERIMENTAL: "enabled"
705+
steps:
706+
- name: Checkout
707+
uses: actions/checkout@v3
708+
with:
709+
fetch-depth: 0
710+
711+
- name: Setup Node
712+
uses: ./.github/actions/setup-node
713+
714+
- name: Setup Go
715+
uses: ./.github/actions/setup-go
716+
717+
- name: Setup sqlc
718+
uses: ./.github/actions/setup-sqlc
719+
720+
- name: GHCR Login
721+
uses: docker/login-action@v2
722+
with:
723+
registry: ghcr.io
724+
username: ${{ github.actor }}
725+
password: ${{ secrets.GITHUB_TOKEN }}
726+
727+
- name: Build and push Linux amd64 Docker image
728+
id: build_and_push
729+
run: |
730+
set -euxo pipefail
731+
go mod download
732+
make gen/mark-fresh
733+
export DOCKER_IMAGE_NO_PREREQUISITES=true
734+
version="$(./scripts/version.sh)"
735+
export CODER_IMAGE_BUILD_BASE_TAG="$(CODER_IMAGE_BASE=coder-base ./scripts/image_tag.sh --version "$version")"
736+
make -j build/coder_linux_amd64
737+
./scripts/build_docker.sh \
738+
--arch amd64 \
739+
--target ghcr.io/coder/coder-preview:main \
740+
--version $version \
741+
--push \
742+
build/coder_linux_amd64
743+
744+
# Tag image with new package tag and push
745+
tag=$(echo "$version" | sed 's/+/-/g')
746+
docker tag ghcr.io/coder/coder-preview:main ghcr.io/coder/coder-preview:main-$tag
747+
docker push ghcr.io/coder/coder-preview:main-$tag
748+
749+
- name: Prune old images
750+
uses: vlaurin/action-ghcr-prune@v0.5.0
751+
with:
752+
token: ${{ secrets.GITHUB_TOKEN }}
753+
organization: coder
754+
container: coder-preview
755+
keep-younger-than: 7 # days
756+
keep-tags-regexes: ^pr
757+
prune-tags-regexes: ^main-
758+
prune-untagged: true

.github/workflows/pr-cleanup.yaml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Cleanup PR deployment and image
22
on:
33
pull_request:
4-
types: [closed]
4+
types: closed
55
workflow_dispatch:
66
inputs:
77
pr_number:
@@ -63,5 +63,18 @@ jobs:
6363
(
6464
curl -X DELETE "https://api.cloudflare.com/client/v4/zones/${{ secrets.PR_DEPLOYMENTS_ZONE_ID }}/dns_records/$record_id" \
6565
-H "Authorization: Bearer ${{ secrets.PR_DEPLOYMENTS_CLOUDFLARE_API_TOKEN }}" \
66-
-H "Content-Type:application/json"
66+
-H "Content-Type:application/json" | jq -r '.success'
6767
) || echo "DNS record not found"
68+
69+
- name: "Delete certificate"
70+
if: ${{ github.event.pull_request.merged == true }}
71+
run: |
72+
set -euxo pipefail
73+
kubectl delete certificate "pr${{ steps.pr_number.outputs.PR_NUMBER }}-tls" -n pr-deployment-certs || echo "certificate not found"
74+
75+
- name: Delete PR Comments
76+
uses: izhangzhihao/delete-comment@master
77+
with:
78+
github_token: ${{ secrets.GITHUB_TOKEN }}
79+
delete_user_name: github-actions[bot]
80+
issue_number: ${{ github.event.number }}

0 commit comments

Comments
 (0)