Skp 2026 #117
This file contains hidden or 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: | |
| push: | |
| branches: | |
| - master | |
| pull_request: | |
| jobs: | |
| build: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| cfg: | |
| - label: L-Gnu | |
| runs-on: ubuntu-latest | |
| torch: OFF | |
| python-version: "3.10" | |
| blas: MKL | |
| build_type: Release | |
| cmargs: > | |
| -D TORCH_SWITCH=OFF | |
| -D BUILD_SHARED_LIBS=ON | |
| -D LIBEFP_ENABLE_OPENMP=ON | |
| pytest-marker-expr: "test" # i.e., all | |
| - label: L-Torch | |
| runs-on: ubuntu-latest | |
| torch: ON | |
| python-version: "3.10" | |
| blas: MKL | |
| build_type: Release | |
| cmargs: > | |
| -D TORCH_SWITCH=ON | |
| -D BUILD_SHARED_LIBS=ON | |
| -D LIBEFP_ENABLE_OPENMP=ON | |
| pytest-marker-expr: "test" # i.e., all | |
| - label: L-Gnu | |
| runs-on: ubuntu-latest | |
| torch: OFF | |
| python-version: "3.10" | |
| blas: OBL | |
| build_type: Release | |
| cmargs: > | |
| -D TORCH_SWITCH=OFF | |
| -D BUILD_SHARED_LIBS=ON | |
| -D LIBEFP_ENABLE_OPENMP=ON | |
| pytest-marker-expr: "test" | |
| - label: L-Intel | |
| runs-on: ubuntu-latest | |
| torch: OFF | |
| python-version: "3.10" | |
| blas: MKL | |
| build_type: Release | |
| cmargs: > | |
| -D TORCH_SWITCH=OFF | |
| -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 | |
| runs-on: macos-latest | |
| torch: OFF | |
| python-version: "3.10" | |
| blas: OBL | |
| build_type: Release | |
| cmargs: > | |
| -D TORCH_SWITCH=OFF | |
| -D BUILD_SHARED_LIBS=ON | |
| -D LIBEFP_ENABLE_OPENMP=ON | |
| pytest-marker-expr: "test" | |
| - label: M-Clang | |
| runs-on: macos-15-intel | |
| torch: OFF | |
| python-version: "3.10" | |
| blas: ACC | |
| build_type: Release | |
| cmargs: > | |
| -D TORCH_SWITCH=OFF | |
| -D BUILD_SHARED_LIBS=ON | |
| -D LIBEFP_ENABLE_OPENMP=ON | |
| pytest-marker-expr: "test" | |
| - label: W-MinGW | |
| runs-on: windows-latest | |
| torch: OFF | |
| python-version: "3.10" | |
| blas: MKL | |
| build_type: Release | |
| cmargs: > | |
| -D TORCH_SWITCH=OFF | |
| -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 | |
| if [[ "${{ matrix.cfg.torch }}" == "ON" ]]; then | |
| # Append pytorch-cpu to the end of the dependencies list | |
| sed -i "/dependencies:/a \ - pytorch-cpu" 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: Install LibTorch | |
| run: | | |
| if [[ "${{ matrix.cfg.torch }}" == "ON" ]]; then | |
| sed -i "/dependencies:/a \ - pytorch-cpu" export.yaml | |
| fi | |
| - 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/" |