Skip to content

Commit 7aedfbc

Browse files
committed
Merge remote-tracking branch 'origin/main' into stevenmasley/merge_oidc_account
2 parents 57b3605 + 0a6e644 commit 7aedfbc

File tree

174 files changed

+5906
-959
lines changed

Some content is hidden

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

174 files changed

+5906
-959
lines changed

.github/workflows/ci.yaml

+12-5
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ jobs:
4747
docs:
4848
- "docs/**"
4949
- "README.md"
50-
# For testing:
51-
# - ".github/**"
50+
- "examples/templates/**"
51+
- "examples/web-server/**"
52+
- "examples/monitoring/**"
53+
- "examples/lima/**"
5254
go:
5355
- "**.sql"
5456
- "**.go"
@@ -231,7 +233,7 @@ jobs:
231233

232234
- uses: hashicorp/setup-terraform@v2
233235
with:
234-
terraform_version: 1.1.9
236+
terraform_version: 1.5.1
235237
terraform_wrapper: false
236238

237239
- name: Test with Mock Database
@@ -296,7 +298,7 @@ jobs:
296298

297299
- uses: hashicorp/setup-terraform@v2
298300
with:
299-
terraform_version: 1.1.9
301+
terraform_version: 1.5.1
300302
terraform_wrapper: false
301303

302304
- name: Test with PostgreSQL Database
@@ -338,6 +340,11 @@ jobs:
338340

339341
- uses: ./.github/actions/setup-go
340342

343+
- uses: hashicorp/setup-terraform@v2
344+
with:
345+
terraform_version: 1.5.1
346+
terraform_wrapper: false
347+
341348
- name: Run Tests
342349
run: |
343350
gotestsum --junitfile="gotests.xml" -- -race ./...
@@ -474,7 +481,7 @@ jobs:
474481

475482
- uses: hashicorp/setup-terraform@v2
476483
with:
477-
terraform_version: 1.1.9
484+
terraform_version: 1.5.1
478485
terraform_wrapper: false
479486

480487
- name: Build

.github/workflows/pr-cleanup.yaml

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Cleanup PR
2+
on:
3+
pull_request:
4+
types: [closed]
5+
workflow_dispatch:
6+
inputs:
7+
pr_number:
8+
description: "PR number"
9+
required: true
10+
11+
permissions:
12+
packages: write
13+
14+
jobs:
15+
cleanup:
16+
runs-on: "ubuntu-latest"
17+
steps:
18+
- name: Get PR number
19+
id: pr_number
20+
run: |
21+
if [ -z "${{ github.event.pull_request.number }}" ]; then
22+
echo "PR_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT
23+
else
24+
echo "PR_NUMBER=${{ github.event.inputs.pr_number }}" >> $GITHUB_OUTPUT
25+
fi
26+
27+
- name: Delete image
28+
uses: bots-house/ghcr-delete-image-action@v1.1.0
29+
with:
30+
owner: coder
31+
name: coder-preview
32+
token: ${{ secrets.GITHUB_TOKEN }}
33+
tag: pr${{ steps.pr_number.outputs.PR_NUMBER }}
34+
35+
- name: Set up kubeconfig
36+
if: always()
37+
run: |
38+
set -euxo pipefail
39+
mkdir -p ~/.kube
40+
echo "${{ secrets.DELIVERYBOT_KUBECONFIG }}" > ~/.kube/config
41+
export KUBECONFIG=~/.kube/config
42+
43+
- name: Delete helm release
44+
if: always()
45+
run: |
46+
set -euxo pipefail
47+
helm delete --namespace "pr${{ steps.pr_number.outputs.PR_NUMBER }}" "pr${{ steps.pr_number.outputs.PR_NUMBER }}" || echo "helm release not found"
48+
49+
- name: "Remove PR namespace"
50+
if: always()
51+
run: |
52+
kubectl delete namespace "pr${{ steps.pr_number.outputs.PR_NUMBER }}" || echo "namespace not found"

.github/workflows/pr-deploy.yaml

+190
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
# This action will trigger when a PR is commentted containing /review-pr by a member of the org.
2+
name: Deploy PR
3+
on:
4+
issue_comment:
5+
workflow_dispatch:
6+
inputs:
7+
pr_number:
8+
description: "PR number"
9+
required: true
10+
11+
env:
12+
REPO: ghcr.io/coder/coder-preview
13+
14+
permissions:
15+
contents: read
16+
packages: write
17+
pull-requests: write
18+
19+
concurrency:
20+
group: ${{ github.workflow }}-${{ github.ref }}
21+
cancel-in-progress: true
22+
23+
jobs:
24+
pr_commented:
25+
if: github.event_name == 'issue_comment' && contains(github.event.comment.body, '/deploy-pr') && github.event.comment.author_association == 'MEMBER' || github.event_name == 'workflow_dispatch'
26+
outputs:
27+
PR_NUMBER: ${{ steps.pr_number.outputs.PR_NUMBER }}
28+
PR_TITLE: ${{ steps.pr_number.outputs.PR_TITLE }}
29+
PR_URL: ${{ steps.pr_number.outputs.PR_URL }}
30+
COMMENT_ID: ${{ steps.comment_id.outputs.comment-id }}
31+
CODER_BASE_IMAGE_TAG: ${{ steps.set_tags.outputs.CODER_BASE_IMAGE_TAG }}
32+
CODER_IMAGE_TAG: ${{ steps.set_tags.outputs.CODER_IMAGE_TAG }}
33+
34+
runs-on: "ubuntu-latest"
35+
steps:
36+
- name: Get PR number and title
37+
id: pr_number
38+
run: |
39+
set -euxo pipefail
40+
if [[ ${{ github.event_name }} == "workflow_dispatch" ]]; then
41+
PR_NUMBER=${{ github.event.inputs.pr_number }}
42+
PR_TITLE=$(curl -sSL -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/coder/coder/pulls/$PR_NUMBER" | jq -r '.title')
43+
else
44+
PR_NUMBER=${{ github.event.issue.number }}
45+
PR_TITLE='${{ github.event.issue.title }}'
46+
fi
47+
echo "PR_URL=https://github.com/coder/coder/pull/$PR_NUMBER" >> $GITHUB_OUTPUT
48+
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_OUTPUT
49+
echo "PR_TITLE=$PR_TITLE" >> $GITHUB_OUTPUT
50+
51+
- name: Set required tags
52+
id: set_tags
53+
run: |
54+
set -euxo pipefail
55+
echo "CODER_BASE_IMAGE_TAG=$CODER_BASE_IMAGE_TAG" >> $GITHUB_OUTPUT
56+
echo "CODER_IMAGE_TAG=$CODER_IMAGE_TAG" >> $GITHUB_OUTPUT
57+
env:
58+
CODER_BASE_IMAGE_TAG: ghcr.io/coder/coder-preview-base:pr${{ steps.pr_number.outputs.PR_NUMBER }}
59+
CODER_IMAGE_TAG: ghcr.io/coder/coder-preview:pr${{ steps.pr_number.outputs.PR_NUMBER }}
60+
61+
- name: Find Comment
62+
uses: peter-evans/find-comment@v2
63+
id: fc
64+
with:
65+
issue-number: ${{ steps.pr_number.outputs.PR_NUMBER }}
66+
comment-author: "github-actions[bot]"
67+
body-includes: This deployment will be deleted when the PR is closed
68+
69+
- name: Comment on PR
70+
id: comment_id
71+
uses: peter-evans/create-or-update-comment@v3
72+
with:
73+
comment-id: ${{ steps.fc.outputs.comment-id }}
74+
issue-number: ${{ steps.pr_number.outputs.PR_NUMBER }}
75+
edit-mode: replace
76+
body: |
77+
:rocket: Deploying PR ${{ steps.pr_number.outputs.PR_NUMBER }} ...
78+
:warning: This deployment will be deleted when the PR is closed.
79+
80+
build:
81+
needs: pr_commented
82+
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
83+
env:
84+
DOCKER_CLI_EXPERIMENTAL: "enabled"
85+
CODER_IMAGE_TAG: ${{ needs.pr_commented.outputs.coder_image_tag }}
86+
PR_NUMBER: ${{ needs.pr_commented.outputs.pr_number }}
87+
steps:
88+
- uses: actions/checkout@v3
89+
with:
90+
fetch-depth: 0
91+
92+
- uses: ./.github/actions/setup-go
93+
94+
- uses: ./.github/actions/setup-node
95+
96+
- name: Install sqlc
97+
run: |
98+
curl -sSL https://github.com/kyleconroy/sqlc/releases/download/v1.18.0/sqlc_1.18.0_linux_amd64.tar.gz | sudo tar -C /usr/bin -xz sqlc
99+
100+
- name: GHCR Login
101+
uses: docker/login-action@v2
102+
with:
103+
registry: ghcr.io
104+
username: ${{ github.actor }}
105+
password: ${{ secrets.GITHUB_TOKEN }}
106+
107+
- name: Build and push Linux amd64 Docker image
108+
run: |
109+
set -euxo pipefail
110+
go mod download
111+
make gen/mark-fresh
112+
export DOCKER_IMAGE_NO_PREREQUISITES=true
113+
version="$(./scripts/version.sh)"
114+
export CODER_IMAGE_BUILD_BASE_TAG="$(CODER_IMAGE_BASE=coder-base ./scripts/image_tag.sh --version "$version")"
115+
make -j build/coder_linux_amd64
116+
./scripts/build_docker.sh \
117+
--arch amd64 \
118+
--target ${{ env.CODER_IMAGE_TAG }} \
119+
--version $version \
120+
--push \
121+
build/coder_linux_amd64
122+
123+
deploy:
124+
needs: [build, pr_commented]
125+
if: needs.build.result == 'success'
126+
runs-on: "ubuntu-latest"
127+
env:
128+
CODER_IMAGE_TAG: ${{ needs.pr_commented.outputs.CODER_IMAGE_TAG }}
129+
PR_NUMBER: ${{ needs.pr_commented.outputs.PR_NUMBER }}
130+
PR_TITLE: ${{ needs.pr_commented.outputs.PR_TITLE }}
131+
PR_URL: ${{ needs.pr_commented.outputs.PR_URL }}
132+
steps:
133+
- uses: actions/checkout@v3
134+
135+
- name: "Set up kubeconfig"
136+
run: |
137+
set -euxo pipefail
138+
mkdir -p ~/.kube
139+
echo "${{ secrets.DELIVERYBOT_KUBECONFIG }}" > ~/.kube/config
140+
export KUBECONFIG=~/.kube/config
141+
142+
- name: "Create PR namespace"
143+
run: |
144+
set -euxo pipefail
145+
# try to delete the namespace, but don't fail if it doesn't exist
146+
kubectl delete namespace "pr${{ env.PR_NUMBER }}" || true
147+
kubectl create namespace "pr${{ env.PR_NUMBER }}"
148+
149+
- name: "Install Helm chart"
150+
run: |
151+
helm upgrade --install pr${{ env.PR_NUMBER }} ./helm \
152+
--namespace "pr${{ env.PR_NUMBER }}" \
153+
--set coder.image.repo=${{ env.REPO }} \
154+
--set coder.image.tag=pr${{ env.PR_NUMBER }} \
155+
--set coder.service.type=ClusterIP \
156+
--set coder.env[0].name=CODER_ACCESS_URL \
157+
--set coder.env[0].value="" \
158+
--force
159+
160+
- name: "Get deployment URL"
161+
id: deployment_url
162+
run: |
163+
set -euo pipefail
164+
kubectl rollout status deployment/coder --namespace "pr${{ env.PR_NUMBER }}"
165+
POD_NAME=$(kubectl get pods -n "pr${{ env.PR_NUMBER }}" | awk 'NR==2{print $1}')
166+
CODER_ACCESS_URL=$(kubectl logs $POD_NAME -n "pr${{ env.PR_NUMBER }}" | grep "Web UI:" | awk -F ':' '{print $2":"$3}' | awk '{$1=$1};1')
167+
echo "::add-mask::$CODER_ACCESS_URL"
168+
echo "CODER_ACCESS_URL=$CODER_ACCESS_URL" >> $GITHUB_OUTPUT
169+
170+
- name: Send Slack notification
171+
run: |
172+
curl -s -o /dev/null -X POST -H 'Content-type: application/json' \
173+
-d '{
174+
"pr_number": "'"${{ env.PR_NUMBER }}"'",
175+
"pr_url": "'"${{ env.PR_URL }}"'",
176+
"pr_title": "'"${{ env.PR_TITLE }}"'",
177+
"pr_access_url": "'"${{ steps.deployment_url.outputs.CODER_ACCESS_URL }}"'" }' ${{ secrets.PR_DEPLOYMENTS_SLACK_WEBHOOK }}
178+
echo "Slack notification sent"
179+
180+
- name: Comment on PR
181+
uses: peter-evans/create-or-update-comment@v3
182+
with:
183+
issue-number: ${{ env.PR_NUMBER }}
184+
edit-mode: replace
185+
comment-id: ${{ needs.pr_commented.outputs.COMMENT_ID }}
186+
body: |
187+
:heavy_check_mark: Deployed PR ${{ env.PR_NUMBER }} successfully.
188+
:rocket: Access the deployment link [here](https://codercom.slack.com/archives/C05DNE982E8).
189+
:warning: This deployment will be deleted when the PR is closed.
190+
reactions: "+1"

.github/workflows/security.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ jobs:
7575
7676
- name: Install sqlc
7777
run: |
78-
curl -sSL https://github.com/kyleconroy/sqlc/releases/download/v1.17.2/sqlc_1.17.2_linux_amd64.tar.gz | sudo tar -C /usr/bin -xz sqlc
78+
curl -sSL https://github.com/kyleconroy/sqlc/releases/download/v1.18.0/sqlc_1.18.0_linux_amd64.tar.gz | sudo tar -C /usr/bin -xz sqlc
7979
- name: Install yq
8080
run: go run github.com/mikefarah/yq/v4@v4.30.6
8181
- name: Install mockgen

.github/workflows/stale.yaml

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Stale Issue and Branch Cleanup
1+
name: Stale Issue, Banch and Old Workflows Cleanup
22
on:
33
schedule:
44
# Every day at midnight
@@ -10,6 +10,7 @@ jobs:
1010
permissions:
1111
issues: write
1212
pull-requests: write
13+
actions: write
1314
steps:
1415
- uses: actions/stale@v8.0.0
1516
with:
@@ -42,3 +43,14 @@ jobs:
4243
delete_tags: false
4344
# extra_protected_branch_regex: ^(foo|bar)$
4445
exclude_open_pr_branches: true
46+
del_runs:
47+
runs-on: ubuntu-latest
48+
steps:
49+
- name: Delete workflow runs
50+
uses: Mattraks/delete-workflow-runs@v2
51+
with:
52+
token: ${{ github.token }}
53+
repository: ${{ github.repository }}
54+
retain_days: 1
55+
keep_minimum_runs: 1
56+
delete_workflow_pattern: pr-cleanup.yaml

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ site/storybook-static/
2727
site/test-results/*
2828
site/e2e/test-results/*
2929
site/e2e/states/*.json
30+
site/e2e/.auth.json
3031
site/playwright-report/*
3132
site/.swc
3233
site/dist/

.prettierignore

+4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ site/storybook-static/
3030
site/test-results/*
3131
site/e2e/test-results/*
3232
site/e2e/states/*.json
33+
site/e2e/.auth.json
3334
site/playwright-report/*
3435
site/.swc
3536
site/dist/
@@ -74,3 +75,6 @@ helm/templates/*.yaml
7475

7576
# Testdata shouldn't be formatted.
7677
scripts/apitypings/testdata/**/*.ts
78+
79+
# Generated files shouldn't be formatted.
80+
site/e2e/provisionerGenerated.ts

.prettierignore.include

+3
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ helm/templates/*.yaml
88

99
# Testdata shouldn't be formatted.
1010
scripts/apitypings/testdata/**/*.ts
11+
12+
# Generated files shouldn't be formatted.
13+
site/e2e/provisionerGenerated.ts

0 commit comments

Comments
 (0)