Skip to content

Commit

Permalink
schema: catch invalid configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
no92 committed Aug 9, 2023
1 parent 7e1374a commit fb03ee7
Showing 1 changed file with 88 additions and 0 deletions.
88 changes: 88 additions & 0 deletions xbstrap/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,50 @@ definitions:
'sources_required': { $ref: '#/definitions/source_deps' }
'tools_required': { $ref: '#/definitions/tool_deps' }

# keep this in sync with the `sources` definition, as this apparently can't be $ref'ed
dependencies:
# when `git` is used, disallow `svn`, `hg` and `url`
git:
not:
anyOf:
- required:
- hg
- required:
- svn
- required:
- url

# when `tag` is used, disallow `branch` and `commit`
tag:
not:
anyOf:
- required:
- branch
- required:
- commit

branch:
# require any of `commit` or `rolling_version` to be present
anyOf:
- required:
- commit
- required:
- rolling_version
# when branch is used, disallow `tag`
not:
required:
- tag

# when commit is used, branch is required
commit:
required:
- branch

# when rolling_version is used, branch is required
rolling_version:
required:
- branch

'nested_task':
type: object
additionalProperties: false
Expand Down Expand Up @@ -253,6 +297,50 @@ properties:
'regenerate': { $ref: '#/definitions/build_steps' }
'sources_required': { $ref: '#/definitions/source_deps' }
'tools_required': { $ref: '#/definitions/tool_deps' }

# keep this in sync with the `nested_sources` definition, as this apparently can't be $ref'ed
dependencies:
# when `git` is used, disallow `svn`, `hg` and `url`
git:
not:
anyOf:
- required:
- hg
- required:
- svn
- required:
- url

# when `tag` is used, disallow `branch` and `commit`
tag:
not:
anyOf:
- required:
- branch
- required:
- commit

branch:
# require any of `commit` or `rolling_version` to be present
anyOf:
- required:
- commit
- required:
- rolling_version
# when branch is used, disallow `tag`
not:
required:
- tag

# when commit is used, branch is required
commit:
required:
- branch

# when rolling_version is used, branch is required
rolling_version:
required:
- branch
'tools':
type: array
items:
Expand Down

0 comments on commit fb03ee7

Please sign in to comment.