forked from omegaup/omegaup
-
Notifications
You must be signed in to change notification settings - Fork 0
293 lines (242 loc) · 8.53 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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
name: CI
on:
pull_request: {}
push:
branches:
- master
jobs:
php:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0
ports:
- 3306:3306
env:
MYSQL_ROOT_PASSWORD:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_USER: omegaup
MYSQL_PASSWORD: omegaup
MYSQL_DATABASE: omegaup-test
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Download gitserver
run: |
DOWNLOAD_URL='https://github.com/omegaup/gitserver/releases/download/v1.4.16/omegaup-gitserver.tar.xz'
curl --location "${DOWNLOAD_URL}" | sudo tar -xJv -C /
# omegaup-gitserver depends on libinteractive.
DOWNLOAD_URL='https://github.com/omegaup/libinteractive/releases/download/v2.0.27/libinteractive.jar'
TARGET='/usr/share/java/libinteractive.jar'
sudo curl --location "${DOWNLOAD_URL}" -o "${TARGET}"
- name: Install Python dependencies
run: |
python3 -m pip install --user setuptools
python3 -m pip install --user wheel
python3 -m pip install --user \
mysqlclient==2.0.1
- name: Validate composer.json and composer.lock
run: composer validate
- name: Install composer dependencies
run: composer install --prefer-dist --no-progress
- name: Create database users
run: |
mysql \
-uroot --skip-password --protocol=TCP \
-e 'CREATE USER "omegaup"@"localhost" IDENTIFIED BY "omegaup";'
- name: Validate database migration scripts
run: python3 stuff/db-migrate.py validate
- name: Create test database
run: |
python3 stuff/db-migrate.py \
--username=root --password= --hostname=localhost \
migrate --databases=omegaup-test
- name: Validate database schema
run: |
python3 stuff/policy-tool.py \
--username=root --password= --hostname=localhost --database=omegaup-test \
validate
python3 stuff/database_schema.py \
--username=root --password= --hostname=localhost --database=omegaup-test \
validate --all < /dev/null
- name: Run tests
timeout-minutes: 20
run: ./stuff/mysql_types.sh
- name: Run Psalm
run: |
# Create optional directories to simplify psalm config.
mkdir -p frontend/www/{phpminiadmin,preguntas}
touch 'frontend/server/config.php'
touch 'frontend/tests/test_config.php'
./vendor/bin/psalm \
--output-format=github \
--long-progress \
--show-info=false
- name: Upload code coverage
run: bash <(curl -s https://codecov.io/bash) -cF php
- name: Upload artifacts
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: test-logs
path: frontend/tests/runfiles/*/*.log
javascript:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Install yarn dependencies
run: yarn install
- name: Run JavaScript tests
run: yarn test:coverage
- name: Upload code coverage
run: |
bash <(curl -s https://codecov.io/bash) -cF javascript
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Install yarn dependencies
run: yarn install
- name: Install composer dependencies
run: composer install --prefer-dist --no-progress
- name: Get docker container
run: docker pull "$(grep --only-matching 'omegaup/hook_tools:\w\+' stuff/lint.sh)"
- name: Run linters
run: |
# Create optional directories to simplify psalm config.
mkdir -p frontend/www/{phpminiadmin,preguntas}
touch 'frontend/server/config.php'
touch 'frontend/tests/test_config.php'
./stuff/lint.sh --diagnostics-output=github validate --all < /dev/null
- name: Run Psalm
run: |
./vendor/bin/psalm \
--output-format=github \
--long-progress \
--show-info=false
- name: Find unused translation strings
run: ./stuff/unused_translation_strings.py
selenium:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0
ports:
- 3306:3306
env:
MYSQL_ROOT_PASSWORD:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_USER: omegaup
MYSQL_PASSWORD: omegaup
MYSQL_DATABASE: omegaup
frontend:
image: omegaup/dev-php:20200930
ports:
- 8001:8001
volumes:
- ${{ github.workspace }}:/opt/omegaup
- omegaupdata:/var/lib/omegaup
env:
CI: true
gitserver:
image: omegaup/dev-gitserver:20200930
volumes:
- omegaupdata:/var/lib/omegaup
broadcaster:
image: omegaup/dev-broadcaster:20200808
grader:
image: omegaup/dev-grader:20200808
volumes:
- omegaupdata:/var/lib/omegaup
runner:
image: omegaup/dev-runner:20200808
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Create default configuration files
run: |
cat > frontend/server/config.php <<EOF
<?php
define('OMEGAUP_ALLOW_PRIVILEGE_SELF_ASSIGNMENT', true);
define('OMEGAUP_CSP_LOG_FILE', '/tmp/csp.log');
define('OMEGAUP_DB_HOST', 'mysql');
define('OMEGAUP_DB_NAME', 'omegaup');
define('OMEGAUP_DB_PASS', 'omegaup');
define('OMEGAUP_DB_USER', 'omegaup');
define('OMEGAUP_ENVIRONMENT', 'development');
define('OMEGAUP_LOG_FILE', '/tmp/omegaup.log');
define('OMEGAUP_ENABLE_SOCIAL_MEDIA_RESOURCES', false);
define('SMARTY_CACHE_DIR', '/tmp');
define('OMEGAUP_CACERT_URL', '/etc/omegaup/frontend/certificate.pem');
define('OMEGAUP_SSLCERT_URL', '/etc/omegaup/frontend/certificate.pem');
define('OMEGAUP_GITSERVER_URL', 'http://gitserver:33861');
define('OMEGAUP_GRADER_URL', 'https://grader:21680');
define('OMEGAUP_GITSERVER_SECRET_TOKEN', 'secret');
EOF
cat > ~/.my.cnf << EOF
[client]
port=3306
host=127.0.0.1
protocol=tcp
user=root
password=
EOF
- name: Install Python dependencies
run: |
python3 -m pip install --user setuptools
python3 -m pip install --user wheel
python3 -m pip install --user --upgrade urllib3
python3 -m pip install --user \
mysqlclient==2.0.1 \
selenium \
pytest \
pytest-xdist \
flaky
- name: Install composer dependencies
run: composer install --prefer-dist --no-progress
- name: Initialize database
run: |
mysql \
-e 'CREATE USER "omegaup"@"localhost" IDENTIFIED BY "omegaup";'
# Create directory to prevent --purge from failing.
sudo mkdir -p /var/lib/omegaup
sudo chown "$(id -u)":"$(id -g)" /var/lib/omegaup
python3 stuff/bootstrap-environment.py --purge --verbose
- name: Install yarn dependencies
run: yarn install
- name: Build webpack resources
run: yarn build
- name: Run Selenium tests
run: |
python3 -m pytest ./frontend/tests/ui/ \
--verbose --capture=no --log-cli-level=INFO --browser=chrome \
--force-flaky --max-runs=2 --min-passes=1 --numprocesses=4
- name: Collect container logs
if: ${{ always() }}
run: |
mkdir -p frontend/tests/runfiles/containers
for name in $(docker ps --format '{{.Names}}'); do
docker logs --timestamps --since 1970-01-01T00:00:00 "${name}" > \
"frontend/tests/runfiles/containers/${name}.log" 2>&1
done
- name: Upload artifacts
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: test-logs
path: frontend/tests/ui/results/
- name: Upload artifacts
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: test-logs
path: frontend/tests/runfiles/*/*.log