Skip to content

Commit ae27874

Browse files
committed
Updated prerelease injection to git-based repos format, updated tests
1 parent f82ca40 commit ae27874

3 files changed

Lines changed: 37 additions & 25 deletions

File tree

scripts/spack_manifest/injection/prerelease.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,17 @@ def inject_prerelease_information(
6565
updated_manifest, root_spec_name, version
6666
)
6767

68+
if spack_packages_path:
69+
# Add the 'repo:' section for prerelease spack packages if provided
70+
updated_manifest = add_prerelease_repos_section(
71+
updated_manifest, spack_packages_path
72+
)
73+
6874
# Dump the current dict, and add the non-standard 'repo::' section
6975
manifest_str: str = yaml.dump(
7076
updated_manifest, default_flow_style=False, sort_keys=False
7177
)
7278

73-
if spack_packages_path:
74-
# Add the 'repo::' section for prerelease spack packages if provided
75-
manifest_str = add_prerelease_repos_section(manifest_str, spack_packages_path)
76-
7779
return manifest_str
7880

7981

@@ -138,14 +140,19 @@ def update_root_spec_projection_version(
138140
return manifest
139141

140142

141-
def add_prerelease_repos_section(manifest_str: str, spack_packages_path: str) -> str:
142-
manifest_str += (
143-
f" repos::\n"
144-
f" - {spack_packages_path}\n"
145-
f" - $spack/var/spack/repos/builtin\n"
146-
)
143+
def add_prerelease_repos_section(
144+
manifest: dict[str, Any], spack_packages_path: str
145+
) -> dict[str, Any]:
147146

148-
return manifest_str
147+
manifest.setdefault("spack", {}).setdefault("repos", {})
148+
manifest["spack"]["repos"] = {
149+
"access_spack_packages": {
150+
"git": "https://github.com/ACCESS-NRI/access-spack-packages.git",
151+
"destination": spack_packages_path,
152+
}
153+
}
154+
155+
return manifest
149156

150157

151158
def parse_args(args: list[str]) -> argparse.Namespace:

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ spack:
4545
projections:
4646
access-om2: '{name}/pr12-12'
4747
mom5: 'access-om2/dependencies/pr12-12/{name}/2023.11.09-{hash:7}'
48-
repos::
49-
- /some/spack-packages
50-
- $spack/var/spack/repos/builtin
48+
repos:
49+
access_spack_packages:
50+
git: https://github.com/ACCESS-NRI/access-spack-packages.git
51+
destination: /some/spack-packages

tests/scripts/spack_manifest/injection/test_prerelease.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -123,20 +123,24 @@ def test_remove_potential_root_spec_git_version__invalid_no_git_version(self):
123123

124124
class TestAddPrereleaseReposSection:
125125
def test_add_prerelease_repos_section__valid(self):
126-
manifest_str = "spack:\n specs:\n - access-om2@git.1.0.0\n"
126+
manifest = {
127+
"spack": {
128+
"specs": [
129+
"access-om2@1.0.0"
130+
]
131+
}
132+
}
127133
spack_packages_path = "/path/to/spack/packages"
128134

129-
updated_manifest_str = add_prerelease_repos_section(manifest_str, spack_packages_path)
130-
131-
last_three_lines = "\n".join(updated_manifest_str.splitlines()[-3:])
132-
133-
expected_last_three_lines = (
134-
f" repos::\n"
135-
f" - {spack_packages_path}\n"
136-
f" - $spack/var/spack/repos/builtin\n"
137-
)
135+
updated_manifest = add_prerelease_repos_section(manifest, spack_packages_path)
138136

139-
assert last_three_lines.strip() == expected_last_three_lines.strip()
137+
expected_repos_section = {
138+
"access_spack_packages": {
139+
"git": "https://github.com/ACCESS-NRI/access-spack-packages.git",
140+
"destination": spack_packages_path,
141+
}
142+
}
143+
assert updated_manifest["spack"]["repos"] == expected_repos_section
140144

141145
class TestInjectPrereleaseInformation:
142146
def test_inject_prerelease_information__valid(self):

0 commit comments

Comments
 (0)