-
Notifications
You must be signed in to change notification settings - Fork 17
242 lines (203 loc) · 7.31 KB
/
python-package.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
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Python package
on: [push, pull_request]
jobs:
Test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.7", "3.8", "3.9", "3.10"]
qt5: [true, false]
gdal: [true, false]
seisunix: [true, false]
exclude:
- os: windows-latest
python-version: "3.7"
- os: macos-latest
qt5: true
- os: macos-latest
seisunix: true
- os: macos-latest
gdal: true
- os: windows-latest
qt5: true
- os: windows-latest
seisunix: true
- os: windows-latest
gdal: true
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
# testing
python -m pip install flake8 pytest
python -m pip install coverage
python -m pip install mock
# production
python -m pip install wheel
python -m pip install -r requirements.txt
- name: Install optional dependency qt5
if: ${{ matrix.qt5 }}
run: |
sudo apt install -y xvfb x11-utils libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 pyqt5-dev-tools
python -m pip install pyqt5
python -c 'import PyQt5'
- name: Install optional dependency SeisUnix
if: ${{ matrix.seisunix }}
run: bash install_su.sh
- name: Install optional dependency GDAL
if: ${{ matrix.gdal }}
run: |
sudo apt-get install -y libcurl4-gnutls-dev
sudo apt-get install libgdal-dev=3.4.1+dfsg-1build4
export CPLUS_INCLUDE_PATH=/usr/include/gdal
export C_INCLUDE_PATH=/usr/include/gdal
python -m pip install gdal==3.4.1
- name: Install ImpDAR
run: python -m pip install .
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Run tests GUI
if: ${{ matrix.qt5 }}
run: |
xvfb-run `which coverage` run --source impdar --omit=impdar/tests/*,impdar/lib/analysis/* -m pytest
- name: Run tests no GUI
if: ${{ !matrix.qt5 }}
run: |
coverage run --source impdar --omit=impdar/tests/*,impdar/lib/analysis/* -m pytest
- name: Produce xml coverage
run: coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: false # I see no reason to fail over this.
Windows-Build:
needs: Test
runs-on: windows-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
steps:
- uses: actions/checkout@master
- name: Download Build Tools for Visual Studio 2019
run: Invoke-WebRequest -Uri https://aka.ms/vs/16/release/vs_buildtools.exe -OutFile vs_buildtools.exe
- name: Run vs_buildtools.exe install
run: ./vs_buildtools.exe --quiet --wait --norestart --nocache --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.VC.v141.x86.x64 --add Microsoft.VisualStudio.Component.VC.140 --includeRecommended
- name: Set up Python ${{ matrix.python-version }} x64
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Install Python package dependencies
run: pip install cython wheel
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
- name: Build binary wheel
run: python setup.py bdist_wheel
- uses: actions/upload-artifact@v3
with:
name: build-windows-${{ matrix.python-version }}
path: dist
Mac-Build:
runs-on: macos-latest
needs: Test
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Symlink gcc
run: |
ln -s /usr/local/bin/gfortran-9 /usr/local/bin/gfortran
ln -s /usr/local/bin/gcc-9 /usr/local/bin/gcc
continue-on-error: true
- name: Checkout
uses: actions/checkout@v4
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel cython
python -m pip install -r requirements.txt
- name: Build binary wheel
run: python setup.py bdist_wheel
- uses: actions/upload-artifact@v3
with:
name: build-macos-${{ matrix.python-version }}
path: dist
# This one is only run when actually needed
Linux-Build:
runs-on: ubuntu-latest
needs: Test
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build and deploy manylinux wheels
uses: ./
- uses: actions/upload-artifact@v3
with:
name: build-linux
path: dist
# deploy source distribution
Source-Build:
runs-on: ubuntu-latest
needs: Test
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.7
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
- name: create source distribution
run: python setup.py sdist
- uses: actions/upload-artifact@v3
with:
name: build-source
path: dist
Upload-PyPi:
runs-on: ubuntu-latest
needs: [Source-Build, Mac-Build, Windows-Build, Linux-Build]
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v3
- name: Collect packages
run: |
if [ ! -d dist ]; then mkdir dist; fi
for d in build*; do mv -f $d/* dist/; done
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true
- name: Publish distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_API_TOKEN }}