-
Notifications
You must be signed in to change notification settings - Fork 6
73 lines (68 loc) · 2.63 KB
/
build_packages.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
name: Build Packages
on:
push:
branches:
- main
tags:
- '*'
pull_request:
jobs:
generate-matrix:
name: Generate matrix for build
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
empty: ${{ steps.set-matrix.outputs.empty }}
steps:
- run: echo "FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> "${GITHUB_ENV}"
- uses: actions/checkout@v3
with:
fetch-depth: ${{ env.FETCH_DEPTH }}
- id: set-matrix
run: |
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)
EMPTY=true
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"
EMPTY=false
fi
done
# Remove last "," and add closing brackets
if [[ $JSON == *, ]]; then
JSON="${JSON%?}"
fi
JSON="$JSON]}"
echo $JSON
# Set output
echo "matrix=$( echo "$JSON" )" >> $GITHUB_OUTPUT
echo "empty=$EMPTY" >> $GITHUB_OUTPUT
concretize:
name: Build ${{ matrix.pkg }}
needs: generate-matrix
if: needs.generate-matrix.outputs.empty == 'false'
strategy:
fail-fast: false
matrix: ${{fromJson(needs.generate-matrix.outputs.matrix)}}
runs-on: ubuntu-latest
container: ghcr.io/spack/ubuntu-jammy:${{ github.event.pull_request.base.ref || github.ref }}
steps:
- uses: actions/checkout@v3
- name: Setup eic-spack repository
run: |
. /opt/spack/share/spack/setup-env.sh
spack repo add $PWD
spack repo list
- name: Concretize package ${{ matrix.pkg }}
run: |
. /opt/spack/share/spack/setup-env.sh
spack spec -I ${{ matrix.pkg }}