-
Notifications
You must be signed in to change notification settings - Fork 14
206 lines (171 loc) · 6.62 KB
/
ci.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
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