From f003b810867e74049eece4ce6a48399905984793 Mon Sep 17 00:00:00 2001 From: Sebastian Schmitt <sebastian.schmitt@kip.uni-heidelberg.de> Date: Mon, 5 Jul 2021 07:39:53 +0200 Subject: [PATCH] Add CI for the in-repo Spack package (#1544) Run only on Linux and Spack/develop closes #1534 --- .github/workflows/spack.yml | 20 ++++++++++++ scripts/build_spack_package.sh | 57 ++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 .github/workflows/spack.yml create mode 100755 scripts/build_spack_package.sh diff --git a/.github/workflows/spack.yml b/.github/workflows/spack.yml new file mode 100644 index 00000000..35de7882 --- /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 00000000..d5fe48d8 --- /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 -- GitLab