diff --git a/.github/workflows/spack.yml b/.github/workflows/spack.yml new file mode 100644 index 0000000000000000000000000000000000000000..35de78828425eea863296ad134c1a0d9bc6da961 --- /dev/null +++ b/.github/workflows/spack.yml @@ -0,0 +1,20 @@ +name: Spack + +on: + push: + branches: [ master ] + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + python-version: [3.8] + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: arbor + - name: Build Arbor's Spack package against the develop branch + run: arbor/scripts/build_spack_package.sh arbor develop diff --git a/scripts/build_spack_package.sh b/scripts/build_spack_package.sh new file mode 100755 index 0000000000000000000000000000000000000000..d5fe48d8c9330208aea74e89e8147d9162c2ceef --- /dev/null +++ b/scripts/build_spack_package.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash +# checks out Spack and Arbor and builds it with the package.py from Arbor's repo +# Spack can be the latest release or the develop branch + +set -Eeuo pipefail + +if [[ "$#" -ne 2 ]]; then + echo "Builds the in-repo Spack package of Arbor against the latest Spack release or a given Spack branch" + echo "usage: build_spack_package.sh arbor_source_directory latest_release|develop" + exit 1 +fi + +trap cleanup SIGINT SIGTERM ERR EXIT + +cleanup() { + trap - SIGINT SIGTERM ERR EXIT + rm -rf "$TMP_DIR" +} + +TMP_DIR=$(mktemp -d) +ARBOR_SOURCE=$1 + +ARBOR_DIR=$TMP_DIR/arbor +mkdir $ARBOR_DIR +cp -r $ARBOR_SOURCE/* $ARBOR_DIR + +cd "$TMP_DIR" + +SPACK_DIR=spack +SPACK_REPO=https://github.com/spack/spack +SPACK_CUSTOM_REPO=custom_repo + +SPACK_VERSION=$2 # latest_release or develop +SPACK_BRANCH=develop # only used for develop + +case $SPACK_VERSION in + "develop") + git clone --depth 1 --branch $SPACK_BRANCH $SPACK_REPO $SPACK_DIR + ;; + "latest_release") + wget "$(curl -sH "Accept: application/vnd.github.v3+json" https://api.github.com/repos/spack/spack/releases/latest | grep browser_download_url | cut -d '"' -f 4)" + tar xfz spack*.tar.gz + ln -s spack*/ $SPACK_DIR + ;; + *) + echo "SPACK_VERSION" must be \"latest_release\" or \"develop\" + exit 1 +esac +source $SPACK_DIR/share/spack/setup-env.sh +spack repo create $SPACK_CUSTOM_REPO + +mkdir -p $SPACK_CUSTOM_REPO/packages/arbor +spack repo add $SPACK_CUSTOM_REPO + +cp $ARBOR_DIR/spack/package.py $SPACK_CUSTOM_REPO/packages/arbor +cd $ARBOR_DIR +spack dev-build arbor@with-package-from-repo