Add schema validation for specific subsystems

- Create validation for existing schemas
- Validate only for subsystems with existing schemas
- Also add schemas for nodejs and rust

Co-authored-by: a-kenji <aks.kenji@protonmail.com>
This commit is contained in:
Brian Leung 2022-09-01 11:03:41 -07:00
parent 877b83654f
commit 45101cccc4
No known key found for this signature in database
GPG Key ID: 2D86D6A94C8BB3B1
3 changed files with 80 additions and 0 deletions

View File

@ -0,0 +1,15 @@
{
"$schema": "http://json-schema.org/draft-07/schema",
"title": "manifest",
"type": "object",
"properties": {
"_subsystem": {
"type": "object",
"properties": {
"nodejsVersion": {
"type": "integer"
}
}
}
}
}

View File

@ -0,0 +1,53 @@
{
"$schema": "http://json-schema.org/draft-07/schema",
"title": "manifest",
"type": "object",
"properties": {
"_subsystem": {
"type": "object",
"properties": {
"gitSources": {
"type": "array",
"items": {
"type": "object",
"properties": {
"url": {
"type": "string"
},
"sha": {
"type": "string"
},
"type": {
"type": "string"
},
"value": {
"type": "string"
}
},
"required": ["url", "sha", "type", "value"],
"additionalProperties": false
}
},
"relPathReplacements": {
"type": "object",
"properties": {
"^.*$": {
"type": "object",
"properties": {
"^.*$": {
"type": "object",
"properties": {
"^.*$": {
"type": "string"
}
}
}
}
},
"additionalProperties": false
}
}
}
}
}
}

View File

@ -233,6 +233,18 @@ in
--output pretty \
${../specifications/dream-lock-schema.json}
# if applicable, validate subsystem portion against jsonschema
subsystem=$(jq '._generic.subsystem' $dreamLockPath)
subsystem=''${subsystem%\"}
subsystem=''${subsystem#\"}
schema=${../specifications/subsystems}/$subsystem/dream-lock-schema.json
if [[ -f "$schema" ]]; then
${python3.pkgs.jsonschema}/bin/jsonschema \
--instance $dreamLockPath \
--output pretty \
$schema
fi
# add dream-lock.json to git
if git rev-parse --show-toplevel &>/dev/null; then
echo "adding file to git: $dreamLockPath"