Skip to content

schema: required keywords not enforced for spack in config.yaml#252

Merged
bcumming merged 6 commits intoeth-cscs:mainfrom
albestro:alby/fix-required-commit
Aug 12, 2025
Merged

schema: required keywords not enforced for spack in config.yaml#252
bcumming merged 6 commits intoeth-cscs:mainfrom
albestro:alby/fix-required-commit

Conversation

@albestro
Copy link
Copy Markdown
Contributor

@albestro albestro commented Jul 29, 2025

PR #245 added to the config schema some requirements about spack and spack:packages.

Unfortunately these new changes were just partially enforced, because the schema is not valid due to the required entry for spack being nested in properties.

@bcumming was it your intention to have both repo and commit mandatory for both spack and spack:packages?

@albestro albestro requested a review from bcumming July 29, 2025 14:34
@albestro albestro marked this pull request as draft July 29, 2025 14:38
@albestro
Copy link
Copy Markdown
Contributor Author

From CI it seems that this makes fail schemas v1, which opens up again the topic raised up in #247 (comment)

@albestro
Copy link
Copy Markdown
Contributor Author

This currently depends on #254. If that proposal gets accepted, this can go on.

@albestro albestro force-pushed the alby/fix-required-commit branch from 4d57a56 to 74a7fc2 Compare August 11, 2025 14:51
@albestro albestro marked this pull request as ready for review August 11, 2025 14:51
Copy link
Copy Markdown
Member

@bcumming bcumming left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nice little fix and clean up.

I have one possible nit about not setting a default commit: null value for a git repository type.

Comment thread stackinator/schema/config.json Outdated
"required": ["packages"],
"properties": {
"packages": {
"$ref": "#/$defs/git-repo",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, I had to revert it. But I agree, it is quite nice. I'm going to explore how to change the validator in order to deal correctly with defaults also in presence of $ref, but in a following PR.

Comment thread stackinator/schema/config.json Outdated
"type": "string"
},
"commit": {
"type": "string"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

provide a default value for commit?
Stackinator expects this field to be set, and has logic to ignore it if it is None/null.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bcumming was it your intention to have both repo and commit mandatory for both spack and spack:packages?

do you mean that you don't want commit to be required? it's perfectly fine. I had two ways to fix with this PR, and looking at the misplaced required I inferred that you wanted it to be required (see in #245 https://github.com/eth-cscs/stackinator/pull/245/files#diff-2bdfe86113f7b73f4dd5fef35aaa8a54fe83e02e02bf212360979e4c23cada84).

Just to be clear, I think that:

  • if commit is required, we can skip the default value
  • if commit is not required, we should put a default (and check it in tests)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think commit should not be required.
We should provide a default that is null (i.e. empty).
This might seem odd, but the code in stackinator expects the field to be set, and gracefully handles the case where the value is "null".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It took a bit of time because I encountered a problem with defaults with $ref. Since it is unrelated and it requires some time, I opted for reverting that change and go for duplication, at least for now. It makes even more clear what is going on in this PR.

On the test side, I just added a couple of "in-place" test-cases for spack:commit and spack:packages:commit defaults. Minimal changes to the rest of test recipes, just to make them pass validation.

custom validator for defaults needs an upgrade for $ref.
leave it for another separate PR
@albestro albestro requested a review from bcumming August 11, 2025 17:07
@albestro
Copy link
Copy Markdown
Contributor Author

@bcumming @simonpintarelli @msimberg

Just to highlight the decision: both spack:commit and spack:packages:commit are not required.

Before this PR, just the latter was required and enforced, while the former was in principle required but it was not enforced (together with other properties), due to the misplaced required field in the schema.

@bcumming bcumming merged commit 8879b95 into eth-cscs:main Aug 12, 2025
2 checks passed
@albestro albestro deleted the alby/fix-required-commit branch August 12, 2025 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants