-
Notifications
You must be signed in to change notification settings - Fork 18
295 lines (245 loc) · 8.14 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
---
name: CI
on:
push:
branches:
- "main"
pull_request:
jobs:
format:
name: Ensure code is properly formatted
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- uses: actions/cache@v3
with:
path: ~/.cache/pypoetry/virtualenvs
key: poetry-${{ hashFiles('poetry.lock') }}
- run: |
pip install --upgrade poetry nox nox-poetry
nox -s format -- --check
generate_requirements:
name: Generate requirements.txt for python 3.6
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- uses: actions/cache@v3
with:
path: ~/.cache/pypoetry/virtualenvs
key: poetry-${{ hashFiles('poetry.lock') }}
- run: |
pipx install poetry
poetry export --with=dev --without-hashes > requirements.txt
- uses: actions/upload-artifact@v3
with:
name: requirements
path: requirements.txt
if-no-files-found: error
ci_36:
name: Run the integration tests for Python 3.6
runs-on: ubuntu-20.04
needs: generate_requirements
strategy:
fail-fast: false
matrix:
container_runtime: ["podman", "docker"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: 3.6
- uses: actions/download-artifact@v3
with:
name: requirements
path: .
- run: pip install -r test-requirements.txt
- run: |
export CUR_USER="$(whoami)"
sudo loginctl enable-linger ${CUR_USER}
- run: |
mkdir ./tmp/
chmod 1777 ./tmp
export TMPDIR="$(pwd)/tmp"
pytest -vv -- -x -n auto --reruns 3 --pytest-container-log-level DEBUG
pytest -vv -- -x --reruns 3 --pytest-container-log-level DEBUG
# nox -s coverage
- name: verify that no stray containers are left
run: |
[[ $(${{ matrix.container_runtime }} ps -aq|wc -l) = "0" ]]
- name: verify that no stray volumes are left
run: |
[[ $(${{ matrix.container_runtime }} volume ls -q|wc -l) = "0" ]]
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: true
ci:
name: Run the integration tests
runs-on: "ubuntu-latest"
strategy:
fail-fast: false
matrix:
python_version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
container_runtime: ["podman", "docker"]
update_runtime: [ true, false ]
exclude:
- container_runtime: "docker"
python_version: "3.7"
update_runtime: true
- container_runtime: "docker"
python_version: "3.8"
update_runtime: true
- container_runtime: "docker"
python_version: "3.9"
update_runtime: true
- container_runtime: "docker"
python_version: "3.10"
update_runtime: true
- container_runtime: "docker"
python_version: "3.11"
update_runtime: true
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python_version }}
- uses: actions/cache@v3
with:
path: ~/.nox
key: nox-${{ matrix.python_version }}-${{ hashFiles('poetry.lock') }}
- run: pip install --upgrade nox poetry nox-poetry
- name: update the container runtime
if: ${{ matrix.update_runtime }}
run: |
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.opensuse.org/repositories/devel:kubic:libcontainers:unstable/xUbuntu_$(lsb_release -rs)/Release.key \
| gpg --dearmor \
| sudo tee /etc/apt/keyrings/devel_kubic_libcontainers_unstable.gpg > /dev/null
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/devel_kubic_libcontainers_unstable.gpg]\
https://download.opensuse.org/repositories/devel:kubic:libcontainers:unstable/xUbuntu_$(lsb_release -rs)/ /" \
| sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:unstable.list > /dev/null
sudo apt-get update -qq
sudo apt-get -qq -y install podman buildah
- run: |
export CUR_USER="$(whoami)"
sudo loginctl enable-linger ${CUR_USER}
- run: |
mkdir ./tmp/
chmod 1777 ./tmp
export TMPDIR="$(pwd)/tmp"
nox -s "test-${{ matrix.python_version }}(${{ matrix.container_runtime }})" -- -x -n auto --reruns 3 --pytest-container-log-level DEBUG
nox -s "test-${{ matrix.python_version }}(${{ matrix.container_runtime }})" -- -x --reruns 3 --pytest-container-log-level DEBUG
nox -s coverage
- name: verify that no stray containers are left
run: |
[[ $(${{ matrix.container_runtime }} ps -aq|wc -l) = "0" ]]
- name: verify that no stray volumes are left
run: |
[[ $(${{ matrix.container_runtime }} volume ls -q|wc -l) = "0" ]]
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: true
build:
name: Build the package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.x"
- uses: actions/cache@v3
with:
path: ~/.cache/pypoetry/virtualenvs
key: poetry-${{ hashFiles('poetry.lock') }}
- name: Run the build
run: |
pip install --upgrade poetry
poetry install
poetry build
- uses: actions/upload-artifact@v3
with:
name: wheel
path: dist/pytest_container*whl
if-no-files-found: error
install:
name: Install the package
runs-on: ${{ matrix.os_version }}
needs: build
strategy:
fail-fast: false
matrix:
os_version: ["ubuntu-latest"]
python_version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
include:
- os_version: "ubuntu-20.04"
python_version: "3.6"
steps:
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python_version }}
- uses: actions/download-artifact@v3
with:
name: wheel
path: dist
- name: install the wheel
run: pip install --user dist/pytest_container*whl
- name: run a smoke test that the package has been installed
run: python -c "import pytest_container; print (pytest_container.__name__)"
documentation:
name: Build the documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- uses: actions/cache@v3
with:
path: ~/.tox
key: tox-${{ hashFiles('poetry.lock') }}
- run: pip install --upgrade nox poetry nox-poetry
- run: nox -s doc
- name: upload the build directory
uses: actions/upload-artifact@v3
with:
name: build
path: ./build/html
deploy:
name: deploy to the gh-pages branch
runs-on: ubuntu-latest
needs: documentation
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v3
with:
name: build
path: ./build
- run: touch ./build/.nojekyll
- name: deploy to github pages
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: build
lint:
name: Lint the source code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- uses: actions/cache@v3
with:
path: ~/.tox
key: tox-${{ hashFiles('poetry.lock') }}
- run: pip install --upgrade nox poetry nox-poetry
- run: nox -s lint