Skip to content

Commit 3da2716

Browse files
committed
Add access-spack-packages ref to final manifest rather than in the install step
1 parent 384c5d6 commit 3da2716

4 files changed

Lines changed: 25 additions & 13 deletions

File tree

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,13 @@ jobs:
145145
--packages "${{ steps.config-packages.outputs.packages-for-injection }}" \
146146
--output ../${{ inputs.spack-manifest-path }}
147147
148+
- name: Get SHA for access-spack-packages repository
149+
id: packages-ref
150+
uses: access-nri/actions/.github/actions/get-git-ref-info@main
151+
with:
152+
repository: ACCESS-NRI/access-spack-packages
153+
ref: ${{ steps.versions.outputs.packages }}
154+
148155
- name: Spack Manifest - Prerelease Injection
149156
if: inputs.deployment-type == 'Prerelease'
150157
# Modifies the name of the prerelease modulefile to the pr<number>-<deployment number>` style.
@@ -156,6 +163,7 @@ jobs:
156163
--manifest ../${{ inputs.spack-manifest-path }} \
157164
--version ${{ inputs.version }} \
158165
--spack-packages-path ${{ steps.path.outputs.spack-environment }}/access-spack-packages \
166+
--spack-packages-version-sha ${{ steps.packages-ref.outputs.sha }} \
159167
${{ steps.modules-injection.outputs.custom-projection != '' && format('--custom-root-projection {0}', steps.modules-injection.outputs.custom-projection ) || ''}} \
160168
--output ../${{ inputs.spack-manifest-path }}
161169
@@ -183,13 +191,6 @@ jobs:
183191
done
184192
EOT
185193
186-
- name: Get SHA for access-spack-packages repository
187-
id: packages-ref
188-
uses: access-nri/actions/.github/actions/get-git-ref-info@main
189-
with:
190-
repository: ACCESS-NRI/access-spack-packages
191-
ref: ${{ steps.versions.outputs.packages }}
192-
193194
- name: Deploy to ${{ inputs.deployment-target }} ${{ inputs.deployment-type }}
194195
id: deploy
195196
# ssh into deployment environment, create and activate the env, install the spack manifest.
@@ -211,9 +212,6 @@ jobs:
211212
# Create and activate environment
212213
spack env activate ${{ inputs.env-name }} --create --envfile ${{ vars.SPACK_YAML_LOCATION }}/${{ inputs.expected-root-spec-name }}-${{ github.run_id }}.spack.yaml
213214
214-
# Update access-spack-packages repository before installation
215-
spack repo update access_spack_packages --commit ${{ steps.packages-ref.outputs.sha }}
216-
217215
# Finally, install the spack manifest
218216
spack --debug install --fail-fast --fresh ${{ vars.SPACK_INSTALL_ADDITIONAL_ARGS }} || exit $?
219217
spack module tcl refresh -y

scripts/spack_manifest/injection/prerelease.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def inject_prerelease_information(
3939
custom_root_projection: str | None = None,
4040
keep_root_spec_intact: bool = False,
4141
spack_packages_path: str | None = None,
42+
spack_packages_version_sha: str | None = None,
4243
) -> str:
4344
# In comparison to the projections script, this returns a string rather than a dict because we need to
4445
# add spack-specific, non-standard 'repo::' sections, which the yaml dumper does not support.
@@ -69,7 +70,7 @@ def inject_prerelease_information(
6970
if spack_packages_path:
7071
# Add the 'repo:' section for prerelease spack packages if provided
7172
updated_manifest = add_prerelease_repos_section(
72-
updated_manifest, spack_packages_path
73+
updated_manifest, spack_packages_path, spack_packages_version_sha
7374
)
7475

7576
# Dump the current dict, and add the non-standard 'repo::' section
@@ -151,7 +152,7 @@ def update_root_spec_projection_version(
151152

152153

153154
def add_prerelease_repos_section(
154-
manifest: dict[str, Any], spack_packages_path: str
155+
manifest: dict[str, Any], spack_packages_path: str, spack_packages_version_sha: str | None = None
155156
) -> dict[str, Any]:
156157

157158
manifest.setdefault("spack", {}).setdefault("repos", {})
@@ -162,6 +163,9 @@ def add_prerelease_repos_section(
162163
}
163164
}
164165

166+
if spack_packages_version_sha:
167+
manifest["spack"]["repos"]["access_spack_packages"]["commit"] = spack_packages_version_sha
168+
165169
return manifest
166170

167171

@@ -208,6 +212,13 @@ def parse_args(args: list[str]) -> argparse.Namespace:
208212
help="Local path to a spack-packages repository that is added to the manifests repos section",
209213
)
210214

215+
parser.add_argument(
216+
"--spack-packages-version-sha",
217+
type=str,
218+
required=False,
219+
help="Git SHA of the spack-packages repository that is added to the manifests repos section",
220+
)
221+
211222
# Args dealing with outputs
212223
parser.add_argument(
213224
"--output",
@@ -228,6 +239,7 @@ def main():
228239
args.custom_root_projection,
229240
args.keep_root_spec_intact,
230241
args.spack_packages_path,
242+
args.spack_packages_version_sha,
231243
)
232244

233245
print(injected_manifest)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,4 @@ spack:
4949
access_spack_packages:
5050
git: https://github.com/ACCESS-NRI/access-spack-packages.git
5151
destination: /some/spack-packages
52+
commit: e8713551c6eee57caf9603543e6dd6daf3c93922

tests/scripts/spack_manifest/injection/test_prerelease.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,10 @@ def test_inject_prerelease_information__valid_custom_projection(self):
149149
root_spec_version = "pr12-12"
150150
custom_root_projection = "2024.03.0"
151151
spack_packages_path = "/some/spack-packages"
152+
spack_packages_version_sha = "e8713551c6eee57caf9603543e6dd6daf3c93922"
152153

153154
updated_manifest_str: str = inject_prerelease_information(
154-
manifest_path, root_spec_version, custom_root_projection, False, spack_packages_path
155+
manifest_path, root_spec_version, custom_root_projection, spack_packages_path, spack_packages_version_sha
155156
)
156157

157158
expected_manifest_path = "tests/scripts/spack_manifest/injection/outputs/expected.prerelease.spack.yaml"

0 commit comments

Comments
 (0)