Skip to content

JANA2: Add v2.3.2 #1064

JANA2: Add v2.3.2

JANA2: Add v2.3.2 #1064

Workflow file for this run

name: Build Packages
on:
push:
branches:
- main
tags:
- '*'
pull_request:
jobs:
generate-matrix:
name: Generate matrix for build
runs-on: ubuntu-latest
outputs:
has-matrix: ${{ steps.set-matrix.outputs.has-matrix }}
matrix: ${{ steps.set-matrix.outputs.matrix }}
has-tag: ${{ steps.set-tag.outputs.has-tag }}
tag: ${{ steps.set-tag.outputs.tag }}
steps:
- name: Determine fetch depth
run: echo "FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> "${GITHUB_ENV}"
- uses: actions/checkout@v4
with:
path: eic-spack
fetch-depth: ${{ env.FETCH_DEPTH }}
- name: Set spack container tag
id: set-tag
run: |
base_ref=${{ github.event.pull_request.base.ref || github.ref }}
if [[ $base_ref =~ ^develop$ ]] ; then
TAG=latest
fi
if [[ $base_ref =~ ^releases/(v[0-9].[0-9]+)$ ]] ; then
TAG=${BASH_REMATCH[1]}.0
fi
if [ -n "$TAG" ] ; then
HAS_TAG=true
fi
echo "tag=${TAG:-}" | tee -a $GITHUB_OUTPUT
echo "has-tag=${HAS_TAG:-false}" | tee -a $GITHUB_OUTPUT
- name: Set modified package matrix
id: set-matrix
run: |
cd eic-spack
echo "github.sha=${{ github.sha }}"
echo "github.event.pull_request.head.sha=${{ github.event.pull_request.head.sha }}"
echo "github.event.pull_request.base.sha=${{ github.event.pull_request.base.sha }}"
git diff-tree --no-commit-id --name-only -r ${{ github.event.pull_request.head.sha || github.sha }} ${{ github.event.pull_request.base.sha }}
CHANGED_PACKAGES=$(git diff-tree --no-commit-id --name-only -r ${{ github.event.pull_request.head.sha }} ${{ github.event.pull_request.base.sha }} | sed 's|^packages/||' | xargs -I {} dirname {} | uniq)
JSON="{\"include\":["
for pkg in ${CHANGED_PACKAGES} ; do
if [ ! -d packages/$pkg ] ; then continue ; fi
if [ ! -f packages/$pkg/package.py ] ; then continue ; fi
# Add build to the matrix only if it is not already included
JSONline="{\"pkg\": \"$pkg\"},"
if [[ "$JSON" != *"$JSONline"* ]]; then
JSON="$JSON$JSONline"
HAS_MATRIX=true
fi
done
# Remove last "," and add closing brackets
if [[ $JSON == *, ]]; then
JSON="${JSON%?}"
fi
JSON="$JSON]}"
echo $JSON
# Set output
echo "matrix=$( echo "$JSON" )" | tee -a $GITHUB_OUTPUT
echo "has-matrix=${HAS_MATRIX:-false}" | tee -a $GITHUB_OUTPUT
concretize:
name: Build ${{ matrix.pkg }}
needs: generate-matrix
if: needs.generate-matrix.outputs.has-matrix == 'true' && needs.generate-matrix.outputs.has-tag == 'true'
strategy:
fail-fast: false
matrix: ${{fromJson(needs.generate-matrix.outputs.matrix)}}
runs-on: ubuntu-latest
container: ghcr.io/spack/ubuntu-jammy:${{needs.generate-matrix.outputs.tag}}
steps:
- uses: actions/checkout@v4
with:
path: key4hep-spack
repository: key4hep/key4hep-spack
- uses: actions/checkout@v4
with:
path: eic-spack
- name: Setup key4hep-spack and eic-spack repositories
run: |
. /opt/spack/share/spack/setup-env.sh
spack repo add ${GITHUB_WORKSPACE}/key4hep-spack
spack repo add ${GITHUB_WORKSPACE}/eic-spack
spack repo list
- name: Concretize package ${{ matrix.pkg }}
run: |
. /opt/spack/share/spack/setup-env.sh
spack spec -I ${{ matrix.pkg }}