-
Notifications
You must be signed in to change notification settings - Fork 2
205 lines (178 loc) · 7.82 KB
/
build-deploy.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
# This is a basic workflow to help you get started with Actions
name: Build and deploy
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the master/develop branches
push:
branches:
- master
- develop
tags:
- 'v[0-9]+.[0-9]+.[0-9]+' # run on semantic version tags
- 'v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+' # pre-release
pull_request:
branches:
- master
- develop
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build-wheels:
name: ${{ matrix.os }} build and test wheels
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: windows-latest
triplet: x64-windows
builddir: dist
- os: ubuntu-latest
triplet: x64-linux
builddir: wheelhouse
- os: macos-latest
triplet: x64-osx
builddir: wheelhouse
env:
# Indicates the CMake build directory where project files and binaries are being produced.
CMAKE_BUILD_DIR: ${{ github.workspace }}/builddir/
# Indicates the location of the vcpkg as a Git submodule of the project repository.
VCPKG_ROOT: ${{ github.workspace }}/external/LibAPR/vcpkg
CIBW_ENVIRONMENT_WINDOWS: EXTRA_CMAKE_ARGS="-DCMAKE_TOOLCHAIN_FILE=D:\\a\\pyapr\\pyapr\\external\\LibAPR\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake -DVCPKG_MANIFEST_DIR=D:\\a\\pyapr\\pyapr\\external\\LibAPR\\"
CIBW_BUILD: "cp38-* cp39-* cp310-* cp311-*"
CIBW_SKIP: "*musllinux*"
CIBW_ARCHS: "auto64"
CIBW_BUILD_VERBOSITY: 1
CIBW_REPAIR_WHEEL_COMMAND_MACOS: "pip install -U delocate && delocate-listdeps {wheel} && delocate-wheel -w {dest_dir} -v {wheel}"
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "pip install -U wheel delvewheel && python fix_windows_wheel.py {wheel} {dest_dir}"
CIBW_TEST_REQUIRES: "pytest pytest-qt pytest-xvfb"
CIBW_TEST_COMMAND: "python3 -m pytest -vv {project}/pyapr/tests"
CIBW_TEST_SKIP: "*-win_amd64" # windows tests are run separately
CIBW_BEFORE_BUILD_LINUX: "yum makecache && yum install -y libtiff-devel hdf5-devel"
CIBW_ENVIRONMENT_MACOS: CPPFLAGS="-I/opt/homebrew/opt/llvm/include" LDFLAGS="-L/opt/homebrew/opt/llvm/lib" CXX="/opt/homebrew/opt/llvm/bin/clang++" CC="/opt/homebrew/opt/llvm/bin/clang" EXTRA_CMAKE_ARGS="-DCMAKE_PREFIX_PATH=/opt/homebrew/Cellar/libtiff/4.6.0"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Submodule recursive
run: |
git submodule update --init --recursive
git status
# Setup the build machine with the most recent versions of CMake and Ninja. Both are cached if not already: on subsequent runs both will be quickly restored from GitHub cache service.
- uses: lukka/get-cmake@latest
# Restore both vcpkg and its artifacts from the GitHub cache service.
- name: Restore vcpkg and its artifacts.
uses: actions/cache@v3
with:
# The first path is where vcpkg generates artifacts while consuming the vcpkg.json manifest file.
# The second path is the location of vcpkg (it contains the vcpkg executable and data files).
# The other paths starting with '!' are exclusions: they contain termporary files generated during the build of the installed packages.
path: |
${{ env.CMAKE_BUILD_DIR }}/vcpkg_installed/
${{ env.VCPKG_ROOT }}
!${{ env.VCPKG_ROOT }}/buildtrees
!${{ env.VCPKG_ROOT }}/packages
!${{ env.VCPKG_ROOT }}/downloads
# The key is composed in a way that it gets properly invalidated: this must happen whenever vcpkg's Git commit id changes, or the list of packages changes. In this case a cache miss must happen and a new entry with a new key with be pushed to GitHub the cache service.
# The key includes: hash of the vcpkg.json file, the hash of the vcpkg Git commit id, and the used vcpkg's triplet. The vcpkg's commit id would suffice, but computing an hash out it does not harm.
# Note: given a key, the cache content is immutable. If a cache entry has been created improperly, in order the recreate the right content the key must be changed as well, and it must be brand new (i.e. not existing already).
key: |
${{ hashFiles( 'external/LibAPR/vcpkg.json' ) }}-${{ hashFiles( '.git/modules/vcpkg/HEAD' )}}-${{ matrix.triplet }}-invalidate
- name: Check file paths
run: |
cd ${{ github.workspace }}/external/LibAPR/vcpkg/scripts/buildsystems/
ls
- name: Show content of workspace after cache has been restored
run: find $RUNNER_WORKSPACE
shell: bash
# On Windows runners, let's ensure to have the Developer Command Prompt environment setup correctly. As used here the Developer Command Prompt created is targeting x64 and using the default the Windows SDK.
- uses: ilammy/msvc-dev-cmd@v1
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.9'
- name: Install cibuildwheel
run: |
python3 -m pip install cibuildwheel
- name: Install OpenMP dependencies with brew for OSX
if: contains(matrix.os,'macos')
run: |
brew install llvm
brew install libomp
brew install c-blosc
brew install hdf5
brew reinstall libtiff
- name: Run cibuildwheel
run: |
git status
python3 -m cibuildwheel --output-dir ${{matrix.builddir}}
- name: Upload wheels as artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.os }}-wheels
path: ${{matrix.builddir}}/
retention-days: 30
windows-tests:
name: ${{ matrix.os }} py${{ matrix.python-version }} tests
runs-on: ${{ matrix.os }}
needs: build-wheels
strategy:
fail-fast: false
matrix:
os: [ windows-latest ]
python-version: ['3.8', '3.9', '3.10', '3.11']
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: false
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Download wheels from artifacts
uses: actions/download-artifact@v3
with:
name: ${{ matrix.os }}-wheels
path: wheelhouse
- name: Set version string
shell: bash
run: echo "py_version_str=cp$(echo ${{ matrix.python-version }} | tr -d -c 0-9)" >> $GITHUB_ENV
- name: Install package from wheel
shell: bash
run: |
ls -R wheelhouse
python -m pip install --upgrade pip
pip install wheelhouse/pyapr-*${{ env.py_version_str }}*.whl
- name: Run tests
run: |
pip install pytest pytest-qt
pytest -vv
deploy:
runs-on: ubuntu-latest
needs: windows-tests
name: publish to pypi
# only run on push of (version) tag
if: contains(github.ref, 'tags')
steps:
- name: Download wheels from artifacts
uses: actions/download-artifact@v3
with:
path: wheelhouse
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -U twine
- name: Publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
twine upload wheelhouse/*wheels/*.whl