Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Spack-based CI #192

Merged
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3318718
Add Spack-based CI
AlexanderRichert-NOAA Sep 6, 2023
6ed3337
Update spack recipe
AlexanderRichert-NOAA Sep 6, 2023
e41b862
Disable testing by default
AlexanderRichert-NOAA Sep 6, 2023
44f0057
package.py require appropriate precision for sp
AlexanderRichert-NOAA Sep 11, 2023
283bae5
Merge branch 'develop' into add_spack_ci
AlexanderRichert-NOAA Sep 11, 2023
f71bc8b
Rename spack.yml->Spack_Linux.yml
AlexanderRichert-NOAA Sep 11, 2023
0c9d2f6
Add macos to spack CI
AlexanderRichert-NOAA Sep 11, 2023
1016e65
Update package.py
AlexanderRichert-NOAA Sep 11, 2023
8241964
Update Spack.yml
AlexanderRichert-NOAA Sep 11, 2023
3a91193
Update CMakeLists.txt
AlexanderRichert-NOAA Sep 11, 2023
3f899ed
Update Spack.yml
AlexanderRichert-NOAA Sep 11, 2023
5bfed1f
update package.py
AlexanderRichert-NOAA Sep 12, 2023
0bdb20e
add explicit build_check to recipe
AlexanderRichert-NOAA Sep 12, 2023
d07d81a
allow parallel ctest in spack recipe
AlexanderRichert-NOAA Sep 12, 2023
30c0ef1
u
AlexanderRichert-NOAA Sep 12, 2023
d7adac8
undo parallel thing
AlexanderRichert-NOAA Sep 12, 2023
97aa67b
self.builder.build_directory
AlexanderRichert-NOAA Sep 12, 2023
39904a1
debugging
AlexanderRichert-NOAA Sep 12, 2023
f30e4ea
debug
AlexanderRichert-NOAA Sep 12, 2023
5fb4d71
debug
AlexanderRichert-NOAA Sep 12, 2023
d7f02f6
more debug...
AlexanderRichert-NOAA Sep 12, 2023
42e255c
reduce matrix for debugging
AlexanderRichert-NOAA Sep 12, 2023
e5d6eb9
revert debug tweaks
AlexanderRichert-NOAA Sep 12, 2023
9652348
u
AlexanderRichert-NOAA Sep 12, 2023
725e294
u
AlexanderRichert-NOAA Sep 12, 2023
7d4f976
revert debug tweaks, pt 2
AlexanderRichert-NOAA Sep 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .github/workflows/Spack_Linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# 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
Linux:
runs-on: ubuntu-latest

strategy:
matrix:
openmp: ["+openmp", "~openmp"]
sharedlibs: ["+shared", "~shared"]
pic: ["+pic", "~pic"]
precision: ["precision=d", "precision=4", "precision=8"]

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
mv $GITHUB_WORKSPACE/ip $SPACK_ENV/ip
spack develop --no-clone ip@develop
spack add ip@develop%gcc@11 ${{ matrix.openmp }} ${{ matrix.sharedlibs }} ${{ matrix.pic }} ${{ matrix.precision }}
spack external find cmake gmake
spack concretize
spack install --verbose --test root

# 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
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
option(BUILD_4 "Build the 4-byte real version of the library, libip_4.a" ON)
option(BUILD_D "Build the 8-byte real version of the library, libip_d.a" ON)
option(BUILD_8 "Build the 8-byte integer version of the library, libsp_8.a" OFF)
option(BUILD_TESTING "Build tests of the library" ON)

# Figure whether user wants a _4, a _d, and/or _8.
if(BUILD_4)
Expand Down
3 changes: 3 additions & 0 deletions spack/README
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-ip, which is found under Spack as "ip".

Before each release of NCEPLIBS-ip, 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.
84 changes: 84 additions & 0 deletions spack/package.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# 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 Ip(CMakePackage):
"""The NCEP general interpolation library (iplib) contains Fortran 90
subprograms to be used for interpolating between nearly all grids used at
NCEP. This is part of the NCEPLIBS project."""

homepage = "https://noaa-emc.github.io/NCEPLIBS-ip"
url = "https://github.com/NOAA-EMC/NCEPLIBS-ip/archive/refs/tags/v3.3.3.tar.gz"

maintainers("t-brown", "AlexanderRichert-NOAA", "edwardhartnett", "Hang-Lei-NOAA")

version("4.1.0", sha256="b83ca037d9a5ad3eb0fb1acfe665c38b51e01f6bd73ce9fb8bb2a14f5f63cdbe")
version("4.0.0", sha256="a2ef0cc4e4012f9cb0389fab6097407f4c623eb49772d96eb80c44f804aa86b8")
version(
"3.3.3",
sha256="d5a569ca7c8225a3ade64ef5cd68f3319bcd11f6f86eb3dba901d93842eb3633",
preferred=True,
)

variant("openmp", description="Enable OpenMP threading", default=True)
variant("pic", default=True, description="Build with position-independent-code")
variant("shared", default=False, description="Build shared library", when="@4.1:")
variant(
"precision",
default=["4", "d"],
values=["4", "d"],
multi=True,
description="Set precision (_4/_d library versions)",
when="@4.1:",
)
variant(
"precision",
default=["4", "d"],
values=["4", "d", "8"],
multi=True,
description="Set precision (_4/_d/_8 library versions)",
when="@develop",
)

depends_on("sp")
depends_on("sp@:2.3.3", when="@:4.0")
depends_on("sp precision=4", when="@4.1: precision=4")
depends_on("sp precision=d", when="@4.1: precision=d")
depends_on("sp precision=8", when="@4.1: precision=8")

def cmake_args(self):
args = [
self.define_from_variant("OPENMP", "openmp"),
self.define_from_variant("CMAKE_POSITION_INDEPENDENT_CODE", "pic"),
]

if self.spec.satisfies("@4:"):
args.append(self.define("ENABLE_TESTS", self.run_tests))

if self.spec.satisfies("@4.1:"):
args.append(self.define_from_variant("BUILD_SHARED_LIBS", "shared"))
args.append(self.define("BUILD_4", self.spec.satisfies("precision=4")))
args.append(self.define("BUILD_D", self.spec.satisfies("precision=d")))

if self.spec.satisfies("@develop"):
args.append(self.define("BUILD_8", self.spec.satisfies("precision=8")))

return args

def setup_run_environment(self, env):
suffixes = (
self.spec.variants["precision"].value
if self.spec.satisfies("@4.1:")
else ["4", "8", "d"]
)
shared = False if self.spec.satisfies("@:4.0") else self.spec.satisfies("+shared")
for suffix in suffixes:
lib = find_libraries(
"libip_" + suffix, root=self.prefix, shared=shared, recursive=True
)
env.set("IP_LIB" + suffix, lib[0])
env.set("IP_INC" + suffix, join_path(self.prefix, "include_" + suffix))
Loading