@@ -173,6 +173,9 @@ jobs:
173
173
ref : ${{ inputs.deployment-ref }}
174
174
175
175
- name : Validate ACCESS-NRI spack.yaml Restrictions
176
+ if : >-
177
+ (github.event_name == 'pull_request' && !github.event.pull_request.draft) ||
178
+ (github.event_name == 'issue_comment' && !github.event.issue.draft)
176
179
uses : access-nri/schema/.github/actions/validate-with-schema@main
177
180
with :
178
181
schema-version : ${{ vars.SPACK_YAML_SCHEMA_VERSION }}
@@ -185,7 +188,7 @@ jobs:
185
188
186
189
- name : Check '@latest' version usage
187
190
if : >-
188
- (github.event_name == 'pull_request' && !github.event.pull_request.draft) ||
191
+ (github.event_name == 'pull_request' && !github.event.pull_request.draft) ||
189
192
(github.event_name == 'issue_comment' && !github.event.issue.draft)
190
193
run : |
191
194
if [[ "${{ steps.current.outputs.root-spec-ref }}" == "latest" ]]; then
@@ -236,40 +239,47 @@ jobs:
236
239
* `!bump major` for feature releases
237
240
* `!bump minor` for bugfixes
238
241
239
- - name : Projection Version Matches
240
- # this step checks that the versions of the packages themselves match with the
241
- # names of the projections, if they're given.
242
- # For example, [email protected] matches with the
243
- # modulefile access-om3/2023.12.12 (specifically, the version strings match)
244
- # TODO: Move this into the `scripts` directory - it's getting unweildly.
242
+ - name : Check Projections - Specs
243
+ # This step checks that the root spec has an appropriate projection in the spack.yaml file.
245
244
run : |
246
245
git checkout ${{ inputs.deployment-ref }}
247
246
247
+ current_projection=$(yq '.spack.modules.default.tcl.projections.${{ steps.current.outputs.root-spec-name }}' ${{ inputs.spack-manifest-path }})
248
+ expected_projection_prefix='{name}/${{ steps.current.outputs.root-spec-ref }}'
249
+
250
+ if [[ "$current_projection" == "$expected_projection_prefix"* ]]; then
251
+ echo "Current root spec projection ($current_projection) and expected projection prefix ($expected_projection_prefix) match."
252
+ else
253
+ echo "::error::Current root spec projection ($current_projection) and expected projection prefix ($expected_projection_prefix) don't match."
254
+ exit 1
255
+ fi
256
+
257
+ - name : Check Projections - Packages
258
+ # This step checks that the defined projections have the same versions as the referenced packages in the spack.yaml file.
259
+ # For example, [email protected] matches with the
260
+ # modulefile mom5/2023.12.12 (specifically, the version strings match)
261
+ if : >-
262
+ (github.event_name == 'pull_request' && !github.event.pull_request.draft) ||
263
+ (github.event_name == 'issue_comment' && !github.event.issue.draft)
264
+ run : |
248
265
FAILED="false"
249
- # Get all the defined projections (minus 'all') and make them suitable for a bash for loop
250
- DEPS=$(yq '.spack.modules.default.tcl.projections | del(.all) | keys | join(" ")' spack.yaml)
266
+ # Get all the defined projections (minus 'all' and the root spec ) and make them suitable for a bash for loop
267
+ DEPS=$(yq '.spack.modules.default.tcl.projections | del(.all) | del(.${{ steps.current.outputs.root-spec-name }}) | keys | join(" ")' spack.yaml)
251
268
252
- # for each of the modules
269
+ # for each of the module names
253
270
for DEP in $DEPS; do
254
- DEP_VER=''
255
- if [[ "$DEP" == "${{ inputs.spack-manifest-root-sbd }}" ]]; then
256
- # The model version is the bit after '@git.', before any later, space-separated, optional variants.
257
- # For example, in '[email protected] type=ACCESS ~debug' the version is 'VERSION'.
258
- DEP_VER=${{ steps.current.outputs.root-spec-ref }}
259
- else
260
- # Capture the section after '@git.' or '@' (if it's not a git-attributed version) and before a possible '=' for a given dependency.
261
- # Ex. '@git.2024.02.11' -> '2024.02.11', '@access-esm1.5' -> 'access-esm1.5', '@git.2024.05.21=access-esm1.5' -> '2024.05.21'
262
- DEP_VER=$(yq ".spack.packages.\"$DEP\".require[0] | match(\"^@(?:git.)?([^=]*)\").captures[0].string" spack.yaml)
263
- fi
271
+ # Capture the section after '@git.' or '@' (if it's not a git-attributed version) and before a possible '=' for a given dependency.
272
+ # Ex. '@git.2024.02.11' -> '2024.02.11', '@access-esm1.5' -> 'access-esm1.5', '@git.2024.05.21=access-esm1.5' -> '2024.05.21'
273
+ package_ver=$(yq ".spack.packages.\"$DEP\".require[0] | match(\"^@(?:git.)?([^=]*)\").captures[0].string" spack.yaml)
274
+ expected_projection_prefix="{name}/$package_ver"
264
275
265
- # Get the version from the module projection, for comparison with DEP_VER
266
- # Projections are of the form '{name}/VERSION[-{hash:7}]', in which we only care about VERSION. For example, '{name}/2024.11.11', or '{name}/2024.11.11-{hash:7}'
267
- MODULE_NAME=$(yq ".spack.modules.default.tcl.projections.\"$DEP\"" spack.yaml)
268
- MODULE_VER="${MODULE_NAME#*/}" # Strip '{name}/' from '{name}/VERSION' module, even if VERSION contains '/'
269
- MODULE_VER="${MODULE_VER%%-\{hash:7\}}" # Strip a potential '-{hash:7}' appendix from the VERSION, since we won't have that in the DEP_VER
276
+ # Projections must start with '{name}/VERSION'. For example, '{name}/2024.11.11', or '{name}/2024.11.11-{hash:7}'
277
+ current_projection=$(yq ".spack.modules.default.tcl.projections.\"$DEP\"" spack.yaml)
270
278
271
- if [[ "$DEP_VER" != "$MODULE_VER" ]]; then
272
- echo "::error::$DEP: Version of dependency and projection do not match ($DEP_VER != $MODULE_VER)"
279
+ if [[ "$current_projection" == "$expected_projection_prefix"* ]]; then
280
+ echo "$DEP: Current projection ($current_projection) and expected projection prefix ($expected_projection_prefix) match."
281
+ else
282
+ echo "::error::$DEP: Current projection ($current_projection) and expected projection prefix ($expected_projection_prefix) don't match."
273
283
FAILED='true'
274
284
fi
275
285
done
0 commit comments