-
Notifications
You must be signed in to change notification settings - Fork 0
325 lines (275 loc) · 10.5 KB
/
complete.yml
File metadata and controls
325 lines (275 loc) · 10.5 KB
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
318
319
320
321
322
323
324
325
# SPDX-FileCopyrightText: 2023 Gabriele Pongelli
#
# SPDX-License-Identifier: MIT
# This is a complete workflow triggered when developing and when releasing packages.
name: complete workflow
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master, main ]
tags:
- '*.*.*'
pull_request:
branches: [ master, main ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
pre-checks:
# pre-checks does not need complex matrix, project is not built
name: Run some checks before build
strategy:
matrix:
python-version: [ "3.11" ]
poetry-version: [ "1.4.1" ]
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
with:
submodules: 'recursive'
# https://github.com/actions/setup-python
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Setup Poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: ${{ matrix.poetry-version }}
# setup poetry environment without install not-yet-built package
- name: Install dependencies
run: |
python -m pip install --upgrade pip
poetry install --with devel --sync --no-root
- name: Lint checks with tox
run:
poetry run tox --skip-pkg-install -e lint
- name: Build and check documentation
run: poetry run tox --skip-pkg-install -e docs
build-test:
needs: pre-checks
name: Build on ${{ matrix.os }} - py${{ matrix.python-version }} - poetry ${{ matrix.poetry-version }}
# The type of runner that the job will run on
strategy:
fail-fast: false
matrix:
python-version: [ 3.8, 3.9, "3.10", "3.11" ]
poetry-version: [ "1.4.1" ]
# https://github.com/actions/runner-images list of images
os: [ ubuntu-latest, windows-latest, macos-latest ]
include:
- python-version: "3.11"
python-sw: "3.11.1"
- python-version: "3.10"
python-sw: "3.10.9"
- python-version: "3.9"
python-sw: "3.9.16"
- python-version: "3.8"
python-sw: "3.8.16"
- os: ubuntu-latest
tox_os: "lin"
- os: windows-latest
tox_os: "win"
- os: macos-latest
tox_os: "mac"
runs-on: ${{ matrix.os }}
outputs:
cibw_build_version: ""
manylinux_image: ""
cd_option: ""
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
with:
submodules: 'recursive'
# https://github.com/actions/setup-python
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Setup Poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: ${{ matrix.poetry-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v2
with:
platforms: all
# cd silently fails when moving on different drive in Windows, it needs /d to act correctly
# see https://github.com/pypa/cibuildwheel/issues/1448
- name: Setup change dir option for windows in cibuildwheel
if: runner.os == 'Windows'
run: |
echo "cd_option=/d" >> $env:GITHUB_ENV
- name: Setting python version for cibuildwheel
uses: actions/github-script@v6
id: set_cibuildwheel_build
with:
script: |
core.setOutput('cibw_build_version', 'cp' + '${{ matrix.python-version }}'.replaceAll(/[/.]/g, '').trim('-') + '-*');
core.setOutput('manylinux_image', 'gpongelli/manylinux_python:py' + '${{ matrix.python-version }}'.replaceAll(/[/.]/g, '').trim('-') + '-latest');
# configuration is inside pyproject.toml
# under linux, check tool is built and used to re-run pytest, it checks C code
# there are no compiler differences, so no need to run check tool in windows and macos
- name: Build wheels
uses: pypa/cibuildwheel@v2.12.0
env:
CIBW_BUILD: ${{ steps.set_cibuildwheel_build.outputs.cibw_build_version }}
CIBW_MANYLINUX_X86_64_IMAGE: ${{ steps.set_cibuildwheel_build.outputs.manylinux_image }}
CIBW_BEFORE_TEST_LINUX: >
cd {project} &&
python3 -m pip install --upgrade pip &&
cd {project}/check_c && make extract && make build
CIBW_TEST_COMMAND_LINUX: >
cd ${{ env.cd_option }} {project} &&
poetry install --with devel --sync --no-root &&
poetry run tox --skip-pkg-install -e py${{ matrix.python-version }}-${{ matrix.tox_os }} &&
poetry env info --path &&
cp -f {project}/check_c/runner $(poetry env info --path)/bin &&
LD_LIBRARY_PATH={project}/check_c/installed/lib64:$LD_LIBRARY_PATH poetry run runner
CIBW_ENVIRONMENT_MACOS: MACOSX_DEPLOYMENT_TARGET="12.0" MACOS_DEPLOYMENT_TARGET="12.0" SYSTEM_VERSION_COMPAT=0
CIBW_TEST_COMMAND: >
cd ${{ env.cd_option }} {project} &&
python3 -m pip install --upgrade pip &&
poetry install --with devel --sync --no-root &&
poetry run tox --skip-pkg-install -e py${{ matrix.python-version }}-${{ matrix.tox_os }}
- name: show temporary files
run: |
ls -l .
ls -l wheelhouse
# https://github.com/actions/upload-artifact
# make artifacts available through jobs and into action's webpage
- uses: actions/upload-artifact@v3
name: Upload wheel
with:
name: built_artifacts
path: ./wheelhouse/*.whl
# https://github.com/codecov/codecov-action
# Easily upload coverage reports to Codecov from GitHub Actions
- uses: codecov/codecov-action@v3.1.1
if: runner.os == 'macOS'
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
files: ./xml_coverage_py${{ matrix.python-version }}-mac.xml
build-sdist:
needs: pre-checks
name: Build source distribution
strategy:
matrix:
python-version: [ "3.11" ]
poetry-version: [ "1.4.1" ]
os: [ windows-latest ]
runs-on: ${{ matrix.os }}
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
with:
submodules: 'recursive'
# https://github.com/actions/setup-python
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Setup Poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: ${{ matrix.poetry-version }}
- name: Install dependencies and Build sdist
run: |
python -m pip install --upgrade pip
# configuration is inside pyproject.toml
- name: Build wheels
uses: pypa/cibuildwheel@v2.12.0
env:
CIBW_SKIP: '*-win32 pp*'
CIBW_BUILD: 'cp311-win_amd64'
CIBW_BEFORE_BUILD: "poetry build --format sdist"
CIBW_TEST_COMMAND: ''
- name: show temporary files
run: |
ls -l dist
- uses: actions/upload-artifact@v3
name: Upload sdist
with:
name: built_artifacts
path: dist/*.tar.gz
publish:
needs: [ build-test, build-sdist ] #, build-rpi ]
name: Publish built artifacts
if: startsWith(github.ref, 'refs/tags/')
strategy:
matrix:
python-version: [ "3.11" ]
poetry-version: [ "1.4.1" ]
# https://github.com/actions/runner-images list of images
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
with:
submodules: 'recursive'
# https://github.com/actions/setup-python
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Setup Poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: ${{ matrix.poetry-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
poetry install --with devel --sync --no-root
- uses: actions/download-artifact@v3
with:
path: ./wheelhouse
- name: Display structure of downloaded files
run: ls -R
working-directory: ./wheelhouse
# Build and publish documentation
- name: Setup Pages
uses: actions/configure-pages@v2
- name: build documentation
run: poetry run tox --skip-pkg-install -e docs
- name: Upload Sphinx doc artifact
uses: actions/upload-pages-artifact@v1
with:
path: './docs/build/html'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
# https://github.com/BinPar/read-conventional-commit-changelog
- name: Get Changelog Entry
id: changelog
uses: BinPar/read-conventional-commit-changelog@v2.0.2
# https://github.com/softprops/action-gh-release
- name: create github release
id: create_release
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.make_gh_release_token }}
body: ${{ steps.changelog.outputs.version-changelog }}
files: wheelhouse/built_artifacts/*
draft: false
prerelease: false
# https://github.com/pypa/gh-action-pypi-publish
# cibuildwheel put whl under wheelhouse
- name: publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: ${{ secrets.pypi_username }}
password: ${{ secrets.pypi_password }}
skip-existing: true
packages_dir: ./wheelhouse/built_artifacts/