-
Notifications
You must be signed in to change notification settings - Fork 24
233 lines (196 loc) · 7.09 KB
/
ci.yml
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
name: ci
on:
push:
branches:
- '*'
pull_request:
branches:
- master
jobs:
test:
runs-on: ubuntu-22.04
services:
rabbitmq:
image: rabbitmq
ports:
- 5672:5672
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 50
- id: changed-files
name: Check changed files
run: python3 ci/check-changed-files.py | bash
- name: Set up JDK
if: steps.changed-files.outputs.gradle == '1'
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'
cache: 'gradle'
- name: Test judgels-commons
if: steps.changed-files.outputs.judgels-commons == '1'
run: ./judgels-backends/gradlew -p judgels-backends/judgels-commons check
- name: Test judgels-grader-api
if: steps.changed-files.outputs.judgels-grader == '1'
run: ./judgels-backends/gradlew -p judgels-backends/judgels-grader-api check
- name: Test judgels-grader-engines
if: steps.changed-files.outputs.judgels-grader == '1'
run: ./judgels-backends/gradlew -p judgels-backends/judgels-grader-engines check
- name: Test judgels-grader-app
if: steps.changed-files.outputs.judgels-grader == '1'
run: ./judgels-backends/gradlew -p judgels-backends/judgels-grader-app check
- name: Test judgels-server-api
if: steps.changed-files.outputs.judgels-server == '1'
run: ./judgels-backends/gradlew -p judgels-backends/judgels-server-api check
- name: Test judgels-server-app
if: steps.changed-files.outputs.judgels-server == '1'
run: ./judgels-backends/gradlew -p judgels-backends/judgels-server-app check
- name: Set up node
if: steps.changed-files.outputs.yarn == '1'
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Get yarn cache directory path
if: steps.changed-files.outputs.yarn == '1'
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: Use yarn cache
if: steps.changed-files.outputs.yarn == '1'
uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Test judgels-client
if: steps.changed-files.outputs.judgels-client == '1'
run: |
cd judgels-client
export NODE_OPTIONS="--max-old-space-size=4096"
yarn install
yarn ci
build:
needs: test
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-22.04
env:
CONTAINER_REGISTRY_USERNAME: ${{ secrets.CONTAINER_REGISTRY_USERNAME }}
CONTAINER_REGISTRY_TOKEN: ${{ secrets.CONTAINER_REGISTRY_TOKEN }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 50
- name: Install docker for ansible
run: |
ansible-galaxy collection install community.docker:3.4.5
pipx inject ansible-core docker six
- id: changed-files
name: Check changed files
run: python3 ci/check-changed-files.py | bash
- name: Set up JDK
if: steps.changed-files.outputs.gradle == '1'
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'
cache: 'gradle'
- name: Set up node
if: steps.changed-files.outputs.yarn == '1'
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Get yarn cache directory path
if: steps.changed-files.outputs.yarn == '1'
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: Use yarn cache
if: steps.changed-files.outputs.yarn == '1'
uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Build judgels-server
if: steps.changed-files.outputs.judgels-server == '1'
run: ./deployment/scripts/build_judgels_server.sh
- name: Build judgels-client
if: steps.changed-files.outputs.judgels-client == '1'
run: ./deployment/scripts/build_judgels_client.sh
- name: Build judgels-grader
if: steps.changed-files.outputs.judgels-grader == '1'
run: ./deployment/scripts/build_judgels_grader.sh
deploy-web:
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-22.04
env:
WEB_HOST: ${{ secrets.WEB_HOST }}
WEB_KNOWN_HOSTS: ${{ secrets.WEB_KNOWN_HOSTS }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 50
- id: changed-files
name: Check changed files
run: python3 ci/check-changed-files.py | bash
- name: Set up node
if: steps.changed-files.outputs.web == '1'
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Build web
if: steps.changed-files.outputs.web == '1'
run: |
cd web
yarn install
yarn build
- name: Install SSH key
if: steps.changed-files.outputs.web == '1'
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.WEB_PRIVATE_KEY }}
known_hosts: ${{ secrets.WEB_KNOWN_HOSTS }}
- name: Rsync web
if: steps.changed-files.outputs.web == '1'
run: rsync -avzh web/build/ root@${WEB_HOST}:/var/www/html/judgels --delete
deploy-tlx-staging:
needs: build
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 50
- name: Check out deployment repository
uses: actions/checkout@v3
with:
repository: ${{ secrets.TLX_STAGING_DEPLOYMENT_REPOSITORY }}
token: ${{ secrets.TLX_STAGING_DEPLOYMENT_TOKEN }}
path: deployment/ansible/env
- name: Prepare staging environment SSH key
run: chmod 600 deployment/ansible/env/deployment_rsa
- id: changed-files
name: Check changed files
run: python3 ci/check-changed-files.py | bash
- name: Deploy judgels-server
if: steps.changed-files.outputs.judgels-server == '1'
run: |
eval "$(ssh-agent -s)"
ssh-add deployment/ansible/env/deployment_rsa
./deployment/scripts/deploy_judgels_server.sh
- name: Deploy judgels-client
if: steps.changed-files.outputs.judgels-client == '1'
run: |
eval "$(ssh-agent -s)"
ssh-add deployment/ansible/env/deployment_rsa
./deployment/scripts/deploy_judgels_client.sh
- name: Deploy judgels-grader
if: steps.changed-files.outputs.judgels-grader == '1'
run: |
eval "$(ssh-agent -s)"
ssh-add deployment/ansible/env/deployment_rsa
./deployment/scripts/deploy_judgels_grader.sh