forked from psi4/libefp
-
Notifications
You must be signed in to change notification settings - Fork 6
291 lines (268 loc) · 10.6 KB
/
ci.yml
File metadata and controls
291 lines (268 loc) · 10.6 KB
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
284
285
286
287
288
289
290
291
name: CI
on:
push:
branches:
- master
pull_request:
jobs:
build:
strategy:
fail-fast: false
matrix:
cfg:
- label: L-Gnu
runs-on: ubuntu-latest
python-version: "3.10"
blas: MKL
build_type: Release
cmargs: >
-D BUILD_SHARED_LIBS=ON
-D LIBEFP_ENABLE_OPENMP=ON
# uncomment the following two options to look for possible memory-related bugs in openmp
# however, the tests will take ~10 times longer
#-D CMAKE_C_FLAGS="-fsanitize=thread -g"
#-D CMAKE_EXE_LINKER_FLAGS="-fsanitize=thread"
pytest-marker-expr: "test" # i.e., all
- label: L-Gnu
runs-on: ubuntu-latest
python-version: "3.10"
blas: OBL
build_type: Release
cmargs: >
-D BUILD_SHARED_LIBS=ON
-D LIBEFP_ENABLE_OPENMP=ON
# uncomment the following two options to look for possible memory-related bugs in openmp
# however, the tests will take ~10 times longer
# this workflow was crashing with these options in pytests due to conflict of TSan and libgomp
#-D CMAKE_C_FLAGS="-fsanitize=thread -g"
#-D CMAKE_EXE_LINKER_FLAGS="-fsanitize=thread"
pytest-marker-expr: "test"
- label: L-Intel
runs-on: ubuntu-latest
python-version: "3.10"
blas: MKL
build_type: Release
cmargs: >
-D CMAKE_C_COMPILER=icx
-D CMAKE_CXX_COMPILER=icpx
-D CMAKE_C_FLAGS="--gcc-toolchain=${CONDA_PREFIX} --sysroot=${CONDA_PREFIX}/${HOST}/sysroot -target ${HOST}"
-D CMAKE_CXX_FLAGS="--gcc-toolchain=${CONDA_PREFIX} --sysroot=${CONDA_PREFIX}/${HOST}/sysroot -target ${HOST}"
-D BUILD_SHARED_LIBS=ON
-D LIBEFP_ENABLE_OPENMP=OFF
pytest-marker-expr: "not dict_5" # the forced fail fails?
- label: M-Clang
# NaNs in tests on macos-latest (macos-12)
#runs-on: macos-13
runs-on: macos-latest
python-version: "3.10"
blas: OBL
build_type: Release
cmargs: >
-D BUILD_SHARED_LIBS=ON
-D LIBEFP_ENABLE_OPENMP=ON
pytest-marker-expr: "test"
- label: M-Clang
# NaNs in tests on macos-latest (macos-12)
#runs-on: macos-13
runs-on: macos-15-intel
python-version: "3.10"
blas: ACC
build_type: Release
cmargs: >
-D BUILD_SHARED_LIBS=ON
-D LIBEFP_ENABLE_OPENMP=ON
pytest-marker-expr: "test"
- label: W-MinGW
runs-on: windows-latest
python-version: "3.10"
blas: MKL
build_type: Release
cmargs: >
-D CMAKE_C_COMPILER="gcc.exe"
-D CMAKE_CXX_COMPILER="g++.exe"
-D CMAKE_Fortran_COMPILER="gfortran.exe"
-D BUILD_SHARED_LIBS=OFF
-D LIBEFP_ENABLE_OPENMP=ON
# using gnu, not clang-cl, for consistent compiler stack incl. Fortran
pytest-marker-expr: "test"
name: "Build • 🐍 ${{ matrix.cfg.python-version }} • ${{ matrix.cfg.label }} • ${{ matrix.cfg.blas }}"
runs-on: ${{ matrix.cfg.runs-on }}
defaults:
run:
shell: bash -el {0}
steps:
- uses: actions/checkout@v4
- name: Write a Conda Env File
run: |
cat > export.yaml <<EOF
name: libefp-dev
dependencies:
- cmake
- ninja
- c-compiler
- fortran-compiler
#- dpcpp_linux-64
- blas-devel
#MKL- libblas=*=*mkl
#ACC- libblas=*=*accelerate
#OBL- libblas=*=*openblas
#OBL- openblas=*=*openmp*
# pylibefp
- cxx-compiler
- pybind11
- qcelemental
#- libpython
- pytest
EOF
if [[ "${{ runner.os }}" == "Linux" ]]; then
:
sed -i "s;#${{ matrix.cfg.blas }};;g" export.yaml
if [[ "${{ matrix.cfg.label }}" == "L-Intel" ]]; then
sed -i "s/#- dpcpp_linux-64/- dpcpp_linux-64/g" export.yaml
fi
fi
if [[ "${{ runner.os }}" == "macOS" ]]; then
:
sed -E -i.bak "s;#${{ matrix.cfg.blas }};;g" export.yaml
fi
# if [[ "${{ runner.os }}" == "Windows" ]]; then
# :
# sed -i "s;fortran-compiler;m2w64-gcc-fortran;g" export.yaml
# sed -i "s;#${{ matrix.cfg.blas }};;g" export.yaml
# sed -i "s;openmp;pthreads;g" export.yaml # W openblas is pthreads
# sed -i "s;#- libpython;- libpython;g" export.yaml
# fi
if [[ "${{ runner.os }}" == "Windows" ]]; then
# Use the modern conda-forge compilers instead of the old m2w64 ones
sed -i "s;c-compiler;gcc;g" export.yaml
sed -i "s;cxx-compiler;gxx;g" export.yaml
sed -i "s;fortran-compiler;gfortran;g" export.yaml
sed -i "s;#${{ matrix.cfg.blas }};;g" export.yaml
sed -i "s;openmp;pthreads;g" export.yaml
sed -i "s;#- libpython;- libpython;g" export.yaml
fi
# model sed for L/W
# sed -i "s;;;g" export.yaml
# model sed for M
# sed -E -i.bak "s;;;g" export.yaml
cat export.yaml
- name: Install dependencies
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: libefp-dev
environment-file: export.yaml
python-version: ${{ matrix.cfg.python-version }}
channels: conda-forge
conda-remove-defaults: true
- name: Environment Information
run: |
conda info
conda list
- name: Configure CMake
run: |
cmake \
-S . \
-B "${{ github.workspace }}/build" \
-G Ninja \
-D CMAKE_INSTALL_PREFIX="${{ github.workspace }}/installed" \
-D CMAKE_PREFIX_PATH="${CONDA_PREFIX}" \
${{ matrix.cfg.cmargs }}
- name: Build & Install
run: cmake --build "${{ github.workspace }}/build" --config ${{ matrix.cfg.build_type }} --target install
- name: Inspect linkage
run: |
if [[ "${{ runner.os }}" == "Linux" ]]; then
ldd "${{ github.workspace }}/installed/lib/libefp.so"
ldd "${{ github.workspace }}/installed/bin/efpmd"
fi
if [[ "${{ runner.os }}" == "macOS" ]]; then
otool -L "${{ github.workspace }}/installed/lib/libefp.dylib"
otool -L "${{ github.workspace }}/installed/bin/efpmd"
fi
if [[ "${{ runner.os }}" == "Windows" ]]; then
# library is static
objdump.exe -p "${{ github.workspace }}\\installed\\bin\\efpmd.exe" | grep "dll"
fi
- name: Test (CTest) - unit tests
run: ctest --output-on-failure --test-dir "${{ github.workspace }}/build"
# - name: Test (CTest) with Valgrind
# run: |
# sudo apt-get update && sudo apt-get install -y valgrind
# # Run valgrind directly on the ctest executable. The tests will take forever
# valgrind --tool=memcheck \
# --leak-check=full \
# --track-origins=yes \
# --trace-children=yes \
# --error-exitcode=1 \
# ctest --output-on-failure --test-dir "${{ github.workspace }}/build"
- name: Test (find_package) - consume installation
run: |
mkdir test_installed_library && cd test_installed_library
cat > CMakeLists.txt <<EOF
cmake_minimum_required(VERSION 3.16)
project(sample)
find_package(libefp REQUIRED)
include(CMakePrintHelpers)
cmake_print_properties(
TARGETS
libefp::efp
libefp::efpmd
tgt::lapack
OpenMP::OpenMP_C
PROPERTIES
IMPORTED_LINK_DEPENDENT_LIBRARIES
IMPORTED_LOCATION
INTERFACE_LOCATION
INTERFACE_LINK_LIBRARIES
INTERFACE_INCLUDE_DIRECTORIES
INTERFACE_COMPILE_DEFINITIONS
INTERFACE_COMPILE_OPTIONS
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES
)
add_executable(hello "hello.c")
target_link_libraries(hello libefp::efp)
EOF
cat > hello.c <<EOF
#include <stdio.h>
#include <efp.h>
int main() {
printf("Hello World");
return 0;
}
EOF
cmake -S . -B build -G Ninja --log-level verbose -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="${CONDA_PREFIX};${{ github.workspace }}/installed"
cmake --build build
./build/hello
# Step is unnecessary; remove for debugging.
- name: Confound Environment - test fetched pybind11
if: ${{ matrix.cfg.blas == 'OBL' }}
run: conda remove pybind11
- name: Build & Install Python bindings
run: |
cd python
cmake \
-S . \
-B build \
-G Ninja \
-D CMAKE_PREFIX_PATH="${CONDA_PREFIX};${{ github.workspace }}/installed" \
-D CMAKE_INSTALL_PREFIX="${{ github.workspace }}/installed" \
${{ matrix.cfg.cmargs }}
cmake --build build --target install
# psi4 with MKL avail for qmefp test
- name: Install Psi4 for QM/EFP testing
if: ${{ matrix.cfg.blas == 'MKL' }}
run: conda install psi4 -c conda-forge
- name: Test (pytest) -- unit tests Python bindings
run: |
# Setup PYTHONPATH
SEP=$(python -c "import os; print(os.pathsep)")
LIB_PATH="${{ github.workspace }}/installed/lib"
TEST_PATH="${{ github.workspace }}/installed/lib/pylibefp/tests"
export PYTHONPATH="${LIB_PATH}${SEP}${TEST_PATH}"
echo "PYTHONPATH is set to: $PYTHONPATH"
# PYTHONPATH="${{ github.workspace }}/installed/lib:${{ github.workspace }}/installed/lib/pylibefp/tests" \
# Run Pytest
pytest -s --cache-clear -v -rws --color=yes \
--durations=50 --durations-min=1 --strict-markers \
-k "${{ matrix.cfg.pytest-marker-expr }}" \
"${{ github.workspace }}/installed/"