Skip to content

CI Tests

CI Tests #177

Workflow file for this run

name: CI Tests
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
schedule:
- cron: "0 2 * * 0"
env:
LATEST_CGAL_VERSION: '5.6'
jobs:
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@v4
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@v3
with:
path: dist/*.tar.gz
build-and-test-wheels:
name: Wheel
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
cgal_branch: [v5.6, 5.6.x-branch, master]
#cgal_branch: [v5.5]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
#python-version: ["3.9"]
os: [ubuntu-latest, macos-latest, windows-latest]
#os: [macos-latest]
#os: [windows-latest]
#os: [ubuntu-latest]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- uses: conda-incubator/setup-miniconda@v2
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: |
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)
LDFLAGS="-rpath ${CONDA_ENV_DIR}/lib -rpath $HOME/.local/lib"
export LDFLAGS
CXXFLAGS=-faligned-allocation
export CXXFLAGS
CGAL_DIR=$HOME/.local python -m pip wheel -v .
delocate-wheel -w fixed_wheel cgal-*.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 wheel and test it
shell: bash -l {0}
run: |
set -ex
python -m venv cgal_venv
case ${{ runner.os }} in
Windows) cgal_venv/Scripts/activate
;;
*) source cgal_venv/bin/activate
esac
python -m pip install cgal-*.whl
cd examples/python
for i in *.py; do
python $i
done
- uses: actions/upload-artifact@v3
if: endsWith(matrix.cgal_branch, env.LATEST_CGAL_VERSION)
with:
path: cgal-*.whl
upload:
name: Upload to PyPI
runs-on: ubuntu-latest
needs: [sdist, build-and-test-wheels]
steps:
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- name: upload to TestPyPI
if: 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/*