-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #192 from AlexanderRichert-NOAA/add_spack_ci
Add Spack-based CI workflow
- Loading branch information
Showing
4 changed files
with
162 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# This is a CI workflow for the NCEPLIBS-w3emc project. | ||
# | ||
# This workflow builds w3emc 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"] | ||
pic_shared_extradeps: ["+pic +shared", "+pic ~shared +extradeps", "+pic ~shared ~extradeps", "~pic +extradeps", "~pic ~extradeps"] | ||
precision: ["precision=d", "precision=4", "precision=8"] | ||
bufr: ["~bufr"] | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
|
||
- name: checkout-w3emc | ||
uses: actions/checkout@v4 | ||
with: | ||
path: w3emc | ||
|
||
- name: spack-build-and-test | ||
run: | | ||
git clone -c feature.manyFiles=true https://github.com/jcsda/spack | ||
. spack/share/spack/setup-env.sh | ||
spack env create w3emc-env | ||
spack env activate w3emc-env | ||
cp $GITHUB_WORKSPACE/w3emc/spack/package.py $SPACK_ROOT/var/spack/repos/builtin/packages/w3emc/package.py | ||
mv $GITHUB_WORKSPACE/w3emc $SPACK_ENV/w3emc | ||
spack develop --no-clone w3emc@develop | ||
spack add w3emc@develop%gcc@11 ${{ matrix.pic_shared_extradeps }} ${{ matrix.precision }} ${{ matrix.bufr }} | ||
spack external find cmake gmake | ||
spack concretize | ||
# Run installation and run CTest suite | ||
spack install --verbose --fail-fast --test root | ||
# Run 'spack load' to check for obvious errors in setup_run_environment | ||
spack load w3emc | ||
# This job validates the Spack recipe by making sure each cmake build option is represented | ||
recipe-check: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
|
||
- name: checkout-w3emc | ||
uses: actions/checkout@v4 | ||
with: | ||
path: w3emc | ||
|
||
- 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/w3emc/CMakeLists.txt) ; do | ||
echo "Checking for presence of '$opt' CMake option in package.py" | ||
grep -cP "define.+\b${opt}\b" $GITHUB_WORKSPACE/w3emc/spack/package.py | ||
done |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
This directory contains an authoritative, up-to-date Spack recipe for NCEPLIBS-w3emc, which is found under Spack as "w3emc". | ||
|
||
Before each release of NCEPLIBS-w3emc, this file should be updated to accommodate changes in build options, etc., and .github/workflows/spack.yml should be updated to exercise all variants. Only the version entry should need to be updated after the release prior to incorporation into the Spack repository and the JCSDA Spack fork. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# Copyright 2013-2023 Lawrence Livermore National Security, LLC and other | ||
# Spack Project Developers. See the top-level COPYRIGHT file for details. | ||
# | ||
# SPDX-License-Identifier: (Apache-2.0 OR MIT) | ||
|
||
from spack.package import * | ||
|
||
|
||
class W3emc(CMakePackage): | ||
"""This library contains Fortran 90 decoder/encoder routines for GRIB | ||
edition 1 with EMC changes. | ||
This is part of the NCEPLIBS project.""" | ||
|
||
homepage = "https://noaa-emc.github.io/NCEPLIBS-w3emc/" | ||
url = "https://github.com/NOAA-EMC/NCEPLIBS-w3emc/archive/refs/tags/v2.9.0.tar.gz" | ||
git = "https://github.com/NOAA-EMC/NCEPLIBS-w3emc" | ||
|
||
maintainers("AlexanderRichert-NOAA", "Hang-Lei-NOAA", "edwardhartnett") | ||
|
||
version("develop", branch="develop") | ||
version("2.10.0", sha256="366b55a0425fc3e729ecb9f3b236250349399fe4c8e19f325500463043fd2f18") | ||
version("2.9.3", sha256="9ca1b08dd13dfbad4a955257ae0cf38d2e300ccd8d983606212bc982370a29bc") | ||
version("2.9.2", sha256="eace811a1365f69b85fdf2bcd93a9d963ba72de5a7111e6fa7c0e6578b69bfbc") | ||
version("2.9.1", sha256="d3e705615bdd0b76a40751337d943d5a1ea415636f4e5368aed058f074b85df4") | ||
version("2.9.0", sha256="994f59635ab91e34e96cab5fbaf8de54389d09461c7bac33b3104a1187e6c98a") | ||
version("2.7.3", sha256="eace811a1365f69b85fdf2bcd93a9d963ba72de5a7111e6fa7c0e6578b69bfbc") | ||
|
||
variant("pic", default=True, description="Build with position-independent-code") | ||
variant("bufr", default=False, description="Build with BUFR routines", when="@2.10:") | ||
variant( | ||
"precision", | ||
default=("4", "d"), | ||
values=("4", "d", "8"), | ||
multi=True, | ||
description="Set precision (_4/_d/_8 library versions)", | ||
when="@2.10:", | ||
) | ||
variant("shared", default=False, description="Build shared library", when="@2.10: +pic") | ||
variant( | ||
"extradeps", | ||
default=False, | ||
description="Build w3emc with subprograms which call unknown dependencies", | ||
when="@2.10:", | ||
) | ||
|
||
conflicts("+shared +extradeps", msg="Shared library cannot be built with unknown dependencies") | ||
|
||
depends_on("bufr", when="@2.10: +bufr") | ||
depends_on("bacio", when="@2.9.2:") | ||
|
||
# w3emc 2.7.3 contains gblevents which has these dependencies | ||
depends_on("nemsio", when="@2.7.3") | ||
depends_on("sigio", when="@2.7.3") | ||
depends_on("netcdf-fortran", when="@2.7.3") | ||
|
||
def setup_run_environment(self, env): | ||
if self.spec.satisfies("@:2.9"): | ||
suffixes = ("4", "d", "8") | ||
shared = False | ||
else: | ||
suffixes = self.spec.variants["precision"].value | ||
shared = self.spec.satisfies("+shared") | ||
|
||
for suffix in suffixes: | ||
lib = find_libraries( | ||
"libw3emc_" + suffix, root=self.prefix, shared=shared, recursive=True | ||
) | ||
env.set("W3EMC_LIB" + suffix, lib[0]) | ||
env.set("W3EMC_INC" + suffix, join_path(self.prefix, "include_" + suffix)) | ||
|
||
def cmake_args(self): | ||
args = [ | ||
self.define_from_variant("BUILD_WITH_BUFR", "bufr"), | ||
self.define_from_variant("CMAKE_POSITION_INDEPENDENT_CODE", "pic"), | ||
self.define("BUILD_4", self.spec.satisfies("precision=4")), | ||
self.define("BUILD_D", self.spec.satisfies("precision=d")), | ||
self.define("BUILD_8", self.spec.satisfies("precision=8")), | ||
self.define_from_variant("BUILD_SHARED_LIBS", "shared"), | ||
self.define_from_variant("BUILD_WITH_EXTRA_DEPS", "extradeps"), | ||
] | ||
|
||
return args | ||
|
||
def check(self): | ||
with working_dir(self.builder.build_directory): | ||
make("test") |