diff --git a/.github/actions/validate-deployment-settings/action.yml b/.github/actions/validate-deployment-settings/action.yml index aff97a1..248099c 100644 --- a/.github/actions/validate-deployment-settings/action.yml +++ b/.github/actions/validate-deployment-settings/action.yml @@ -29,7 +29,7 @@ runs: shell: bash run: | majors_only_in_prerelease=$(jq --compact-output --raw-output \ - '.deployment.${{ inputs.target }} | (.Prerelease.spack | keys) - (.Release.spack | keys) | @sh' \ + '.deployment.${{ inputs.target }} | (.Prerelease | keys) - (.Release | keys) | @sh' \ ${{ inputs.settings-path }} ) @@ -46,8 +46,21 @@ runs: # It then merges them together based on major version (Ex. [[{"0.20": "u298rer3", "0.20": "r98u349u"}], ...]). # And then finally compares the hashes for each major version, and returns the major versions where they differ. run: | - release_version_hashes=$(jq '.deployment.${{ inputs.target }}.Release.spack | to_entries' ${{ inputs.settings-path }}) - prerelease_version_hashes=$(jq '.deployment.${{ inputs.target }}.Prerelease.spack | to_entries' ${{ inputs.settings-path }}) + release_version_hashes=$(jq \ + '.deployment.${{ inputs.target }}.Release + | [ + keys[] as $major | .[$major].spack as $hash + | {($major): $hash} | to_entries[] + ]' ${{ inputs.settings-path }} + ) + + prerelease_version_hashes=$(jq \ + '.deployment.${{ inputs.target }}.Prerelease + | [ + keys[] as $major | .[$major].spack as $hash + | {($major): $hash} | to_entries[] + ]' ${{ inputs.settings-path }} + ) unequal_hashes_for_version=$(jq --compact-output --raw-output --null-input \ --argjson r "$release_version_hashes" \ @@ -79,8 +92,16 @@ runs: run: | gh repo clone access-nri/spack ${{ env.CHECKOUT_DIR }} -- --no-checkout --bare --filter=blob:none - # Essentially, pull out all the spack 'version: hash' sections and iterate - jq -cr '.deployment.${{ inputs.target }}[].spack | to_entries[] | "\(.key) \(.value)"' ${{ inputs.settings-path }} | while read -ra line; do + # Essentially, pull out all the spack 'major: hash' sections and iterate + version_hashes=$(jq --compact-output --raw-output \ + '.deployment.${{ inputs.target }}[] + | keys[] as $major | .[$major].spack as $hash + | "\($major) \($hash)"' \ + ${{ inputs.settings-path }} + ) + + # For each of the version hashes, check if $hash is in releases/v$major + while read -ra line; do version=${line[0]} hash=${line[1]} echo "Checking if $hash is in $version" @@ -88,7 +109,7 @@ runs: echo "::${{ inputs.error-level }}::Commit $hash does not exist on branch releases/v$version" failed=true fi - done + done <<< "$version_hashes" if [ -n $failed ]; then msg="Some commits referenced do not exist in access-nri/spack. Check the workflow logs."