Merge pull request #357 from 3dgeo-heidelberg/pre-commit-ci-update-co… #1007
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 | |
on: | |
# We run CI on pushes to the main branch | |
push: | |
branches: | |
- main | |
# and on all pull requests to the main branch | |
pull_request: | |
branches: | |
- main | |
# as well as upon manual triggers through the 'Actions' tab of the Github UI | |
workflow_dispatch: | |
jobs: | |
build-and-test: | |
name: Testing on ${{matrix.os}} Py${{matrix.python-version}}- OpenMP ${{matrix.openmp}} | |
runs-on: ${{matrix.os}} | |
strategy: | |
matrix: | |
os: [ubuntu-22.04, macos-13, macos-14, windows-2019] | |
python-version: ["3.9", "3.12"] | |
openmp: ['ON', 'OFF'] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: 'recursive' | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install OpenMP | |
if: runner.os == 'macOS' && matrix.openmp == 'ON' | |
run: brew install libomp | |
- name: make build directory | |
run: cmake -E make_directory ${{runner.workspace}}/build | |
- name: configure cmake | |
shell: bash | |
working-directory: ${{runner.workspace}}/build | |
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Debug -DBUILD_DOCS=OFF -DBUILD_BENCHMARKS=ON -DPY4DGEO_WITH_OPENMP=${{matrix.openmp}} | |
- name: build | |
shell: bash | |
working-directory: ${{runner.workspace}}/build | |
run: cmake --build . | |
- name: Install Python package and development requirements | |
run: | | |
python -m pip install -r requirements-dev.txt | |
python -m pip install -v . | |
- name: Install py4dgeo test data | |
shell: bash | |
run: | | |
mkdir -p $GITHUB_WORKSPACE/tests/data | |
copy_py4dgeo_test_data $GITHUB_WORKSPACE/tests/data | |
- name: run tests | |
shell: bash | |
working-directory: ${{runner.workspace}}/build | |
run: ctest --output-on-failure -C Debug | |
- name: Run Python tests | |
run: | | |
python -m pytest --nbval | |
coverage-test: | |
name: Coverage Testing | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: 'recursive' | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.9" | |
- name: Install LCov | |
run: | | |
sudo apt-get install -y lcov | |
- name: Install Python package and development requirements | |
run: | | |
python -m pip install -r requirements-dev.txt | |
python -m pip install -v --editable . | |
- name: Install py4dgeo test data | |
shell: bash | |
run: | | |
mkdir -p $GITHUB_WORKSPACE/tests/data | |
copy_py4dgeo_test_data $GITHUB_WORKSPACE/tests/data | |
- name: make build directory | |
run: cmake -E make_directory ${{runner.workspace}}/build | |
- name: configure cmake | |
shell: bash | |
working-directory: ${{runner.workspace}}/build | |
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="--coverage" -DBUILD_DOCS=OFF | |
- name: build | |
shell: bash | |
working-directory: ${{runner.workspace}}/build | |
run: cmake --build . | |
- name: run tests | |
shell: bash | |
working-directory: ${{runner.workspace}}/build | |
run: ctest -C Debug | |
- name: collect coverage report | |
shell: bash | |
working-directory: ${{runner.workspace}} | |
run: | | |
lcov --directory ./build --capture --output-file coverage.info | |
lcov_cobertura coverage.info -o coverage2.xml | |
- name: Run coverage tests | |
run: | | |
python -m pytest --cov=src --cov-report=xml | |
- name: Upload coverage to Codecov.io | |
working-directory: ${{runner.workspace}} | |
run: | | |
curl --connect-timeout 10 --retry 5 -Os https://uploader.codecov.io/latest/linux/codecov | |
chmod +x codecov | |
./codecov -f py4dgeo/coverage.xml -F python | |
./codecov -f coverage2.xml -F cxx | |
address-sanitizer: | |
name: Address sanitizer run | |
runs-on: ubuntu-20.04 | |
env: | |
ASAN_OPTIONS: "detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1" | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: 'recursive' | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.9" | |
- name: Install Python development requirements | |
run: | | |
python -m pip install -r requirements-dev.txt | |
python -m pip install -v . | |
- name: Install py4dgeo test data | |
shell: bash | |
run: | | |
mkdir -p $GITHUB_WORKSPACE/tests/data | |
copy_py4dgeo_test_data $GITHUB_WORKSPACE/tests/data | |
- name: make build directory | |
run: cmake -E make_directory ${{runner.workspace}}/build | |
- name: configure cmake | |
shell: bash | |
working-directory: ${{runner.workspace}}/build | |
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="-fsanitize=address -fsanitize-address-use-after-scope -fno-omit-frame-pointer" -DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address -fsanitize-address-use-after-scope -fno-omit-frame-pointer" -DBUILD_DOCS=OFF | |
- name: build | |
shell: bash | |
working-directory: ${{runner.workspace}}/build | |
run: cmake --build . | |
- name: run c++ tests | |
shell: bash | |
working-directory: ${{runner.workspace}}/build | |
run: ctest --rerun-failed --output-on-failure -C Debug | |
- name: run python tests | |
shell: bash | |
working-directory: ${{runner.workspace}}/py4dgeo | |
# for LD_PRELOAD see https://github.com/google/sanitizers/issues/934#issuecomment-649516500 | |
run: | | |
mv ../build/_py4dgeo.*.so src/py4dgeo/. | |
echo "leak:/usr/bin/bash" > supp.txt | |
echo "leak:_PyObject_New" >> supp.txt | |
echo "leak:_PyObject_GC" >> supp.txt | |
echo "leak:_PyUnicodeWriter_Finish">> supp.txt | |
echo "leak:insert_to_emptydict" >> supp.txt | |
echo "leak:new_keys_object" >> supp.txt | |
echo "leak:PyArrayMethod_FromSpec_int" >> supp.txt | |
echo "leak:PyDict_Copy" >> supp.txt | |
echo "leak:PyUnicode_New" >> supp.txt | |
echo "leak:pyo3::types::function::PyCFunction::internal_new_from_pointers" >> supp.txt | |
echo "leak:pyo3::types::function::PyCFunction::internal_new::" >> supp.txt | |
# hack to prevent external libs from dlclosing libraries, | |
# which otherwise results in <module not found> LSAN leaks that cannot be suppressed | |
# https://github.com/google/sanitizers/issues/89#issuecomment-406316683 | |
echo "#include <stdio.h>" > dlclose.c | |
echo "int dlclose(void *handle) { return 0; }" >> dlclose.c | |
clang -shared dlclose.c -o libdlclose.so | |
LSAN_OPTIONS=suppressions="$(pwd)/supp.txt" PYTHONPATH=src LD_PRELOAD="$(gcc -print-file-name=libasan.so) /usr/lib/x86_64-linux-gnu/libstdc++.so.6 $(pwd)/libdlclose.so" PYTHONMALLOC=malloc pytest -s |