-
Notifications
You must be signed in to change notification settings - Fork 412
317 lines (257 loc) · 9.13 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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
name: CI
on:
push:
branches:
- master
- '*.x'
pull_request:
branches:
- master
- '*.x'
jobs:
setup:
name: setup-${{ matrix.name }}
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
include:
- { name: '3.9', python: '3.9', tox: py39 }
- { name: '3.10', python: '3.10', tox: py310 }
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
id: cache-npm
with:
path: node_modules
key: ${{ runner.os }}-npm-${{ hashFiles('package*.json') }}
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: Setup Node
uses: actions/setup-node@v3
if: steps.cache-npm.outputs.cache-hit != 'true'
with:
node-version: 14.x
- name: Install system dependencies
run: sudo apt-get install libpq-dev
- name: Create virtualenv
run: |
python${{ matrix.python }} -m venv .venv
source .venv/bin/activate
pip install -U pip setuptools wheel
- name: Activate virtualenv for later steps
run: |
echo "VIRTUAL_ENV=$(pwd)/.venv" >> $GITHUB_ENV
echo "$(pwd)/.venv/bin" >> $GITHUB_PATH
- name: Get pip cache dir
id: pip-cache
run: echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: Cache pip
uses: actions/cache@v3
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: pip|${{ runner.os }}|${{ matrix.python }}|${{ hashFiles('requirements*.txt') }}
- name: Install python dependencies
run: |
pip install -r requirements.dev.txt
pip install -r requirements.txt
- name: Install node dependencies
if: steps.cache-npm.outputs.cache-hit != 'true'
run: npm ci
- name: Archive environment
run: tar cf /tmp/env.tar .venv node_modules
- name: Upload environment
uses: actions/upload-artifact@v3
with:
name: environment-${{ matrix.name }}
retention-days: 1
path: /tmp/env.tar
lint:
needs: setup
runs-on: ubuntu-20.04
steps:
# BEGIN common steps - edit all occurrences if needed!
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 14.x
- name: Download environment
uses: actions/download-artifact@v3
with:
name: environment-3.10
path: /tmp
- name: Restore environment
run: tar xf /tmp/env.tar
- name: Activate virtualenv for later steps
run: |
echo "VIRTUAL_ENV=$(pwd)/.venv" >> $GITHUB_ENV
echo "$(pwd)/.venv/bin" >> $GITHUB_PATH
- name: Install Indico
run: pip install -e .
# END common steps
- name: Check import sorting
run: isort --diff --check-only indico/
- name: Check backref comments
if: success() || failure()
run: python bin/maintenance/update_backrefs.py --ci
- name: Check headers
if: success() || failure()
run: |
echo "::add-matcher::.github/matchers/headers-problem-matcher.json"
python bin/maintenance/update_header.py --ci
echo "::remove-matcher owner=headers::"
- name: Run flake8
if: success() || failure()
run: |
echo "::add-matcher::.github/matchers/flake8-problem-matcher.json"
flake8 --format '%(path)s:%(row)d:%(col)d: %(code)s %(text)s'
echo "::remove-matcher owner=flake8::"
- name: Run pyquotes
if: success() || failure()
run: pyquotes --check .
- name: Try extracting i18n strings (Python)
if: success() || failure()
run: indico i18n extract-messages
- name: Try extracting i18n strings (JS)
if: success() || failure()
run: |
echo "::add-matcher::.github/matchers/react-jsx-i18n-problem-matcher.json"
FORCE_COLOR=1 npx react-jsx-i18n extract --ext jsx indico/web/client/ indico/modules/ > /dev/null
echo "::remove-matcher owner=react-jsx-i18n::"
- name: Check i18n format strings
if: success() || failure()
run: indico i18n check-format-strings
- name: Run eslint
if: success() || failure()
run: npx eslint --ext .js --ext .jsx
indico/modules/rb/
indico/modules/logs/
indico/modules/events/editing/
indico/modules/events/client/js/reviewing/
indico/modules/events/papers/client/js/
indico/modules/events/registration/client/js/
indico/web/client/js/react/
indico/modules/users/
indico/modules/search/
- name: Run stylelint for all files
if: github.event_name == 'push' && (success() || failure())
run: |
echo "::add-matcher::.github/matchers/stylelint-problem-matcher.json"
npx stylelint --formatter unix 'indico/**/*.{scss,css}'
echo "::remove-matcher owner=stylelint::"
# GitHub shows annotations for files not touched in the PR, which is very noisy in case
# of stylelint warnings, so we only run it for changed files when running on PRs
# https://github.com/actions/toolkit/issues/457
- name: Get list of changed files
if: github.event_name == 'pull_request' && (success() || failure())
uses: umani/changed-files@v4.0.1
with:
repo-token: ${{ github.token }}
result-encoding: json
pattern: '^.+\.s?css$'
- name: Run stylelint for changed files
if: github.event_name == 'pull_request' && (success() || failure())
run: |
echo "::add-matcher::.github/matchers/stylelint-problem-matcher.json"
jq -rs '(.[0] + .[1]) | unique | .[]' ~/files_{created,updated}.json | tr '\n' '\0' | xargs -0 -r \
npx stylelint --formatter unix
echo "::remove-matcher owner=stylelint::"
test-python:
name: test-python-${{ matrix.name }}
needs: setup
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
include:
- { name: '3.9', python: '3.9', tox: py39 }
- { name: '3.10', python: '3.10', tox: py310 }
services:
postgres:
image: postgres:12
env:
POSTGRES_HOST_AUTH_METHOD: trust
ports:
- 5432
options: --health-cmd pg_isready --health-interval 5s --health-timeout 5s --health-retries 10
steps:
# BEGIN common steps - edit all occurrences if needed!
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 14.x
- name: Download environment
uses: actions/download-artifact@v3
with:
name: environment-${{ matrix.name }}
path: /tmp
- name: Restore environment
run: tar xf /tmp/env.tar
- name: Activate virtualenv for later steps
run: |
echo "VIRTUAL_ENV=$(pwd)/.venv" >> $GITHUB_ENV
echo "$(pwd)/.venv/bin" >> $GITHUB_PATH
- name: Install Indico
run: pip install -e .
# END common steps
- name: Install redis
run: sudo apt-get install redis-server
- name: Setup database
run: |
sudo apt-get update
sudo apt-get install postgresql-client libpq-dev
export PGHOST=localhost
export PGPORT=${{ job.services.postgres.ports[5432] }}
export PGUSER=postgres
createuser indicotest
createdb -O indicotest indicotest
psql indicotest -c 'CREATE EXTENSION unaccent;'
psql indicotest -c 'CREATE EXTENSION pg_trgm;'
- name: Run pytest tests
run: |
export INDICO_TEST_DATABASE_URI="postgresql://indicotest@localhost:${{ job.services.postgres.ports[5432] }}/indicotest"
pytest --color=yes
test-js:
needs: setup
runs-on: ubuntu-20.04
steps:
# BEGIN common steps - edit all occurrences if needed!
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 14.x
- name: Download environment
uses: actions/download-artifact@v3
with:
name: environment-3.10
path: /tmp
- name: Restore environment
run: tar xf /tmp/env.tar
- name: Activate virtualenv for later steps
run: |
echo "VIRTUAL_ENV=$(pwd)/.venv" >> $GITHUB_ENV
echo "$(pwd)/.venv/bin" >> $GITHUB_PATH
- name: Install Indico
run: pip install -e .
# END common steps
- name: Run jest tests
run: npm test
- name: Try building assets
run: python bin/maintenance/build-assets.py indico --dev