-
Notifications
You must be signed in to change notification settings - Fork 421
261 lines (217 loc) · 6.39 KB
/
test.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
on:
push:
branches:
- main
pull_request:
name: Unit Testing
permissions:
contents: read
jobs:
lint:
name: Lint and check format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: make lint
run: make lint
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
with:
scandir: './scripts'
unit-test:
name: Unit Tests
needs: lint
runs-on: ubuntu-latest
strategy:
matrix:
pyenv: [py39, py310, py311, py312, py312-raw]
include:
- pyenv: py39
python-version: "3.9"
- pyenv: py310
python-version: "3.10"
- pyenv: py311
python-version: "3.11"
- pyenv: py312
python-version: "3.12"
- pyenv: py312-raw
python-version: "3.12"
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
memcached:
image: memcached
options: >-
--health-cmd "timeout 5 bash -c 'cat < /dev/null > /dev/udp/127.0.0.1/11211'"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 11211:11211
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: pyproject.toml
- name: Create database
env:
PGPASSWORD: postgres
run: |
psql -c "CREATE DATABASE testdb ENCODING 'UTF8' TEMPLATE template0;" -U postgres -h localhost
- name: Run tests with minimal dependencies
if: endsWith(matrix.pyenv, '-raw') == true
run: make tests-raw
- name: Run tests with optional dependencies
if: endsWith(matrix.pyenv, '-raw') != true
env:
COVERAGE_DEBUG: config,trace,pathmap
run: make tests
- name: Coveralls for ${{ matrix.pyenv }}
if: endsWith(matrix.pyenv, '-raw') != true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: ${{ matrix.pyenv }}
COVERALLS_PARALLEL: true
run: |
pip install tomli coveralls
coveralls --service=github
finish:
name: Coveralls Finished
needs: unit-test
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install coveralls
run: pip install tomli coveralls
- name: Coveralls Finished
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: coveralls --service=github --finish
functional:
name: Functional
needs: lint
runs-on: ubuntu-latest
env:
DOCKER_CACHE: /tmp/docker-cache
TEST_TAG: user/app:test
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Print environment
run: |
python --version
pip --version
- name: Install dependencies
run: |
make install-dev
- name: Create database
env:
PGPASSWORD: postgres
run: |
psql -c "CREATE DATABASE testdb ENCODING 'UTF8' TEMPLATE template0;" -U postgres -h localhost
- run: mkdir ${DOCKER_CACHE}
- name: Compute cache key
# Create hash of hashes of checked in files not in Dockerignore
run: echo "CACHE_KEY=$(git ls-tree --full-tree -r HEAD | grep -v -f .dockerignore | awk '{print $3}' | git hash-object --stdin)" >> $GITHUB_ENV
- uses: actions/cache@v4
with:
path: ${{ env.DOCKER_CACHE}}
key: docker-build-${{ hashFiles('Dockerfile') }}-${{ env.CACHE_KEY }}
restore-keys: |
docker-build-${{ hashFiles('Dockerfile') }}-${{ env.CACHE_KEY }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
install: true
- name: Build container
uses: docker/build-push-action@v6
with:
cache-from: type=local,src=${{ env.DOCKER_CACHE}}
cache-to: type=local,dest=${{ env.DOCKER_CACHE}},mode=max
tags: ${{ env.TEST_TAG }}
file: Dockerfile
load: true
context: .
- name: Run container
run: |
docker run --net=host --detach --rm \
-p 8888:8888 \
-v `pwd`/tests/functional.ini:/etc/functional.ini \
-e KINTO_INI=/etc/functional.ini \
${{ env.TEST_TAG }} && sleep 5
- name: Functional Tests
run: |
make functional
kinto-admin:
name: Kinto Admin
needs: [lint, functional]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: actions/setup-node@v4
with:
node-version: "18.x"
- name: Print environment
run: |
python --version
pip --version
node --version
npm --version
- name: geckodriver/firefox
run: |
echo "geckodriver/firefox"
which geckodriver
geckodriver --version
which firefox
firefox --version
- name: make pull-kinto-admin
run: make pull-kinto-admin
- name: Install dependencies
run: make install-dev
- name: Start Kinto
run: .venv/bin/kinto start --ini tests/browser.ini & sleep 5
- name: Browser Tests
run: make browser-test
docs:
name: Validate docs
needs: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Print environment
run: |
python --version
pip --version
- name: make docs
run: make docs
- name: Package description
run: make test-description