-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
143 lines (129 loc) · 4.7 KB
/
action.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
name: 'Build Mochi release with Spack'
description: 'Build the release of a specified Mochi package using Spack'
inputs:
spack-version:
description: 'Version of spack to use'
required: false
default: 'develop'
mochi-spack-packages-version:
description: 'Version or commit hash of the mochi-spack-packages'
required: false
default: 'main'
package-name:
description: 'Package to build'
required: false
default: 'unspecified'
package-version:
description: 'Version of the package to build (should start with @)'
require: false
default: ''
build-cache-token:
description: 'Token to use to push into the build cache'
required: false
default: 'unspecified'
push-only-dependencies:
description: 'Only push dependencies to build cache'
required: false
default: 'true'
runs:
using: "composite"
steps:
- name: Setup spack
uses: spack/setup-spack@v2.1.1
with:
ref: ${{ inputs.spack-version }}
- name: Extract name of calling repository
id: extract_repo_name
if: ${{ inputs.package-name == 'unspecified' }}
shell: bash
run: |
REPO_NAME=$(echo "${GITHUB_REPOSITORY}" | cut -d'/' -f2)
echo "repo_name=$REPO_NAME" >> $GITHUB_OUTPUT
- name: Find the package name
id: determine_name
shell: bash
run: |
if [[ "${{ inputs.package-name }}" == "unspecified" ]]; then
PACKAGE_NAME="${{ steps.extract_repo_name.outputs.repo_name }}"
else
PACKAGE_NAME="${{ inputs.package-name }}"
fi
echo "package_name=$PACKAGE_NAME" >> $GITHUB_OUTPUT
- name: Create environment
shell: bash
run: |
spack env create myenv "$GITHUB_ACTION_PATH"/spack.yaml
- name: Add mochi-spack-packages
shell: bash
run: |
git clone https://github.com/mochi-hpc/mochi-spack-packages
pushd mochi-spack-packages
git checkout ${{ inputs.mochi-spack-packages-version }}
popd
spack -e myenv repo add mochi-spack-packages
- name: Add package to environment
shell: bash
run: |
spack -e myenv add \
"${{steps.determine_name.outputs.package_name}}${{inputs.package-version}}"
- name: Install environment
shell: bash
run: |
spack -e myenv concretize --fresh
spack -e myenv install
- name: Find and check Spack dependencies
if: ${{ (inputs.build-cache-token != 'unspecified') && (inputs.push-only-dependencies == 'true')}}
shell: bash
run: |
spack -e myenv find --no-groups -X \
| awk 'BEGIN { skip=1 } /^$/ { skip=0; next } skip==0 { print }' > specs.txt
if grep -qE "@develop|@master|@main" specs.txt; then
echo "Error: Found develop dependencies (@develop, @master, or @main) in specs.txt." >&2
echo "------ Specs are the following:" >&2
cat specs.txt >&2
exit 1
else
echo "No develop dependencies found. Workflow can proceed."
fi
- name: Find and check Spack dependencies
if: ${{ (inputs.build-cache-token != 'unspecified') && (inputs.push-only-dependencies == 'false')}}
shell: bash
run: |
spack -e myenv find --no-groups \
| awk 'BEGIN { skip=1 } /^$/ { skip=0; next } skip==0 { print }' > specs.txt
if grep -qE "@develop|@master|@main" specs.txt; then
echo "Error: Found develop dependencies (@develop, @master, or @main) in specs.txt." >&2
echo "------ Specs are the following:" >&2
cat specs.txt >&2
exit 1
else
echo "No develop dependencies found. Workflow can proceed."
fi
- name: Add token to buildcache
if: ${{ inputs.build-cache-token != 'unspecified' }}
shell: bash
run: |
spack -e myenv mirror set --push \
--oci-username ${{ github.actor }} \
--oci-password-variable MY_OCI_TOKEN mochi-buildcache
- name: Push dependency packages to buildcache and update index
if: ${{ (inputs.build-cache-token != 'unspecified') && (inputs.push-only-dependencies == 'true') }}
shell: bash
run: |
MY_OCI_TOKEN=${{ inputs.build-cache-token }} \
spack -e myenv buildcache push --base-image ubuntu:22.04 \
--unsigned --only dependencies --update-index mochi-buildcache
- name: Push dependency packages to buildcache and update index
if: ${{ (inputs.build-cache-token != 'unspecified') && (inputs.push-only-dependencies == 'false') }}
shell: bash
run: |
MY_OCI_TOKEN=${{ inputs.build-cache-token }} \
spack -e myenv buildcache push --base-image ubuntu:22.04 \
--unsigned --update-index mochi-buildcache
- name: Cleanup mochi-spack-packages
shell: bash
run: |
spack env rm -y myenv
spack uninstall -y --all
spack clean --all
rm -rf mochi-spack-packages