Skip to content

Merge pull request #208 from NOAA-EMC/AlexanderRichert-NOAA-patch-2 #8

Merge pull request #208 from NOAA-EMC/AlexanderRichert-NOAA-patch-2

Merge pull request #208 from NOAA-EMC/AlexanderRichert-NOAA-patch-2 #8

Workflow file for this run

# This is a CI workflow for the NCEPLIBS-ip project.
#
# This workflow builds ip with Spack, including installing with the "--test
# root" option to run the CTest suite. It also has a one-off job that validates
# the recipe by ensuring that every CMake option that should be set in the
# Spack recipe is so set.
#
# Alex Richert, Sep 2023
name: Spack
on:
push:
branches:
- develop
pull_request:
branches:
- develop
jobs:
# This job builds with Spack using every combination of variants and runs the CTest suite each time
Spack:
strategy:
matrix:
os: ["ubuntu-latest"]
openmp: ["+openmp", "~openmp"]
sharedlibs: ["+shared", "~shared"]
pic: ["+pic", "~pic"]
precision: ["d", "4", "8"]
runs-on: ${{ matrix.os }}
steps:
- name: checkout-ip
uses: actions/checkout@v4
with:
path: ip
- name: spack-build-and-test
run: |
git clone -c feature.manyFiles=true https://github.com/spack/spack
. spack/share/spack/setup-env.sh
spack env create ip-env
spack env activate ip-env
cp $GITHUB_WORKSPACE/ip/spack/package.py $SPACK_ROOT/var/spack/repos/builtin/packages/ip/package.py
spack develop --no-clone --path $GITHUB_WORKSPACE/ip ip@develop
spack add ip@develop%gcc@11 ${{ matrix.openmp }} ${{ matrix.sharedlibs }} ${{ matrix.pic }} precision=${{ matrix.precision }} target=x86_64
if [ ${{ matrix.precision }} == "d" ]; then spack add grib-util@develop ; fi
spack external find cmake gmake
spack concretize
# Run installation and run CTest suite
spack install --verbose --fail-fast --test root
# Run 'spack load' and check that key build options were respected
spack load ip
if [ ${{ matrix.sharedlibs }} == "+shared" ]; then suffix="so" ; else suffix="a"; fi
ls ${IP_LIB${{ matrix.precision }}} | grep -cE '/libip_${{ matrix.precision }}\.'$suffix'$'
# This job validates the Spack recipe by making sure each cmake build option is represented
recipe-check:
runs-on: ubuntu-latest
steps:
- name: checkout-ip
uses: actions/checkout@v4
with:
path: ip
- name: recipe-check
run: |
echo "If this jobs fails, look at the most recently output CMake option below and make sure that option appears in spack/package.py"
for opt in $(grep -ioP '^option\(\K(?!(ENABLE_DOCS))[^ ]+' $GITHUB_WORKSPACE/ip/CMakeLists.txt) ; do
echo "Checking for presence of '$opt' CMake option in package.py"
grep -cP "define.+\b${opt}\b" $GITHUB_WORKSPACE/ip/spack/package.py
done