From c5e67ab0e3ac0ca54600a547f9f6310fcdacd3d5 Mon Sep 17 00:00:00 2001 From: Alberto Invernizzi Date: Tue, 29 Jul 2025 16:21:51 +0200 Subject: [PATCH 1/6] fix schema: required was not enforced (it was erroneously nested) --- stackinator/schema/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stackinator/schema/config.json b/stackinator/schema/config.json index ebfc44bf..18399370 100644 --- a/stackinator/schema/config.json +++ b/stackinator/schema/config.json @@ -15,8 +15,8 @@ "spack" : { "type" : "object", "additionalProperties": false, + "required": ["repo", "commit", "packages"], "properties" : { - "required": ["repo", "commit", "packages"], "repo": { "type": "string" }, From f29bed811fdc49c7dbc9817e4badd5f6205bfc34 Mon Sep 17 00:00:00 2001 From: Alberto Invernizzi Date: Wed, 30 Jul 2025 18:07:23 +0200 Subject: [PATCH 2/6] adapt tests to new schema --- unittests/recipes/base-nvgpu/config.yaml | 5 ++++- unittests/recipes/cache/config.yaml | 5 ++++- unittests/recipes/host-recipe/config.yaml | 5 ++++- unittests/recipes/with-repo/config.yaml | 5 ++++- unittests/test_schema.py | 2 +- unittests/yaml/config.defaults.yaml | 6 ++++-- unittests/yaml/config.full.yaml | 3 +++ 7 files changed, 24 insertions(+), 7 deletions(-) diff --git a/unittests/recipes/base-nvgpu/config.yaml b/unittests/recipes/base-nvgpu/config.yaml index a2b14813..6d560d69 100644 --- a/unittests/recipes/base-nvgpu/config.yaml +++ b/unittests/recipes/base-nvgpu/config.yaml @@ -2,7 +2,10 @@ name: cuda-env store: /user-environment spack: repo: https://github.com/spack/spack.git - commit: 6408b51 + commit: develop + packages: + repo: https://github.com/spack/spack-packages.git + commit: develop mirror: enable: false version: 2 diff --git a/unittests/recipes/cache/config.yaml b/unittests/recipes/cache/config.yaml index ee25a292..031aa85a 100644 --- a/unittests/recipes/cache/config.yaml +++ b/unittests/recipes/cache/config.yaml @@ -2,7 +2,10 @@ name: cached-example store: '/user-environment' spack: repo: https://github.com/spack/spack.git - commit: 6408b51 + commit: releases/v1.0 + packages: + repo: https://github.com/spack/spack-packages.git + commit: releases/v2025.07 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..cb9c2399 100644 --- a/unittests/recipes/host-recipe/config.yaml +++ b/unittests/recipes/host-recipe/config.yaml @@ -2,6 +2,9 @@ name: host-example store: /user-environment description: "An example gcc configuration for CPU-only development" spack: - commit: releases/v0.23 + commit: releases/v1.0 repo: https://github.com/spack/spack.git + packages: + commit: releases/v2025.07 + 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..b50eb82f 100644 --- a/unittests/recipes/with-repo/config.yaml +++ b/unittests/recipes/with-repo/config.yaml @@ -2,5 +2,8 @@ name: with-repo store: '/user-environment' spack: repo: https://github.com/spack/spack.git - commit: v21.0 + commit: releases/v1.0 + packages: + repo: https://github.com/spack/spack-packages.git + commit: develop version: 2 diff --git a/unittests/test_schema.py b/unittests/test_schema.py index 6850e5fe..d4585042 100644 --- a/unittests/test_schema.py +++ b/unittests/test_schema.py @@ -41,7 +41,6 @@ def test_config_yaml(yaml_path): raw = yaml.load(fid, Loader=yaml.Loader) schema.ConfigValidator.validate(raw) assert raw["store"] == "/user-environment" - assert raw["spack"]["commit"] is None assert raw["modules"] == True # noqa: E712 assert raw["mirror"] == {"enable": True, "key": None} assert raw["description"] is None @@ -51,6 +50,7 @@ def test_config_yaml(yaml_path): schema.ConfigValidator.validate(raw) assert raw["store"] == "/alternative-point" assert raw["spack"]["commit"] == "6408b51" + assert raw["spack"]["packages"]["commit"] == "develop" 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..9c530ea2 100644 --- a/unittests/yaml/config.defaults.yaml +++ b/unittests/yaml/config.defaults.yaml @@ -3,8 +3,10 @@ name: cuda-env #store: /user-environment spack: repo: https://github.com/spack/spack.git - # default: None == no `git checkout` command - #commit: 6408b51 + commit: 6408b51 + packages: + repo: https://github.com/spack/spack-packages.git + commit: develop #mirror: # default None #key: None diff --git a/unittests/yaml/config.full.yaml b/unittests/yaml/config.full.yaml index 26267c6d..47faaa5f 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: develop mirror: key: /home/bob/veryprivate.key enable: True From 24e6ec76ca9ca3ca95ffcc41a1cc2bd73deb5c81 Mon Sep 17 00:00:00 2001 From: Alberto Invernizzi Date: Wed, 30 Jul 2025 18:08:31 +0200 Subject: [PATCH 3/6] update also this recipe --- unittests/data/arbor-uenv/meta/recipe/config.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/unittests/data/arbor-uenv/meta/recipe/config.yaml b/unittests/data/arbor-uenv/meta/recipe/config.yaml index cf2ab463..b3f631c7 100644 --- a/unittests/data/arbor-uenv/meta/recipe/config.yaml +++ b/unittests/data/arbor-uenv/meta/recipe/config.yaml @@ -1,6 +1,10 @@ name: arbor spack: - commit: releases/v0.21 + commit: releases/v1.0 repo: https://github.com/spack/spack.git + packages: + commit: releases/v2025.07 + repo: https://github.com/spack/spack-packages.git store: /user-environment description: The Arbor neuroscience simulation package and its dependencies for multicore systems. +version: 2 From 74a7fc23456fa388d8431cfe467aa7aeacb040e0 Mon Sep 17 00:00:00 2001 From: Alberto Invernizzi Date: Thu, 31 Jul 2025 16:46:33 +0200 Subject: [PATCH 4/6] improve schema introducing a "git-repo" subschema --- stackinator/schema/config.json | 55 +++++++++++++++------------------- 1 file changed, 24 insertions(+), 31 deletions(-) diff --git a/stackinator/schema/config.json b/stackinator/schema/config.json index 18399370..ea2c091d 100644 --- a/stackinator/schema/config.json +++ b/stackinator/schema/config.json @@ -12,37 +12,14 @@ "type" : "string", "default" : "/user-environment" }, - "spack" : { - "type" : "object", + "spack": { + "$ref": "#/$defs/git-repo", "additionalProperties": false, - "required": ["repo", "commit", "packages"], - "properties" : { - "repo": { - "type": "string" - }, - "commit": { - "oneOf": [ - {"type" : "string"}, - {"type" : "null"} - ], - "default": null - }, - "packages" : { - "type" : "object", - "additionalProperties": false, - "required": ["repo", "commit"], - "properties" : { - "repo": { - "type": "string" - }, - "commit": { - "oneOf": [ - {"type" : "string"}, - {"type" : "null"} - ], - "default": null - } - } + "required": ["packages"], + "properties": { + "packages": { + "$ref": "#/$defs/git-repo", + "additionalProperties": false } } }, @@ -77,7 +54,23 @@ }, "version" : { "type": "number", - "default": 1 + "default": 1, + "minimum": 1, + "maximum": 2 + } + }, + "$defs": { + "git-repo": { + "type": "object", + "required": ["repo"], + "properties" : { + "repo": { + "type": "string" + }, + "commit": { + "type": "string" + } + } } } } From d9bb90bd8436fa0e4a04ac6ce9442d54b98022f6 Mon Sep 17 00:00:00 2001 From: Alberto Invernizzi Date: Mon, 11 Aug 2025 18:16:00 +0200 Subject: [PATCH 5/6] revert usage of $ref custom validator for defaults needs an upgrade for $ref. leave it for another separate PR --- stackinator/schema/config.json | 45 ++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/stackinator/schema/config.json b/stackinator/schema/config.json index ea2c091d..99d6cd0f 100644 --- a/stackinator/schema/config.json +++ b/stackinator/schema/config.json @@ -13,13 +13,36 @@ "default" : "/user-environment" }, "spack": { - "$ref": "#/$defs/git-repo", + "type": "object", "additionalProperties": false, - "required": ["packages"], + "required": ["repo", "packages"], "properties": { + "repo": { + "type": "string" + }, + "commit": { + "oneOf": [ + {"type" : "string"}, + {"type" : "null"} + ], + "default": null + }, "packages": { - "$ref": "#/$defs/git-repo", - "additionalProperties": false + "type": "object", + "additionalProperties": false, + "required": ["repo"], + "properties" : { + "repo": { + "type": "string" + }, + "commit": { + "oneOf": [ + {"type" : "string"}, + {"type" : "null"} + ], + "default": null + } + } } } }, @@ -58,19 +81,5 @@ "minimum": 1, "maximum": 2 } - }, - "$defs": { - "git-repo": { - "type": "object", - "required": ["repo"], - "properties" : { - "repo": { - "type": "string" - }, - "commit": { - "type": "string" - } - } - } } } From ebd0359fd0e931f67dc9049fe8ba64ccdbb1e2b1 Mon Sep 17 00:00:00 2001 From: Alberto Invernizzi Date: Mon, 11 Aug 2025 19:01:50 +0200 Subject: [PATCH 6/6] adapt tests resources + add some basic test for spack/spack:packages defaults --- .../data/arbor-uenv/meta/recipe/config.yaml | 5 +- unittests/recipes/base-nvgpu/config.yaml | 3 +- unittests/recipes/cache/config.yaml | 3 +- unittests/recipes/host-recipe/config.yaml | 3 +- unittests/recipes/with-repo/config.yaml | 5 +- unittests/test_schema.py | 47 ++++++++++++++++++- unittests/yaml/config.defaults.yaml | 8 ++-- unittests/yaml/config.full.yaml | 2 +- 8 files changed, 58 insertions(+), 18 deletions(-) diff --git a/unittests/data/arbor-uenv/meta/recipe/config.yaml b/unittests/data/arbor-uenv/meta/recipe/config.yaml index b3f631c7..37ca9a60 100644 --- a/unittests/data/arbor-uenv/meta/recipe/config.yaml +++ b/unittests/data/arbor-uenv/meta/recipe/config.yaml @@ -1,10 +1,7 @@ name: arbor spack: - commit: releases/v1.0 + commit: releases/v0.21 repo: https://github.com/spack/spack.git - packages: - commit: releases/v2025.07 - repo: https://github.com/spack/spack-packages.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 6d560d69..0102735a 100644 --- a/unittests/recipes/base-nvgpu/config.yaml +++ b/unittests/recipes/base-nvgpu/config.yaml @@ -2,10 +2,9 @@ name: cuda-env store: /user-environment spack: repo: https://github.com/spack/spack.git - commit: develop + commit: 6408b51 packages: repo: https://github.com/spack/spack-packages.git - commit: develop mirror: enable: false version: 2 diff --git a/unittests/recipes/cache/config.yaml b/unittests/recipes/cache/config.yaml index 031aa85a..8609b78a 100644 --- a/unittests/recipes/cache/config.yaml +++ b/unittests/recipes/cache/config.yaml @@ -2,10 +2,9 @@ name: cached-example store: '/user-environment' spack: repo: https://github.com/spack/spack.git - commit: releases/v1.0 + commit: 6408b51 packages: repo: https://github.com/spack/spack-packages.git - commit: releases/v2025.07 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 cb9c2399..780cf031 100644 --- a/unittests/recipes/host-recipe/config.yaml +++ b/unittests/recipes/host-recipe/config.yaml @@ -2,9 +2,8 @@ name: host-example store: /user-environment description: "An example gcc configuration for CPU-only development" spack: - commit: releases/v1.0 + commit: releases/v0.23 repo: https://github.com/spack/spack.git packages: - commit: releases/v2025.07 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 b50eb82f..a3cb2940 100644 --- a/unittests/recipes/with-repo/config.yaml +++ b/unittests/recipes/with-repo/config.yaml @@ -2,8 +2,7 @@ name: with-repo store: '/user-environment' spack: repo: https://github.com/spack/spack.git - commit: releases/v1.0 + commit: v21.0 packages: - repo: https://github.com/spack/spack-packages.git - commit: develop + repo: https://github.com/spack/spack-packages.git version: 2 diff --git a/unittests/test_schema.py b/unittests/test_schema.py index d4585042..1b376c6f 100644 --- a/unittests/test_schema.py +++ b/unittests/test_schema.py @@ -41,16 +41,61 @@ def test_config_yaml(yaml_path): raw = yaml.load(fid, Loader=yaml.Loader) 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"] == "develop" + 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 9c530ea2..d021bd01 100644 --- a/unittests/yaml/config.defaults.yaml +++ b/unittests/yaml/config.defaults.yaml @@ -3,10 +3,12 @@ name: cuda-env #store: /user-environment spack: repo: https://github.com/spack/spack.git - commit: 6408b51 + # default: None == no `git checkout` command + #commit: 6408b51 packages: - repo: https://github.com/spack/spack-packages.git - commit: develop + 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 47faaa5f..e13aa035 100644 --- a/unittests/yaml/config.full.yaml +++ b/unittests/yaml/config.full.yaml @@ -5,7 +5,7 @@ spack: commit: 6408b51 packages: repo: https://github.com/spack/spack-packages.git - commit: develop + commit: v2025.07.0 mirror: key: /home/bob/veryprivate.key enable: True