Skip to content

Commit 8a072b2

Browse files
authored
vars to File-Based Special Packages (#305)
* Validate MDR config/packages.json * Pass info from MDR config/packages.json to module injection script * Update variable name to `vars.CONFIG_PACKAGES_SCHEMA_VERSION` * Change cwd relative to build-cd rather than model for scripts * Add output of packages to be injected/added to provenance DB * Update prerelease projection to `ROOT_SPEC/prX-Y/{name}/VERSION` * Update tests for new prerelease injection logic
1 parent 424ba3c commit 8a072b2

5 files changed

Lines changed: 30 additions & 16 deletions

File tree

.github/workflows/deploy-1-setup.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,13 @@ jobs:
148148
schema-location: au.org.access-nri/model/deployment/config/versions
149149
data-location: ./model/config/versions.json
150150

151+
- name: Validate ${{ github.repository }} config/packages.json
152+
uses: access-nri/schema/.github/actions/validate-with-schema@main
153+
with:
154+
schema-version: ${{ vars.CONFIG_PACKAGES_SCHEMA_VERSION }}
155+
schema-location: au.org.access-nri/model/deployment/config/packages
156+
data-location: ./model/config/packages.json
157+
151158
- name: Validate spack-packages version
152159
id: spack-packages
153160
uses: access-nri/build-cd/.github/actions/validate-repo-version@v5

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

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,25 +121,28 @@ jobs:
121121

122122
- name: Spack Manifest - Modules Injection
123123
# Injects relevant module projections and includes into the spack manifest so users don't have to
124-
# Note the cd prefix to the module name, as this is the path we cloned build-cd into
125124
run: |
126-
python -m cd.scripts.spack_manifest.injection.modules \
127-
--manifest ${{ inputs.spack-manifest-path }} \
128-
--packages "${{ vars.BUILD_DB_PACKAGES }}" \
129-
--output ${{ inputs.spack-manifest-path }}
125+
packages_for_injection=$(jq -cr '.provenance + .injection | join(" ")' config/packages.json)
126+
echo "Packages to be injected: $packages_for_injection"
127+
128+
cd cd
129+
python -m scripts.spack_manifest.injection.modules \
130+
--manifest ../${{ inputs.spack-manifest-path }} \
131+
--packages "$packages_for_injection" \
132+
--output ../${{ inputs.spack-manifest-path }}
130133
131134
- name: Spack Manifest - Prerelease Injection
132135
if: inputs.deployment-type == 'Prerelease'
133136
# Modifies the name of the prerelease modulefile to the pr<number>-<deployment number>` style.
134137
# Also removes the `@git.VERSION` specifier for Prereleases as it is a tag that doesn't yet exist.
135138
# Also adds a repos section that points to the prereleases specific spack-packages repo.
136-
# Note the cd prefix to the module name, as this is the path we cloned build-cd into
139+
working-directory: cd
137140
run: |
138-
python -m cd.scripts.spack_manifest.injection.prerelease \
139-
--manifest ${{ inputs.spack-manifest-path }} \
141+
python -m scripts.spack_manifest.injection.prerelease \
142+
--manifest ../${{ inputs.spack-manifest-path }} \
140143
--version ${{ inputs.version }} \
141144
--spack-packages-path ${{ steps.path.outputs.spack-packages }} \
142-
--output ${{ inputs.spack-manifest-path }}
145+
--output ../${{ inputs.spack-manifest-path }}
143146
144147
- name: Copy ${{ inputs.spack-manifest-path }}
145148
run: |
@@ -252,7 +255,10 @@ jobs:
252255
# Get the information associated with the packages for the build database
253256
jq -n '[]' > ${{ steps.path.outputs.spack-environment }}/build-db-pkgs.json
254257
255-
for pkg in ${{ vars.BUILD_DB_PACKAGES }}; do
258+
packages_for_provenance=$(jq -cr '.provenance | join(" ")' config/packages.json)
259+
echo "Packages for provenance: $packages_for_provenance"
260+
261+
for pkg in $packages_for_provenance; do
256262
hash=$(spack find --format '{hash}' $pkg)
257263
version=$(spack find --format '{version}' $pkg)
258264
location=$(spack find --format '{prefix}' $pkg)

scripts/spack_manifest/injection/prerelease.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,10 @@ def add_namespace_to_other_projection_versions(
6969
projections.pop(root_spec_name)
7070

7171
for projection_name, projection_value in projections.items():
72-
# Non-root-spec projections will be of the form {name}/prX-Y/VERSION, where VERSION is previously defined.
72+
# Non-root-spec projections will be of the form ROOT_SPEC_NAME/prX-Y/{name}/VERSION, where VERSION is previously defined.
73+
# For example, access-om2/pr12-13/mom5/main-{hash:7}
7374
new_projection_value = re.sub(
74-
r"{name}/(.+)", rf"{{name}}/{version}/\1", projection_value
75+
r"{name}/(.+)", rf"{root_spec_name}/{version}/{{name}}/\1", projection_value
7576
)
7677

7778
print(

tests/scripts/spack_manifest/injection/outputs/expected.prerelease.spack.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ spack:
4444
- oasis3-mct
4545
projections:
4646
access-om2: '{name}/pr12-12'
47-
mom5: '{name}/pr12-12/2023.11.09-{hash:7}'
47+
mom5: access-om2/pr12-12/{name}/2023.11.09-{hash:7}
4848
repos::
4949
- /some/spack-packages
5050
- $spack/var/spack/repos/builtin

tests/scripts/spack_manifest/injection/test_prerelease.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,9 @@ def test_add_namespace_to_other_projection_versions__valid(self):
180180
updated_manifest = add_namespace_to_other_projection_versions(manifest, root_spec_name, version)
181181

182182
assert updated_manifest["spack"]["modules"]["default"]["tcl"]["projections"]["access-om2"] == f"{{name}}/{version}"
183-
assert updated_manifest["spack"]["modules"]["default"]["tcl"]["projections"]["dependency1"] == f"{{name}}/{version}/2.0.0"
184-
assert updated_manifest["spack"]["modules"]["default"]["tcl"]["projections"]["dependency2"] == f"{{name}}/{version}/3.0.0-{{hash:7}}"
185-
assert updated_manifest["spack"]["modules"]["default"]["tcl"]["projections"]["dependency3"] == f"{{name}}/{version}/special/4.0.0-{{hash:7}}"
183+
assert updated_manifest["spack"]["modules"]["default"]["tcl"]["projections"]["dependency1"] == f"{root_spec_name}/{version}/{{name}}/2.0.0"
184+
assert updated_manifest["spack"]["modules"]["default"]["tcl"]["projections"]["dependency2"] == f"{root_spec_name}/{version}/{{name}}/3.0.0-{{hash:7}}"
185+
assert updated_manifest["spack"]["modules"]["default"]["tcl"]["projections"]["dependency3"] == f"{root_spec_name}/{version}/{{name}}/special/4.0.0-{{hash:7}}"
186186

187187
def test_add_namespace_to_other_projection_versions__no_projections_except_for_root(self):
188188
root_spec_name = "access-om2"

0 commit comments

Comments
 (0)