-
Notifications
You must be signed in to change notification settings - Fork 92
283 lines (257 loc) · 9.44 KB
/
tests.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
name: CI Tests
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
schedule:
- cron: "0 2 * * 0"
env:
LATEST_CGAL_VERSION: '6.0.1'
jobs:
prepare-matrix:
name: Prepare Matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- name: Set matrix output
id: set-matrix
run: |
MATRIX_JSON=$(jq -c . < .github/workflows/matrix.json)
echo "MATRIX_JSON=${MATRIX_JSON}" >> $GITHUB_ENV
echo "matrix=${MATRIX_JSON}" >> $GITHUB_OUTPUT
sdist:
name: Create Source Distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Upgrade pip
run: |
python3 -m pip install --upgrade pip
- name: Create Source Distribution
run: |
pip install setuptools wheel twine
mkdir -p build/build-python/CGAL
CGAL_VERSION=$LATEST_CGAL_VERSION
CGAL_SWIG_BINDINGS_VERSION=$(git show --no-patch --format='format:%ad' --date=format:'%Y%m%d%H%M')
CGAL_PYTHON_MODULE_VERSION=$CGAL_VERSION-$CGAL_SWIG_BINDINGS_VERSION
export CGAL_PYTHON_MODULE_VERSION
python3 setup.py sdist
- uses: actions/upload-artifact@v4
with:
name: sdist
path: dist/*.tar.gz
build-and-test-wheels:
name: Wheel
needs: prepare-matrix
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix: ${{fromJson(needs.prepare-matrix.outputs.matrix)}}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
environment-file: .integration/conda-env-test.yml
activate-environment: test
- name: Display Python version
shell: bash -l {0}
run: |
echo -n "Wanted: "
echo ${{ matrix.python-version }}
python --version
- name: Conda info
shell: bash -l {0}
run: conda info
# - name: Set up JDK 1.8
# uses: actions/setup-java@v1
# with:
# java-version: 1.8
# - name: Install dependencies
# shell: bash -l {0}
# run: |
# $CONDA/bin/conda install -n test -y -c conda-forge 'boost-cpp>=1.77' bzip2 zlib eigen mpfr mpir tbb numpy wheel twine swig
- name: pycodestyle
shell: bash -l {0}
env:
CGAL_PYTHON_EXAMPLES: examples/python
PYCODESTYLE_CONVENTIONS: "--max-line-length=120"
run: |
pycodestyle --show-source --show-pep8 $PYCODESTYLE_CONVENTIONS $CGAL_PYTHON_EXAMPLES || pycodestyle --statistics $PYCODESTYLE_CONVENTIONS -qq $CGAL_PYTHON_EXAMPLES
- name: Install CGAL
shell: bash -l {0}
run: |
set -xe
pushd $HOME
git clone --depth 1 -b ${{ matrix.cgal_branch }} https://github.com/CGAL/cgal.git
cd cgal
mkdir build
cmake -B build -S . -DCMAKE_INSTALL_PREFIX=$HOME/.local -DCMAKE_BUILD_TYPE=Release ..
cmake --install build
cd ..
rm -rf cgal
popd
- name: Install LASTools
shell: bash -l {0}
run: |
MACOSX_DEPLOYMENT_TARGET=10.13
export MACOSX_DEPLOYMENT_TARGET
set -xe
pushd $HOME
git clone --depth 1 https://github.com/CGAL/LAStools.git
cd LAStools
mkdir build
cmake -B build -S . -DCMAKE_INSTALL_PREFIX=$HOME/.local -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release -j$(nproc)
cmake --install build --config Release
cd ..
rm -rf LAStools
mv $HOME/.local/include/LASzip/*.hpp $HOME/.local/include/
mv $HOME/.local/include/LASlib/*.hpp $HOME/.local/include/
[ -d $HOME/.local/bin ] || mkdir $HOME/.local/bin
[ -f $HOME/.local/lib/las.dll ] && mv $HOME/.local/lib/las.dll $HOME/.local/bin/
[ -f $HOME/.local/lib/liblas.dylib ] && install_name_tool -id '@rpath/liblas.dylib' $HOME/.local/lib/liblas.dylib
popd
- name: Build local wheel
shell: bash -l {0}
run: |
set -ex
CONDA_ENV_DIR=$(conda env list --json | jq -r '.envs | .[] | select(test("test"))')
[ -d "$CONDA_ENV_DIR/Library" ] && CONDA_ENV_DIR="$CONDA_ENV_DIR\\Library" # for Windows miniconda
export CONDA_ENV_DIR
export PATH=$CONDA_ENV_DIR/bin:$HOME/.local/bin:$PATH
case ${{ runner.os }} in
Windows)
export CMAKE_PREFIX_PATH=${CONDA_ENV_DIR}';'$(cygpath -w $HOME/.local)
;;
*) export CMAKE_PREFIX_PATH=${CONDA_ENV_DIR}:$HOME/.local
esac
CGAL_VERSION=$(perl -lan -e 'if(/CGAL_VERSION /) { $v=@F[2]; $v =~ s/-.*//; print "$v" }' $HOME/.local/include/CGAL/version.h)
CGAL_SWIG_BINDINGS_VERSION=$(git show --no-patch --format='format:%ad' --date=format:'%Y%m%d%H%M')
CGAL_PYTHON_MODULE_VERSION=$CGAL_VERSION-$CGAL_SWIG_BINDINGS_VERSION
echo Create package version $CGAL_PYTHON_MODULE_VERSION
export CGAL_PYTHON_MODULE_VERSION
mkdir -p build/build-python/CGAL
case ${{ runner.os }} in
Linux)
docker pull cgal/python-wheel:manylinux2014
docker run --rm -v$HOME/.local:/cgal -v${PWD}:/cgal-bindings -eCGAL_PYTHON_MODULE_VERSION=$CGAL_PYTHON_MODULE_VERSION -ePYTHON_VERSION_MINOR=$(python -c "import sys; print(sys.version_info.minor)") cgal/python-wheel:manylinux2014
rm cgal-*.whl
cp wheelhouse/*.whl .
;;
macOS)
MACOSX_DEPLOYMENT_TARGET=10.13
LDFLAGS="-rpath ${CONDA_ENV_DIR}/lib -rpath $HOME/.local/lib"
DYLD_LIBRARY_PATH=${CONDA_ENV_DIR}/lib:/Users/runner/.local/lib
export MACOSX_DEPLOYMENT_TARGET
export LDFLAGS
export DYLD_LIBRARY_PATH
CXXFLAGS=-faligned-allocation
export CXXFLAGS
CGAL_DIR=$HOME/.local python -m pip wheel -v .
delocate-listdeps --all cgal-*.whl
delocate-wheel -v -w fixed_wheel cgal-*.whl
delocate-listdeps --all fixed_wheel/*.whl
rm cgal-*.whl
cp fixed_wheel/*.whl .
;;
Windows)
LIB=${CONDA_ENV_DIR}\\lib
CGAL_DIR=$HOME/.local
CXXFLAGS=-D__TBB_NO_IMPLICIT_LINKAGE
export CXXFLAGS
export LIB
export CGAL_DIR
python -m pip wheel -v .
;;
esac
unzip -l cgal-*whl
python -m twine check cgal-*whl
- name: Install delvewheel
shell: bash -l {0}
if: runner.os == 'Windows'
run: pip install delvewheel
- name: Repair wheel with delvewheel
shell: bash -l {0}
if: runner.os == 'Windows'
run: |
delvewheel repair --ignore-in-wheel cgal-*.whl -w fixed_wheels
rm cgal-*.whl
mv fixed_wheels/*.whl .
- uses: actions/upload-artifact@v4
with:
name: wheel-${{ matrix.os }}-${{ matrix.cgal_branch }}-${{ matrix.python-version }}
path: cgal-*.whl
test-wheel:
name: Test Wheel
needs: [prepare-matrix, build-and-test-wheels]
runs-on: ${{ matrix.os }}
if: always()
strategy:
fail-fast: false
matrix: ${{fromJson(needs.prepare-matrix.outputs.matrix)}}
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: actions/download-artifact@v4
with:
name: wheel-${{ matrix.os }}-${{ matrix.cgal_branch }}-${{ matrix.python-version }}
merge-multiple: true
- name: Install Wheel and Test
shell: bash -l {0}
run: |
set -ex
${pythonLocation}/python -m venv cgal_venv
case ${{ runner.os }} in
Windows) cgal_venv/Scripts/activate
;;
*) source cgal_venv/bin/activate
esac
${pythonLocation}/python -m pip install cgal-*.whl
cd examples/python
for i in *.py; do
${pythonLocation}/python $i
done
upload:
name: Upload to PyPI
runs-on: ubuntu-latest
needs: [sdist, build-and-test-wheels, test-wheel]
steps:
- uses: actions/download-artifact@v4
- name: Select wheels to push
run : |
mkdir dist
cp -r *v${{ env.LATEST_CGAL_VERSION }}*/*.whl dist/
ls dist
- name: upload to TestPyPI
if: false && github.event_name == 'push' && github.ref_name == 'main'
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_PASSWORD }}
run: |
pip install twine
python3 -m twine upload --verbose --repository testpypi dist/*
- name: upload to PyPI
if: github.event_name == 'push' && github.ref_name == 'main'
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
pip install twine
python3 -m twine upload --verbose dist/*