Skip to content

Commit a41494b

Browse files
committed
validate-deployment-settings: Update checks to work with new settings.json schema
1 parent 9a4033f commit a41494b

File tree

1 file changed

+27
-6
lines changed
  • .github/actions/validate-deployment-settings

1 file changed

+27
-6
lines changed

.github/actions/validate-deployment-settings/action.yml

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ runs:
2929
shell: bash
3030
run: |
3131
majors_only_in_prerelease=$(jq --compact-output --raw-output \
32-
'.deployment.${{ inputs.target }} | (.Prerelease.spack | keys) - (.Release.spack | keys) | @sh' \
32+
'.deployment.${{ inputs.target }} | (.Prerelease | keys) - (.Release | keys) | @sh' \
3333
${{ inputs.settings-path }}
3434
)
3535
@@ -46,8 +46,21 @@ runs:
4646
# It then merges them together based on major version (Ex. [[{"0.20": "u298rer3", "0.20": "r98u349u"}], ...]).
4747
# And then finally compares the hashes for each major version, and returns the major versions where they differ.
4848
run: |
49-
release_version_hashes=$(jq '.deployment.${{ inputs.target }}.Release.spack | to_entries' ${{ inputs.settings-path }})
50-
prerelease_version_hashes=$(jq '.deployment.${{ inputs.target }}.Prerelease.spack | to_entries' ${{ inputs.settings-path }})
49+
release_version_hashes=$(jq \
50+
'.deployment.${{ inputs.target }}.Release
51+
| [
52+
keys[] as $major | .[$major].spack as $hash
53+
| {($major): $hash} | to_entries[]
54+
]' ${{ inputs.settings-path }}
55+
)
56+
57+
prerelease_version_hashes=$(jq \
58+
'.deployment.${{ inputs.target }}.Prerelease
59+
| [
60+
keys[] as $major | .[$major].spack as $hash
61+
| {($major): $hash} | to_entries[]
62+
]' ${{ inputs.settings-path }}
63+
)
5164
5265
unequal_hashes_for_version=$(jq --compact-output --raw-output --null-input \
5366
--argjson r "$release_version_hashes" \
@@ -79,16 +92,24 @@ runs:
7992
run: |
8093
gh repo clone access-nri/spack ${{ env.CHECKOUT_DIR }} -- --no-checkout --bare --filter=blob:none
8194
82-
# Essentially, pull out all the spack 'version: hash' sections and iterate
83-
jq -cr '.deployment.${{ inputs.target }}[].spack | to_entries[] | "\(.key) \(.value)"' ${{ inputs.settings-path }} | while read -ra line; do
95+
# Essentially, pull out all the spack 'major: hash' sections and iterate
96+
version_hashes=$(jq --compact-output --raw-output \
97+
'.deployment.${{ inputs.target }}[]
98+
| keys[] as $major | .[$major].spack as $hash
99+
| "\($major) \($hash)"' \
100+
${{ inputs.settings-path }}
101+
)
102+
103+
# For each of the version hashes, check if $hash is in releases/v$major
104+
while read -ra line; do
84105
version=${line[0]}
85106
hash=${line[1]}
86107
echo "Checking if $hash is in $version"
87108
if ! git -C ${{ env.CHECKOUT_DIR }} merge-base --is-ancestor $hash releases/v$version; then
88109
echo "::${{ inputs.error-level }}::Commit $hash does not exist on branch releases/v$version"
89110
failed=true
90111
fi
91-
done
112+
done <<< "$version_hashes"
92113
93114
if [ -n $failed ]; then
94115
msg="Some commits referenced do not exist in access-nri/spack. Check the workflow logs."

0 commit comments

Comments
 (0)