fix #100
Workflow file for this run
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: [push, pull_request] | |
env: | |
BUILD_DIR: _build | |
PIP_PACKAGES: >- | |
meson | |
cmake | |
ninja | |
gcovr | |
PIP_EXTRAS: >- | |
pkgconfig | |
pytest | |
pytest-cov | |
cffi | |
numpy | |
ase | |
matplotlib | |
qcelemental | |
LINUX_INTEL_COMPONENTS: >- | |
intel-oneapi-compiler-fortran-2021.2.0 | |
intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic-2021.2.0 | |
intel-oneapi-mkl-2021.2.0 | |
intel-oneapi-mkl-devel-2021.2.0 | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, macos-latest] | |
build: [meson, cmake] | |
build-type: [debug] | |
compiler: [gnu] | |
version: [12] | |
include: | |
- os: ubuntu-latest | |
build: meson | |
build-type: coverage | |
compiler: gnu | |
version: 10 | |
- os: ubuntu-latest | |
build: meson | |
build-type: debug | |
compiler: gnu | |
version: 11 | |
- os: ubuntu-latest | |
build: meson | |
build-type: debug | |
compiler: intel | |
version: 2021.2.0 | |
- os: ubuntu-latest | |
build: fpm | |
compiler: gnu | |
version: 12 | |
# - os: windows-latest | |
# build: meson | |
# build-type: debug | |
# compiler: gnu | |
# shell: msys2 {0} | |
defaults: | |
run: | |
shell: ${{ matrix.shell || 'bash' }} | |
env: | |
FC: ${{ matrix.compiler == 'intel' && 'ifort' || 'gfortran' }} | |
CC: ${{ matrix.compiler == 'intel' && 'icc' || 'gcc' }} | |
GCC_V: ${{ matrix.version }} | |
PYTHON_V: 3.9 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.PYTHON_V }} | |
- name: Link pre-installed GCC and FC (macOS) | |
if: ${{ contains(matrix.os, 'macos') && matrix.compiler == 'gnu' }} | |
run: | | |
brew install openblas | |
gfortran_path=$( which gfortran-${{ env.GCC_V }} ) | |
gcc_path=$( which gcc-${{ env.GCC_V }} ) | |
gplusplus_path=$( which g++-${{ env.GCC_V }} ) | |
export FC=$gfortran_path | |
export CC=$gcc_path | |
export CXX=$gplusplus_path | |
ln -s $gfortran_path /usr/local/bin/gfortran | |
ln -s $gcc_path /usr/local/bin/gcc | |
ln -s $gplusplus_path /usr/local/bin/g++ | |
echo "PKG_CONFIG_PATH=/usr/local/opt/openblas/lib/pkgconfig" >> $GITHUB_ENV | |
echo "LDFLAGS=-L/opt/homebrew/opt/openblas/lib" >> $GITHUB_ENV | |
echo "CPPFLAGS=-I/opt/homebrew/opt/openblas/include" >> $GITHUB_ENV | |
- name: Install GCC (Linux) | |
if: ${{ contains(matrix.os, 'ubuntu') && matrix.compiler == 'gnu' }} | |
run: | | |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test | |
sudo apt-get update | |
sudo apt-get install -y gcc-${{ env.GCC_V}} gfortran-${{ env.GCC_V }} | |
sudo update-alternatives \ | |
--install /usr/bin/gcc gcc /usr/bin/gcc-${{ env.GCC_V }} 100 \ | |
--slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${{ env.GCC_V }} \ | |
--slave /usr/bin/gcov gcov /usr/bin/gcov-${{ env.GCC_V }} | |
- name: Install GCC (Windows) | |
if: ${{ contains(matrix.os, 'windows') && matrix.compiler == 'gnu' }} | |
uses: msys2/setup-msys2@v2 | |
with: | |
msystem: MINGW64 | |
update: false | |
install: >- | |
git | |
mingw-w64-x86_64-gcc-fortran | |
mingw-w64-x86_64-openblas | |
mingw-w64-x86_64-lapack | |
mingw-w64-x86_64-cmake | |
mingw-w64-x86_64-meson | |
mingw-w64-x86_64-ninja | |
- name: Install fpm | |
if: ${{ matrix.build == 'fpm' }} | |
uses: fortran-lang/setup-fpm@v5 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Prepare for cache restore | |
if: ${{ matrix.compiler == 'intel' }} | |
run: | | |
sudo mkdir -p /opt/intel | |
sudo chown $USER /opt/intel | |
- name: Cache Intel install | |
if: ${{ matrix.compiler == 'intel' }} | |
id: cache-install | |
uses: actions/cache@v4 | |
with: | |
path: /opt/intel/oneapi | |
key: install-${{ matrix.compiler }}-${{ matrix.version }}-${{ matrix.os }} | |
- name: Install Intel (Linux) | |
if: ${{ contains(matrix.os, 'ubuntu') && contains(matrix.compiler, 'intel') && steps.cache-install.outputs.cache-hit != 'true' }} | |
run: | | |
wget https://apt.repos.intel.com/intel-gpg-keys/${{ env.KEY }} | |
sudo apt-key add ${{ env.KEY }} | |
rm ${{ env.KEY }} | |
echo "deb https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list | |
sudo apt-get update | |
sudo apt-get install ${{ env.PKG }} | |
env: | |
KEY: GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB | |
PKG: ${{ env.LINUX_INTEL_COMPONENTS }} | |
- name: Setup Intel oneAPI environment | |
if: ${{ matrix.compiler == 'intel' }} | |
run: | | |
source /opt/intel/oneapi/setvars.sh | |
printenv >> $GITHUB_ENV | |
- name: Install build and test dependencies | |
if: ${{ ! contains(matrix.os, 'windows') }} | |
run: pip3 install ${{ env.PIP_PACKAGES }} ${{ env.PIP_EXTRAS }} | |
- name: Configure build (meson) | |
if: ${{ matrix.build == 'meson' }} | |
run: >- | |
meson setup ${{ env.BUILD_DIR }} | |
--buildtype=debug | |
--prefix=$PWD/_dist | |
--libdir=lib | |
--warnlevel=0 | |
-Db_coverage=${{ env.COVERAGE }} | |
${{ env.MESON_ARGS }} | |
env: | |
COVERAGE: ${{ matrix.build-type == 'coverage' }} | |
MESON_ARGS: >- | |
${{ matrix.compiler == 'intel' && '-Dfortran_link_args=-qopenmp -Dapi=false' || '' }} | |
${{ contains(matrix.os, 'macos') && '-Dlapack=openblas' || '' }} | |
${{ contains(matrix.os, 'windows') && '-Dfortran_link_args=-Wl,--allow-multiple-definition' || '' }} | |
- name: CMake | |
if: ${{ matrix.build == 'cmake' }} | |
run: >- | |
CMAKE_ROOT=$(which cmake) | |
- name: Configure build (CMake) | |
if: ${{ matrix.build == 'cmake' }} | |
run: >- | |
cmake -B${{ env.BUILD_DIR }} | |
-GNinja | |
-DCMAKE_BUILD_TYPE=Debug | |
-DCMAKE_INSTALL_PREFIX=$PWD/_dist | |
-DCMAKE_INSTALL_LIBDIR=lib | |
- name: Build library (fpm) | |
if: ${{ matrix.build == 'fpm' }} | |
run: | | |
fpm --version | |
fpm build | |
- name: Build library | |
if: ${{ matrix.build != 'fpm' }} | |
run: ninja -C ${{ env.BUILD_DIR }} | |
- name: Run unit tests (fpm) | |
if: ${{ matrix.build == 'fpm' }} | |
run: fpm test | |
- name: Run unit tests (meson) | |
if: ${{ matrix.build == 'meson' }} | |
run: >- | |
meson test | |
-C ${{ env.BUILD_DIR }} | |
--print-errorlogs | |
--no-rebuild | |
--num-processes 1 | |
--suite tblite | |
-t 2 | |
env: | |
OMP_NUM_THREADS: 1,2,1 | |
- name: Run benchmarks | |
if: ${{ matrix.build == 'meson' }} | |
run: >- | |
meson test | |
-C ${{ env.BUILD_DIR }} | |
--print-errorlogs | |
--no-rebuild | |
--num-processes 1 | |
--suite tblite | |
-t 2 | |
--benchmark | |
- name: Run unit tests (ctest) | |
if: ${{ matrix.build == 'cmake' }} | |
run: | | |
ctest --output-on-failure --parallel 2 -R '^tblite/' | |
working-directory: ${{ env.BUILD_DIR }} | |
env: | |
OMP_NUM_THREADS: 1,2,1 | |
- name: Create coverage report | |
if: ${{ matrix.build == 'meson' && matrix.build-type == 'coverage' }} | |
run: | |
ninja -C ${{ env.BUILD_DIR }} coverage | |
- name: Install project | |
if: ${{ matrix.build != 'fpm' }} | |
run: | | |
ninja -C ${{ env.BUILD_DIR }} install | |
echo "TBLITE_PREFIX=$PWD/_dist" >> $GITHUB_ENV | |
- name: Create package | |
if: ${{ matrix.build == 'meson' && matrix.version == 12 && matrix.build-type == 'debug' && matrix.compiler == 'gnu' }} | |
run: | | |
tar cvf ${{ env.OUTPUT }} _dist | |
xz -T0 ${{ env.OUTPUT }} | |
echo "TBLITE_OUTPUT=${{ env.OUTPUT }}.xz" >> $GITHUB_ENV | |
env: | |
OUTPUT: tblite-${{ matrix.compiler }}-${{ matrix.version }}-${{ matrix.os }}.tar | |
- name: Upload package | |
if: ${{ matrix.build == 'meson' && matrix.version == 12 && matrix.build-type == 'debug' && matrix.compiler == 'gnu' }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.TBLITE_OUTPUT }} | |
path: ${{ env.TBLITE_OUTPUT }} | |
- name: Upload coverage report | |
if: ${{ matrix.build == 'meson' && matrix.build-type == 'coverage' }} | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
python: | |
needs: | |
- build | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest] | |
gcc_v: [12] | |
python_v: ['3.7', '3.8', '3.9'] | |
include: | |
- os: macos-latest | |
gcc_v: 12 | |
python_v: '3.9' | |
env: | |
FC: gfortran | |
CC: gcc | |
GCC_V: ${{ matrix.gcc_v }} | |
PYTHON_V: ${{ matrix.python_v }} | |
OMP_NUM_THREADS: 2,1 | |
TBLITE_OUTPUT: tblite-gnu-${{ matrix.gcc_v }}-${{ matrix.os }}.tar.xz | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python_v }} | |
- name: Link pre-installed GCC and FC (macOS) | |
if: ${{ contains(matrix.os, 'macos')}} | |
run: | | |
brew install openblas | |
gfortran_path=$( which gfortran-${{ env.GCC_V }} ) | |
gcc_path=$( which gcc-${{ env.GCC_V }} ) | |
gplusplus_path=$( which g++-${{ env.GCC_V }} ) | |
export FC=$gfortran_path | |
export CC=$gcc_path | |
export CXX=$gplusplus_path | |
ln -s $gfortran_path /usr/local/bin/gfortran | |
ln -s $gcc_path /usr/local/bin/gcc | |
ln -s $gplusplus_path /usr/local/bin/g++ | |
echo "PKG_CONFIG_PATH=/usr/local/opt/openblas/lib/pkgconfig" >> $GITHUB_ENV | |
echo "LDFLAGS=-L/opt/homebrew/opt/openblas/lib" >> $GITHUB_ENV | |
echo "CPPFLAGS=-I/opt/homebrew/opt/openblas/include" >> $GITHUB_ENV | |
- name: Install GCC (Linux) | |
if: ${{ contains(matrix.os, 'ubuntu') }} | |
run: >- | |
sudo update-alternatives | |
--install /usr/bin/gcc gcc /usr/bin/gcc-${{ env.GCC_V }} 100 | |
--slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${{ env.GCC_V }} | |
--slave /usr/bin/gcov gcov /usr/bin/gcov-${{ env.GCC_V }} | |
- name: Install meson and test dependencies | |
run: pip3 install ${{ env.PIP_EXTRAS }} | |
- name: Download package | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ env.TBLITE_OUTPUT }} | |
- name: Unpack package | |
run: | | |
tar xvf ${{ env.TBLITE_OUTPUT }} | |
echo "TBLITE_PREFIX=$PWD/_dist" >> $GITHUB_ENV | |
- name: Install Python extension module (pip) | |
run: pip3 install . --user | |
working-directory: python | |
env: | |
PKG_CONFIG_PATH: ${{ env.PKG_CONFIG_PATH }}:${{ env.TBLITE_PREFIX }}/lib/pkgconfig | |
- name: Test Python API | |
run: pytest --pyargs tblite --cov=tblite -vv | |
env: | |
LD_LIBRARY_PATH: ${{ env.LD_LIBRARY_PATH }}:${{ env.TBLITE_PREFIX }}/lib | |
DYLD_LIBRARY_PATH: ${{ env.DYLD_LIBRARY_PATH }}:${{ env.TBLITE_PREFIX }}/lib | |
- name: Upload coverage report | |
uses: codecov/codecov-action@v3 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} |