Skip to content

Commit

Permalink
add spack-based CI build (NOAA-EMC#100)
Browse files Browse the repository at this point in the history
* adding package file

* adding spack CI build

* trying to get spack build to work

* trying to get spack build to work

* trying to get spack build to work

* trying to fix spack workflow

* Update package.py

---------

Co-authored-by: Alex Richert <82525672+AlexanderRichert-NOAA@users.noreply.github.com>
  • Loading branch information
edwardhartnett and AlexanderRichert-NOAA committed Oct 11, 2023
1 parent 71c53db commit f62e0ef
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 0 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/Spack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# This is a CI workflow for the NCEPLIBS-g2tmpl 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"]

runs-on: ${{ matrix.os }}

steps:

- name: checkout-g2tmpl
uses: actions/checkout@v4
with:
path: g2tmpl

- 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 g2tmpl-env
spack env activate g2tmpl-env
cp $GITHUB_WORKSPACE/g2tmpl/spack/package.py $SPACK_ROOT/var/spack/repos/builtin/packages/g2tmpl/package.py
mv $GITHUB_WORKSPACE/g2tmpl $SPACK_ENV/g2tmpl
spack develop --no-clone g2tmpl@develop
spack add g2tmpl@develop%gcc@11
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 g2tmpl
# This job validates the Spack recipe by making sure each cmake build option is represented
recipe-check:
runs-on: ubuntu-latest

steps:

- name: checkout-g2tmpl
uses: actions/checkout@v4
with:
path: g2tmpl

- 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/g2tmpl/CMakeLists.txt) ; do
echo "Checking for presence of '$opt' CMake option in package.py"
grep -cP "define.+\b${opt}\b" $GITHUB_WORKSPACE/g2tmpl/spack/package.py
done
33 changes: 33 additions & 0 deletions spack/package.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# 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 G2tmpl(CMakePackage):
"""Utilities for GRIB2 templates.
This is part of NOAA's NCEPLIBS project."""

homepage = "https://github.com/NOAA-EMC/NCEPLIBS-g2tmpl"
url = "https://github.com/NOAA-EMC/NCEPLIBS-g2tmpl/archive/refs/tags/v1.10.0.tar.gz"
git = "https://github.com/NOAA-EMC/NCEPLIBS-g2tmpl"

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

version("develop", branch="develop")
version("1.10.2", sha256="4063361369f3691f75288c801fa9d1a2414908b7d6c07bbf69d4165802e2a7fc")
version("1.10.1", sha256="0be425e5128fabb89915a92261aa75c27a46a3e115e00c686fc311321e5d1e2a")
version("1.10.0", sha256="dcc0e40b8952f91d518c59df7af64e099131c17d85d910075bfa474c8822649d")

variant("shared", default=False, description="Build shared library")

def cmake_args(self):
args = [self.define_from_variant("BUILD_SHARED_LIBS", "shared")]
return args

def check(self):
with working_dir(self.builder.build_directory):
make("test")

0 comments on commit f62e0ef

Please sign in to comment.