-
Notifications
You must be signed in to change notification settings - Fork 11
264 lines (233 loc) · 7.6 KB
/
main.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
name: CI
on:
- push
- pull_request
jobs:
Python-Test:
runs-on: ubuntu-latest
services:
redis:
image: redis:latest
ports:
- 6379:6379
postgres:
image: postgres:14
env:
POSTGRES_DB: varfish_web
POSTGRES_USER: varfish_web
POSTGRES_PASSWORD: varfish_web
DATABASE_URL: postgres://varfish_web:varfish_web@postgres/varfish_web
CELERY_BROKER_URL: redis://redis:6379/0
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 10
ports:
- 5432:5432
# We launch a minio instance for testing. Note that we use the bitnami
# image because of the issue lined out in this SO discussion:
#
# - https://stackoverflow.com/questions/64031598
minio:
image: bitnami/minio:latest
env:
MINIO_ROOT_USER: minioadmin
MINIO_ROOT_PASSWORD: minio-root-password
options: >-
--name=minio
--health-cmd "curl http://localhost:9000/minio/health/live"
--health-interval 10s
--health-timeout 5s
--health-retries 10
ports:
- 9000:9000
env:
CELERY_BROKER_URL: redis://0.0.0.0:6379/0
DATABASE_URL: 'postgres://varfish_web:[email protected]/varfish_web'
POSTGRES_HOST: 0.0.0.0
POSTGRES_PORT: 5432
VARFISH_CASE_IMPORT_INTERNAL_STORAGE: |
{
"bucket": "varfish-server-test",
"host": "minio",
"port": 9000,
"access_key": "varfish-server-test",
"secret_key": "varfish-server-test"
}
steps:
- name: Perform minio client setup
run: |
set -x
# create host alias for minio
echo "127.0.0.1 minio" | sudo tee -a /etc/hosts
# install minio client and configure default alias
wget -O /usr/local/bin/mc https://dl.min.io/client/mc/release/linux-amd64/mc
chmod +x /usr/local/bin/mc
mc alias set minio/ http://minio:9000 minioadmin minio-root-password
# setup bucket and access key for tests
mc mb minio/varfish-server-test
mc admin user add minio varfish-server-test varfish-server-test
# write policy file for bucket access, add it to server, and associate with
# access key created above
cat >/tmp/policy.json <<"EOF"
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"s3:DeleteObject",
"s3:GetBucketLocation",
"s3:GetObject",
"s3:ListBucket",
"s3:PutObject"
],
"Effect": "Allow",
"Resource": [
"arn:aws:s3:::varfish-server-test/*",
"arn:aws:s3:::varfish-server-test"
],
"Sid": "BucketAccessForUser"
}
]
}
EOF
mc admin policy create minio varfish-server-test-policy /tmp/policy.json
mc admin policy attach minio varfish-server-test-policy --user varfish-server-test
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential zlib1g-dev libtiff5-dev libjpeg8-dev \
libfreetype6-dev liblcms2-dev libwebp-dev libpq-dev graphviz-dev \
libldap2-dev libsasl2-dev
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: 'recursive'
lfs: true
- name: Install Python
uses: actions/setup-python@v5
with:
# We need to fix the patch version here otherwise, snapshot tests
# with randomness will / may fail.
python-version: "3.10.15"
- name: Install pip and Pipenv
run: |
pip install -U pip pipenv
working-directory: backend
- name: Install project dependencies with pipenv
run: |
pipenv install --verbose --categories=packages,dev-packages
working-directory: backend
- name: Run collectstatic (will download icons and build frontend)
run: make collectstatic
working-directory: backend
- name: Build Vue app as that can be tested via selenium.
run: |
npm ci
npm run build
nohup npm run serve &
working-directory: frontend
- name: Setup environment with worker
uses: mamba-org/setup-micromamba@v2
with:
environment-file: environment.yaml
init-shell: bash
cache-environment: true
post-cleanup: 'all'
- name: Run tests
run: |
make test
# Important: use shell that was initialized by micromamba.
shell: bash -el {0}
working-directory: backend
- name: Upload Python coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
flags: python
directory: backend
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
Python-Lint:
runs-on: ubuntu-20.04
steps:
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: "3.10.15"
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: 'recursive'
lfs: true
- name: Install pip and Pipenv
run: pip install -U pip pipenv
working-directory: backend
- name: Install project dependencies with pipenv
run: make deps
working-directory: backend
- name: Run all lints
run: |
rm -rf src
make lint
working-directory: backend
- name: Check for OpenAPI schema changes
run: |
pipenv run python manage.py spectacular \
--file /tmp/varfish_api_schema.yaml
diff \
varfish/tests/drf_openapi_schema/varfish_api_schema.yaml \
/tmp/varfish_api_schema.yaml
shell: bash -euo pipefail {0}
working-directory: backend
Node-Lint:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: 'recursive'
lfs: true
- name: Install javascript dependencies
run: |
make deps
working-directory: frontend
- name: Run linting
run: |
make lint
working-directory: frontend
# # TODO: it appears that this is not stable
# - name: Check for OpenAPI schema changes.
# run: |
# npx openapi-typescript \
# ../backend/varfish/tests/drf_openapi_schema/varfish_api_schema.yaml \
# -o /tmp/varfish.d.ts
#
# diff \
# src/varfish/api/varfish.d.ts \
# /tmp/varfish.d.ts
# shell: bash -euo pipefail {0}
# working-directory: frontend
Node-Test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: 'recursive'
lfs: true
- name: Install javascript dependencies
run: |
make deps
working-directory: frontend
- name: Run Vue app tests
run: |
make test
working-directory: frontend
- name: Upload nodejs coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
flags: nodejs
directory: frontend
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}