Skip to content

Commit 4f07c3e

Browse files
committed
Merge branch 'main' into projectversionresources
2 parents c07224e + 7851067 commit 4f07c3e

File tree

7 files changed

+527
-400
lines changed

7 files changed

+527
-400
lines changed

.github/workflows/coder.yaml

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,9 @@ jobs:
8888
- run: "make --output-sync -j gen"
8989
- run: ./scripts/check_unstaged.sh
9090

91-
style:
92-
name: "style/${{ matrix.style }}"
91+
style-fmt:
92+
name: "style/fmt"
9393
runs-on: ubuntu-latest
94-
strategy:
95-
matrix:
96-
style:
97-
- fmt
98-
fail-fast: false
9994
steps:
10095
- name: Checkout
10196
uses: actions/checkout@v2
@@ -116,8 +111,8 @@ jobs:
116111
run: yarn install
117112
working-directory: site
118113

119-
- name: "make ${{ matrix.style }}"
120-
run: "make --output-sync -j ${{ matrix.style }}"
114+
- name: "make fmt"
115+
run: "make --output-sync -j fmt"
121116

122117
test-go:
123118
name: "test/go"
@@ -189,6 +184,46 @@ jobs:
189184
flags: unittest-go-${{ matrix.os }}
190185
fail_ci_if_error: true
191186

187+
deploy:
188+
name: "deploy"
189+
runs-on: ubuntu-latest
190+
if: github.event_name != 'pull_request'
191+
permissions:
192+
contents: read
193+
id-token: write
194+
steps:
195+
- uses: actions/checkout@v2
196+
197+
- name: Authenticate to Google Cloud
198+
uses: google-github-actions/auth@v0
199+
with:
200+
workload_identity_provider: projects/477254869654/locations/global/workloadIdentityPools/github/providers/github
201+
service_account: github-coder@coder-ci.iam.gserviceaccount.com
202+
203+
- name: Set up Google Cloud SDK
204+
uses: google-github-actions/setup-gcloud@v0
205+
206+
- name: Configure Docker for Google Artifact Registry
207+
run: gcloud auth configure-docker us-docker.pkg.dev
208+
209+
- uses: actions/setup-node@v2
210+
with:
211+
node-version: "14"
212+
213+
- run: yarn install
214+
working-directory: site
215+
216+
- uses: actions/setup-go@v2
217+
with:
218+
go-version: "^1.17"
219+
220+
- run: make docker/image/coder
221+
222+
- run: docker push us-docker.pkg.dev/coder-blacktriangle-dev/ci/coder:latest
223+
224+
- name: Update coder service
225+
run: gcloud run services update coder --image us-docker.pkg.dev/coder-blacktriangle-dev/ci/coder:latest --project coder-blacktriangle-dev --region us-central1
226+
192227
test-js:
193228
name: "test/js"
194229
runs-on: ubuntu-latest

Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@ bin/coderd:
33
go build -o bin/coderd cmd/coderd/main.go
44
.PHONY: bin/coderd
55

6-
bin/provisionerd:
7-
mkdir -p bin
8-
go build -o bin/provisionerd cmd/provisionerd/main.go
9-
.PHONY: bin/provisionerd
10-
11-
build: site/out bin/coderd bin/provisionerd
6+
build: site/out bin/coderd
127
.PHONY: build
138

149
# Runs migrations to output a dump of the database.
@@ -22,6 +17,11 @@ database/generate: fmt/sql database/dump.sql database/query.sql
2217
cd database && gofmt -w -r 'Queries -> sqlQuerier' *.go
2318
.PHONY: database/generate
2419

20+
docker/image/coder: build
21+
cp ./images/coder/run.sh ./bin
22+
docker build --network=host -t us-docker.pkg.dev/coder-blacktriangle-dev/ci/coder:latest -f images/coder/Dockerfile ./bin
23+
.PHONY: docker/build
24+
2525
fmt/prettier:
2626
@echo "--- prettier"
2727
# Avoid writing files in CI to reduce file write activity

coderd/provisionerdaemons.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,8 @@ func (server *provisionerdServer) UpdateJob(stream proto.DRPCProvisionerDaemon_U
310310
insertParams.Source = append(insertParams.Source, logSource)
311311
insertParams.Output = append(insertParams.Output, log.Output)
312312
}
313-
logs, err := server.Database.InsertProvisionerJobLogs(stream.Context(), insertParams)
313+
logs, err := server.Database.InsertProvisionerJobLogs(context.Background(), insertParams)
314314
if err != nil {
315-
server.Logger.Error(stream.Context(), "insert provisioner job logs", slog.Error(err))
316315
return xerrors.Errorf("insert job logs: %w", err)
317316
}
318317
data, err := json.Marshal(logs)

images/coder/Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM registry.access.redhat.com/ubi8/ubi:latest
2+
3+
COPY coderd /coder/coderd
4+
RUN chmod +x /coder/coderd
5+
6+
COPY run.sh /coder/run.sh
7+
RUN chmod +x /coder/run.sh
8+
9+
# Once `provisionerd` is available, we'll also need that binary
10+
# COPY bin/provisionerd /provisionerd
11+
# RUN chmod +x /provisionerd
12+
13+
ENTRYPOINT ["/coder/run.sh"]

images/coder/run.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
EMAIL=${EMAIL:-admin@coder.com}
6+
USERNAME=${USERNAME:-admin}
7+
ORGANIZATION=${ORGANIZATION:-ACME-Corp}
8+
PASSWORD=${PASSWORD:-password}
9+
PORT=${PORT:-8000}
10+
11+
# Helper to create an initial user
12+
function create_initial_user() {
13+
# TODO: We need to wait for `coderd` to spin up -
14+
# need to replace with a deterministic strategy
15+
sleep 5s
16+
17+
curl -X POST \
18+
-d '{"email": "'"$EMAIL"'", "username": "'"$USERNAME"'", "organization": "'"$ORGANIZATION"'", "password": "'"$PASSWORD"'"}' \
19+
-H 'Content-Type:application/json' \
20+
"http://localhost:$PORT/api/v2/user"
21+
}
22+
23+
# This is a way to run multiple processes in parallel, and have Ctrl-C work correctly
24+
# to kill both at the same time. For more details, see:
25+
# https://stackoverflow.com/questions/3004811/how-do-you-run-multiple-programs-in-parallel-from-a-bash-script
26+
(
27+
trap 'kill 0' SIGINT
28+
create_initial_user &
29+
/coder/coderd --address=":$PORT"
30+
)

site/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"@react-theming/storybook-addon": "1.1.5",
2525
"@storybook/addon-actions": "6.3.12",
2626
"@storybook/addon-essentials": "6.4.18",
27-
"@storybook/addon-links": "6.3.12",
27+
"@storybook/addon-links": "6.4.18",
2828
"@storybook/react": "6.4.18",
2929
"@testing-library/react": "12.1.2",
3030
"@types/express": "4.17.13",
@@ -49,7 +49,7 @@
4949
"express": "4.17.2",
5050
"formik": "2.2.9",
5151
"http-proxy-middleware": "2.0.2",
52-
"jest": "27.4.7",
52+
"jest": "27.5.0",
5353
"jest-runner-eslint": "1.0.0",
5454
"next": "12.0.10",
5555
"next-router-mock": "^0.6.5",
@@ -60,7 +60,7 @@
6060
"swr": "1.2.1",
6161
"ts-jest": "27.1.3",
6262
"ts-loader": "9.2.6",
63-
"ts-node": "10.4.0",
63+
"ts-node": "10.5.0",
6464
"typescript": "4.5.5",
6565
"yup": "0.32.11"
6666
},

0 commit comments

Comments
 (0)