CI Tests #315
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/* |