Skip to content

Commit

Permalink
Use full capability versioning in workflow yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryNguyen5 committed May 24, 2024
1 parent ec140ee commit 54707d3
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 30 deletions.
8 changes: 4 additions & 4 deletions pkg/workflows/models_yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ type stepDefinitionYaml struct {
// (For Keystone only.) More specific than a major version is specified.
//
// Example (string)
// id: read_chain:chain_ethereum:network_mainnet@1
// id: read_chain:chain_ethereum:network_mainnet@1.0.0
//
// Example (table)
//
Expand Down Expand Up @@ -233,7 +233,7 @@ type stepDefinitionYaml struct {
//
// Example
// targets:
// - id: write_polygon_mainnet@1
// - id: write_polygon_mainnet@1.0.0
// inputs:
// report:
// - consensus.evm_median.outputs.report
Expand Down Expand Up @@ -305,7 +305,7 @@ func (stepDefinitionID) JSONSchema() *jsonschema.Schema {
tableSchema := reflector.Reflect(&stepDefinitionTableID{})
stringSchema := &jsonschema.Schema{
ID: "string",
Pattern: "^[a-z0-9_\\-:]+@(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$",
Pattern: "^[a-z0-9_\\-:]+@(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$",
}

return &jsonschema.Schema{
Expand All @@ -320,7 +320,7 @@ func (stepDefinitionID) JSONSchema() *jsonschema.Schema {
// stepDefinitionTableID is the structured representation of a stepDefinitionID.
type stepDefinitionTableID struct {
Name string `json:"name"`
Version string `json:"version" jsonschema:"pattern=(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"`
Version string `json:"version" jsonschema:"pattern=(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"`
Labels map[string]string `json:"labels"`
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/workflows/models_yaml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func TestWorkflowSpecMarshalling(t *testing.T) {
require.NoError(t, err)

// change this to update golden file
shouldUpdateWorkflowSpec := false
shouldUpdateWorkflowSpec := true
if shouldUpdateWorkflowSpec {
err = os.WriteFile(expectedSpecPath, workflowSpecBytes, 0600)
require.NoError(t, err)
Expand All @@ -176,7 +176,7 @@ func TestJsonSchema(t *testing.T) {
require.NoError(t, err)

// change this to update golden file
shouldUpdateSchema := false
shouldUpdateSchema := true
if shouldUpdateSchema {
err = os.WriteFile(expectedSchemaPath, generatedSchema, 0600)
require.NoError(t, err)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
triggers:
- id: mercury-trigger@1
- id: mercury-trigger@1.0.0
ref: report_data
config:
boolean_coercion:
Expand Down Expand Up @@ -54,7 +54,7 @@
# no actions

consensus:
- id: offchain_reporting@1
- id: offchain_reporting@1.0.0
inputs:
observations:
- triggers.report_data.outputs
Expand All @@ -76,7 +76,7 @@
abi: "mercury_reports bytes[]"

targets:
- id: write_polygon_mainnet@1
- id: write_polygon_mainnet@1.0.0
inputs:
report:
- consensus.evm_median.outputs.report
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
triggers:
- id: on_mercury_report@1
- id: on_mercury_report@1.0.0
ref: report_data
config: {}

Expand All @@ -19,7 +19,7 @@
- triggers.report_data.outputs

targets:
- id: write_polygon_mainnet@1
- id: write_polygon_mainnet@1.0.0
config: {}
inputs:
report:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"triggers": [
{
"id": "on_mercury_report@1",
"id": "on_mercury_report@1.0.0",
"ref": "report_data",
"config": {}
}
Expand All @@ -19,7 +19,7 @@
],
"targets": [
{
"id": "write_polygon_mainnet@1",
"id": "write_polygon_mainnet@1.0.0",
"inputs": {
"report": [
"consensus.evm_median.outputs.report"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
triggers:
- id: trigger_test@1
- id: trigger_test@1.0.0
config: {}

consensus:
- id: offchain_reporting@1
- id: offchain_reporting@1.0.0
ref: offchain_reporting=1
config: {}

targets:
- id: write_polygon_mainnet@1
- id: write_polygon_mainnet@1.0.0
ref: write_polygon_mainnet_1
config: {}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
triggers:
- id: trigger_test@1
- id: trigger_test@1.0.0
config: {}

consensus:
- id: offchain_reporting@1
- id: offchain_reporting@1.0.0
ref: offchain_reporting_1
config: {}

targets:
- id: write_polygon_mainnet@1
- id: write_polygon_mainnet@1.0.0
ref: write_polygon_mainnet_1
config: {}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# Should fail since version is more specific than major
triggers:
- id: trigger_test@1.0
config: {}
Expand All @@ -9,7 +8,7 @@ consensus:
config: {}

targets:
- id: write_polygon_mainnet@1
- id: write_polygon_mainnet@1.0.0
ref: write_polygon_mainnet_1
config: {}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@

# Should fail since version is more specific than major
triggers:
- id: trigger_test@1.0.0
- id: trigger_test@1
config: {}

consensus:
- id: offchain_reporting@1
- id: offchain_reporting@1.0
ref: offchain_reporting_1
config: {}

targets:
- id: write_polygon_mainnet@1
- id: write_polygon_mainnet@1.0.0
ref: write_polygon_mainnet_1
config: {}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
triggers:
- id: trigger_test@1
- id: trigger_test@1.0.0
config: {}

consensus:
- id: offchain_reporting@1-beta.1
- id: offchain_reporting@1.0.0-beta.1
ref: offchain_reporting_1
config: {}

targets:
- id: write_polygon_mainnet@1-alpha+sha246er3
- id: write_polygon_mainnet@1.0.0-alpha+sha246er3
ref: write_polygon_mainnet_1
config: {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"oneOf": [
{
"$id": "string",
"pattern": "^[a-z0-9_\\-:]+@(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"
"pattern": "^[a-z0-9_\\-:]+@(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"
},
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
Expand All @@ -21,7 +21,7 @@
},
"version": {
"type": "string",
"pattern": "(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"
"pattern": "(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"
},
"labels": {
"additionalProperties": {
Expand Down

0 comments on commit 54707d3

Please sign in to comment.