-
Notifications
You must be signed in to change notification settings - Fork 2
210 lines (205 loc) · 7.33 KB
/
ci.yml
File metadata and controls
210 lines (205 loc) · 7.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# This file was generated by ci/generate and should not be modified by hand
---
name: Validate everything
'on':
push:
pull_request_target:
types:
- labeled
branches:
- main
env:
DOCKER_HUB_USERNAME: javaplayground
GH_CONTAINER_REGISTRY_USERNAME: bowbahdoe
AWS_ACCESS_KEY_ID: AKIAWESVHZ3JQAY5NM5K
jobs:
build_compiler_containers:
name: Build ${{ matrix.runtime }} container
runs-on: ubuntu-latest
strategy:
matrix:
include:
- runtime: latest
TARGZ_URL: https://download.java.net/java/GA/jdk25/bd75d5f9689641da8e1daabeccb5528b/35/GPL/openjdk-25_linux-x64_bin.tar.gz
TARGZ_SHA: c00224c25b0b915f4d69929d90e59dfd66e949f79f7437d334248f7789b646f4
TARGZ_FOLDER: jdk-25
- runtime: valhalla
TARGZ_URL: https://download.java.net/java/early_access/valhalla/26/1/openjdk-26-jep401ea2+1-1_linux-x64_bin.tar.gz
TARGZ_SHA: 27d12e7ed51b0a9e94c6356adb4c42a50a8861031e1bc833b3f6b7a3212bed55
TARGZ_FOLDER: jdk-26
- runtime: early_access
TARGZ_URL: https://download.java.net/java/early_access/jdk26/10/GPL/openjdk-26-ea+10_linux-x64_bin.tar.gz
TARGZ_SHA: '09044ebef2f1122e484e84df3a95605462c66caf6fb6363a6b3bb70cb6dba3db'
TARGZ_FOLDER: jdk-26
if: 'github.event_name == ''push'' || contains(github.event.pull_request.labels.*.name, ''CI: approved'')'
env:
IMAGE_NAME: ghcr.io/bowbahdoe/run-java-code-ci-${{ matrix.runtime }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: "${{ github.event.pull_request.head.sha }}"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
driver-opts: image=moby/buildkit:v0.11.6
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: "${{ github.actor }}"
password: "${{ secrets.GITHUB_TOKEN }}"
- name: Build and push container
uses: docker/build-push-action@v4
with:
context: compiler/base/
file: compiler/base/Dockerfile
build-args: |-
TARGZ_URL=${{ matrix.TARGZ_URL }}
TARGZ_SHA=${{ matrix.TARGZ_SHA }}
TARGZ_FOLDER=${{ matrix.TARGZ_FOLDER }}
pull: true
push: true
tags: "${{ env.IMAGE_NAME }}:${{ github.run_id }}"
build_backend:
name: Build backend
runs-on: ubuntu-latest
if: 'github.event_name == ''push'' || contains(github.event.pull_request.labels.*.name, ''CI: approved'')'
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: "${{ github.event.pull_request.head.sha }}"
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Cache Cargo intermediate products
uses: actions/cache@v3
with:
path: |-
~/.cargo/registry
~/.cargo/git
ui/target
key: "${{ runner.os }}-cargo-${{ hashFiles('ui/**/Cargo.lock') }}-2"
- name: Format server
run: cargo fmt --manifest-path ui/Cargo.toml --all --check
- name: Build backend
run: |-
mkdir -p ui/target; docker run --rm -v $PWD/ui:/ui -v ~/.cargo/git:/root/.cargo/git -v ~/.cargo/registry:/root/.cargo/registry --workdir /ui rust:alpine sh -c '
apk add musl-dev openssl-dev openssl-libs-static
# Adding -C relocation-model=static due to
# https://github.com/rust-lang/rust/issues/95926
# Adding this to find the statically-built version
export OPENSSL_NO_PKG_CONFIG=1 OPENSSL_STATIC=1 OPENSSL_DIR=/usr/
# Unit tests
cargo rustc --tests --locked -- -C relocation-model=static;
test_bin=$(find target/debug/deps/ -name "ui*" -type f -perm -a=x);
mv "${test_bin}" target/unit_tests;
# Primary binary
cargo rustc --locked --release -- -C relocation-model=static;
mv target/release/ui target/ui;
'
- name: Restore permissions
run: sudo chown -R runner:docker ~/.cargo/ ui/target
- name: Save backend artifact
uses: actions/upload-artifact@v4
with:
name: backend
path: |
ui/target/ui
ui/target/unit_tests
build_frontend:
name: Build frontend
runs-on: ubuntu-latest
if: 'github.event_name == ''push'' || contains(github.event.pull_request.labels.*.name, ''CI: approved'')'
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: "${{ github.event.pull_request.head.sha }}"
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: Cache yarn intermediate products
uses: actions/cache@v3
with:
path: "${{ steps.yarn-cache-dir-path.outputs.dir }}"
key: "${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}"
restore-keys: "${{ runner.os }}-yarn-"
- name: Configure node
uses: actions/setup-node@v3
with:
node-version: 18.14
- name: Install dependencies
run: yarn --cwd ui/frontend/
- name: Run tests
run: yarn --cwd ui/frontend/ test
- name: Lint
run: yarn --cwd ui/frontend/ test:lint
- name: Style
run: yarn --cwd ui/frontend/ test:style
- name: Build frontend
run: yarn --cwd ui/frontend/ run build:production
- name: Save frontend artifact
uses: actions/upload-artifact@v4
with:
name: frontend
path: ui/frontend/build
release_artifacts:
name: Release artifacts
runs-on: ubuntu-latest
needs:
- build_compiler_containers
- build_backend
- build_frontend
if: github.event_name == 'push' && github.event.ref == 'refs/heads/main'
permissions:
contents: read
id-token: write
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: "${{ github.actor }}"
password: "${{ secrets.GITHUB_TOKEN }}"
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: "${{ env.DOCKER_HUB_USERNAME }}"
password: "${{ secrets.DOCKER_HUB_TOKEN }}"
- name: Pull containers
run: |-
for c in latest early_access valhalla; do
docker pull ghcr.io/bowbahdoe/run-java-code-ci-$c:${{ github.run_id }}
done
- name: Rename containers
run: |-
for c in latest early_access valhalla; do
docker tag ghcr.io/bowbahdoe/run-java-code-ci-$c:${{ github.run_id }} javaplayground/$c
done
- name: Push containers
run: |-
for c in latest early_access valhalla; do
docker push javaplayground/$c
done
- name: Download backend
uses: actions/download-artifact@v4
with:
name: backend
path: server/
- name: Download frontend
uses: actions/download-artifact@v4
with:
name: frontend
path: server/build/
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::762254388821:role/java-playground-github-actions-role
aws-region: us-east-2
- name: Push backend
run: aws s3 cp server/ui s3://java-playground-artifacts
- name: Push frontend
run: aws s3 sync server/build/ s3://java-playground-artifacts/build