diff --git a/stackinator/schema/config.json b/stackinator/schema/config.json index ebfc44bf..99d6cd0f 100644 --- a/stackinator/schema/config.json +++ b/stackinator/schema/config.json @@ -12,11 +12,11 @@ "type" : "string", "default" : "/user-environment" }, - "spack" : { - "type" : "object", + "spack": { + "type": "object", "additionalProperties": false, - "properties" : { - "required": ["repo", "commit", "packages"], + "required": ["repo", "packages"], + "properties": { "repo": { "type": "string" }, @@ -27,10 +27,10 @@ ], "default": null }, - "packages" : { - "type" : "object", + "packages": { + "type": "object", "additionalProperties": false, - "required": ["repo", "commit"], + "required": ["repo"], "properties" : { "repo": { "type": "string" @@ -77,7 +77,9 @@ }, "version" : { "type": "number", - "default": 1 + "default": 1, + "minimum": 1, + "maximum": 2 } } } diff --git a/unittests/data/arbor-uenv/meta/recipe/config.yaml b/unittests/data/arbor-uenv/meta/recipe/config.yaml index cf2ab463..37ca9a60 100644 --- a/unittests/data/arbor-uenv/meta/recipe/config.yaml +++ b/unittests/data/arbor-uenv/meta/recipe/config.yaml @@ -4,3 +4,4 @@ spack: repo: https://github.com/spack/spack.git store: /user-environment description: The Arbor neuroscience simulation package and its dependencies for multicore systems. +version: 2 diff --git a/unittests/recipes/base-nvgpu/config.yaml b/unittests/recipes/base-nvgpu/config.yaml index a2b14813..0102735a 100644 --- a/unittests/recipes/base-nvgpu/config.yaml +++ b/unittests/recipes/base-nvgpu/config.yaml @@ -3,6 +3,8 @@ store: /user-environment spack: repo: https://github.com/spack/spack.git commit: 6408b51 + packages: + repo: https://github.com/spack/spack-packages.git mirror: enable: false version: 2 diff --git a/unittests/recipes/cache/config.yaml b/unittests/recipes/cache/config.yaml index ee25a292..8609b78a 100644 --- a/unittests/recipes/cache/config.yaml +++ b/unittests/recipes/cache/config.yaml @@ -3,6 +3,8 @@ store: '/user-environment' spack: repo: https://github.com/spack/spack.git commit: 6408b51 + packages: + repo: https://github.com/spack/spack-packages.git mirror: key: /scratch/e1000/bcumming/secret/spack-key.gpg enable: true diff --git a/unittests/recipes/host-recipe/config.yaml b/unittests/recipes/host-recipe/config.yaml index 30b15889..780cf031 100644 --- a/unittests/recipes/host-recipe/config.yaml +++ b/unittests/recipes/host-recipe/config.yaml @@ -4,4 +4,6 @@ description: "An example gcc configuration for CPU-only development" spack: commit: releases/v0.23 repo: https://github.com/spack/spack.git + packages: + repo: https://github.com/spack/spack-packages.git version: 2 diff --git a/unittests/recipes/with-repo/config.yaml b/unittests/recipes/with-repo/config.yaml index 89c9dcac..a3cb2940 100644 --- a/unittests/recipes/with-repo/config.yaml +++ b/unittests/recipes/with-repo/config.yaml @@ -3,4 +3,6 @@ store: '/user-environment' spack: repo: https://github.com/spack/spack.git commit: v21.0 + packages: + repo: https://github.com/spack/spack-packages.git version: 2 diff --git a/unittests/test_schema.py b/unittests/test_schema.py index 6850e5fe..1b376c6f 100644 --- a/unittests/test_schema.py +++ b/unittests/test_schema.py @@ -42,15 +42,60 @@ def test_config_yaml(yaml_path): schema.ConfigValidator.validate(raw) assert raw["store"] == "/user-environment" assert raw["spack"]["commit"] is None + assert raw["spack"]["packages"]["commit"] is None assert raw["modules"] == True # noqa: E712 assert raw["mirror"] == {"enable": True, "key": None} assert raw["description"] is None + # no spack:commit + config = dedent(""" + version: 2 + name: env-without-spack-commit + spack: + repo: https://github.com/spack/spack.git + packages: + repo: https://github.com/spack/spack.git + commit: develop-packages + """) + raw = yaml.load( + config, + Loader=yaml.Loader, + ) + schema.ConfigValidator.validate(raw) + assert raw["spack"]["commit"] is None + assert raw["spack"]["packages"]["commit"] is not None + assert raw["modules"] == True # noqa: E712 + assert raw["mirror"] == {"enable": True, "key": None} + assert raw["description"] is None + + # no spack:packages:commit + config = dedent(""" + version: 2 + name: env-without-spack-packages-commit + spack: + repo: https://github.com/spack/spack.git + commit: develop + packages: + repo: https://github.com/spack/spack.git + """) + raw = yaml.load( + config, + Loader=yaml.Loader, + ) + schema.ConfigValidator.validate(raw) + assert raw["spack"]["commit"] == "develop" + assert raw["spack"]["packages"]["commit"] is None + assert raw["modules"] == True # noqa: E712 + assert raw["mirror"] == {"enable": True, "key": None} + assert raw["description"] is None + + # full config with open(yaml_path / "config.full.yaml") as fid: raw = yaml.load(fid, Loader=yaml.Loader) schema.ConfigValidator.validate(raw) assert raw["store"] == "/alternative-point" assert raw["spack"]["commit"] == "6408b51" + assert raw["spack"]["packages"]["commit"] == "v2025.07.0" assert raw["modules"] == False # noqa: E712 assert raw["mirror"] == {"enable": True, "key": "/home/bob/veryprivate.key"} assert raw["description"] == "a really useful environment" diff --git a/unittests/yaml/config.defaults.yaml b/unittests/yaml/config.defaults.yaml index 0571b297..d021bd01 100644 --- a/unittests/yaml/config.defaults.yaml +++ b/unittests/yaml/config.defaults.yaml @@ -5,6 +5,10 @@ spack: repo: https://github.com/spack/spack.git # default: None == no `git checkout` command #commit: 6408b51 + packages: + repo: https://github.com/spack/spack-packages.git + # default: None == no `git checkout` command + #commit: 6408b51 #mirror: # default None #key: None diff --git a/unittests/yaml/config.full.yaml b/unittests/yaml/config.full.yaml index 26267c6d..e13aa035 100644 --- a/unittests/yaml/config.full.yaml +++ b/unittests/yaml/config.full.yaml @@ -3,6 +3,9 @@ store: /alternative-point spack: repo: https://github.com/spack/spack.git commit: 6408b51 + packages: + repo: https://github.com/spack/spack-packages.git + commit: v2025.07.0 mirror: key: /home/bob/veryprivate.key enable: True