Skip to content

Commit

Permalink
feat: add JSON schema (#140)
Browse files Browse the repository at this point in the history
Related to #125

This PR adds a minimal JSON schema, that validates the first level of
keys and sets the groundwork for #125. It also adds a language server
directive to all examples and the default config (although this last one
will only work once this PR is merged).
  • Loading branch information
MegaRedHand authored Dec 11, 2024
1 parent 5b3ff91 commit b0d32b8
Show file tree
Hide file tree
Showing 7 changed files with 185 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ jobs:
- name: Kurtosis Lint
run: make kurtosis_lint

schema_checker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Validate all example config files using their own $schema properties
uses: cardinalby/schema-validator-action@v3
with:
file: 'examples/*.yaml'
schema: 'schema.json'

# Golang CI
go_fmt:
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions examples/hello_world.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# yaml-language-server: $schema=../schema.json

# Example devnet config file for the hello-world-avs example
deployments:
- name: EigenLayer
Expand Down
2 changes: 2 additions & 0 deletions examples/hello_world_local.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# yaml-language-server: $schema=../schema.json

# Local devnet config file for the hello-world-avs example
# This file can be used inside the hello-world-avs repo to start
# a devnet with any local changes
Expand Down
2 changes: 2 additions & 0 deletions examples/incredible_squaring.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# yaml-language-server: $schema=../schema.json

# Example devnet config file for the incredible-squaring-avs example
deployments:
- type: EigenLayer
Expand Down
2 changes: 2 additions & 0 deletions examples/incredible_squaring_local.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# yaml-language-server: $schema=../schema.json

# Local devnet config file for the incredible-squaring-avs example
# This file can be used inside the incredible-squaring-avs repo to
# start a devnet with any local changes
Expand Down
166 changes: 166 additions & 0 deletions schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
{
"$schema": "https://json-schema.org/draft-07/schema",
"$ref": "#/definitions/DevnetConfig",
"definitions": {
"DevnetConfig": {
"type": "object",
"additionalProperties": false,
"properties": {
"deployments": {
"type": "array",
"items": {
"$ref": "#/definitions/Deployment"
}
},
"services": {
"type": "array",
"items": {
"$ref": "#/definitions/Service"
}
},
"keys": {
"type": "array",
"items": {
"$ref": "#/definitions/Key"
}
},
"artifacts": {
"$ref": "#/definitions/Artifacts"
},
"ethereum_package": {
"$ref": "#/definitions/EthereumPackage"
}
},
"required": [],
"title": "DevnetConfig"
},
"Deployment": {
"type": "object",
"additionalProperties": false,
"properties": {
"name": {
"type": "string"
},
"repo": {
"type": "string"
},
"ref": {
"type": "string"
},
"contracts_path": {
"type": "string"
},
"script": {
"type": "string"
},
"extra_args": {
"type": "string"
},
"verify": {
"type": "boolean"
},
"env": {
"type": "object"
},
"input": {
"type": "object"
},
"output": {
"type": "object"
},
"addresses": {
"type": "object"
},
"type": {
"type": "string"
},
"strategies": {
"type": "array",
"items": {
"type": "string"
}
},
"operators": {
"type": "array",
"items": {
"type": "object"
}
}
},
"required": [],
"title": "Deployment"
},
"Service": {
"type": "object",
"additionalProperties": false,
"properties": {
"name": {
"type": "string"
},
"image": {
"type": "string"
},
"build_context": {
"type": "string"
},
"build_file": {
"type": "string"
},
"build_cmd": {
"type": "string"
},
"ports": {
"type": "object"
},
"input": {
"type": "object"
},
"env": {
"type": "object"
},
"cmd": {
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
"image",
"name"
],
"title": "Service"
},
"Key": {
"type": "object",
"additionalProperties": false,
"properties": {
"name": {
"type": "string"
},
"type": {
"type": "string"
},
"address": {
"type": "string"
},
"private_key": {
"type": "string"
}
},
"required": [],
"title": "Key"
},
"Artifacts": {
"type": "object",
"additionalProperties": true,
"required": [],
"title": "Artifacts"
},
"EthereumPackage": {
"type": "object",
"additionalProperties": true,
"title": "ethereum-package args"
}
}
}
1 change: 1 addition & 0 deletions src/config/default_config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# yaml-language-server: $schema=https://github.com/Layr-Labs/avs-devnet/blob/master/schema.json
deployments:
# Deploy EigenLayer
- type: EigenLayer
Expand Down

0 comments on commit b0d32b8

Please sign in to comment.