Skip to content

Commit 0aa2c7f

Browse files
committed
settings-2-deploy.yml: Deployment works for spack>=1.0's builtin-spack-packages
1 parent d5f27d8 commit 0aa2c7f

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

.github/workflows/settings-2-deploy.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,23 @@ jobs:
5555
echo "$updates" >> $GITHUB_OUTPUT
5656
echo "EOF" >> $GITHUB_OUTPUT
5757
58+
- name: Setup builtin spack-packages updates
59+
id: builtin-spack-packages
60+
# Notably, only the spack instances that are >=1.0 and have builtin-spack-packages entries will produce any output here
61+
run: |
62+
updates=$(jq --compact-output --raw-output \
63+
--arg env "${{ inputs.deployment-environment }}" \
64+
--arg type "${{ inputs.spack-type }}" \
65+
'.deployment[$env][$type] | to_entries[] | select(.value."builtin-spack-packages" != null) | "\(.key) \(.value."builtin-spack-packages")"' \
66+
${{ env.CONFIG_SETTINGS_PATH }}
67+
)
68+
69+
echo "$updates"
70+
# For multiline output, use a heredoc. See https://github.com/orgs/community/discussions/116619#discussioncomment-8994849
71+
echo "updates<<EOF" >> $GITHUB_OUTPUT
72+
echo "$updates" >> $GITHUB_OUTPUT
73+
echo "EOF" >> $GITHUB_OUTPUT
74+
5875
- name: Setup SSH
5976
id: ssh
6077
uses: access-nri/actions/.github/actions/setup-ssh@main
@@ -119,10 +136,46 @@ jobs:
119136
if [ $? -ne 0 ]; then
120137
echo "::error::Error: ${{ inputs.deployment-environment }} ${{ inputs.spack-type }} $version spack-config failed checkout from $current_head_commit to $new_commit"
121138
else
139+
ln -s -r -v -f \
140+
${{ secrets.SPACK_INSTALLS_ROOT_LOCATION }}/$version/spack-config/$version/* \
141+
${{ secrets.SPACK_INSTALLS_ROOT_LOCATION }}/$version/spack/etc/spack/
142+
122143
echo "::notice::Changed: ${{ inputs.deployment-environment }} ${{ inputs.spack-type }} $version spack-config changed from $current_head_commit to $new_commit"
123144
fi
145+
124146
else
125147
echo "::notice::Unchanged: ${{ inputs.deployment-environment }} ${{ inputs.spack-type }} $version spack-config left at $current_head_commit"
126148
fi
127149
done <<< "${{ steps.spack-config.outputs.updates }}"
128150
EOT
151+
152+
- name: Update builtin spack-packages
153+
# This will only run for instances that have builtin-spack-packages defined in their entries (i.e. instances at spack >=1.0)
154+
continue-on-error: true
155+
run: |
156+
ssh ${{ secrets.USER}}@${{ secrets.HOST }} -i ${{ steps.ssh.outputs.private-key-path }} /bin/bash <<'EOT'
157+
set +e
158+
159+
while read -ra update; do
160+
version=${update[0]}
161+
new_ref=${update[1]}
162+
163+
. ${{ secrets.SPACK_INSTALLS_ROOT_LOCATION }}/$version/spack-config/spack-enable.bash
164+
165+
builtin_repo_path=$(spack location --repo builtin)
166+
167+
current_head_commit=$(git -C $builtin_repo_path rev-parse HEAD)
168+
new_commit=$(git -C $builtin_repo_path rev-parse "$new_ref")
169+
170+
if [[ "$current_head_commit" != "$new_commit" ]]; then
171+
172+
spack repo update builtin --commit $new_commit
173+
174+
if [ $? -ne 0 ]; then
175+
echo "::error::Error: ${{ inputs.deployment-environment }} ${{ inputs.spack-type }} $version builtin-spack-packages failed checkout from $current_head_commit to $new_commit"
176+
else
177+
echo "::notice::Changed: ${{ inputs.deployment-environment }} ${{ inputs.spack-type }} $version builtin-spack-packages changed from $current_head_commit to $new_commit"
178+
fi
179+
else
180+
echo "::notice::Unchanged: ${{ inputs.deployment-environment }} ${{ inputs.spack-type }} $version builtin-spack-packages left at $current_head_commit"
181+
fi

0 commit comments

Comments
 (0)