From 54707d3e6c8e99cf817a37e1b2f84fe016b3c264 Mon Sep 17 00:00:00 2001 From: HenryNguyen5 <6404866+HenryNguyen5@users.noreply.github.com> Date: Thu, 23 May 2024 22:19:14 -0400 Subject: [PATCH] Use full capability versioning in workflow yaml --- pkg/workflows/models_yaml.go | 8 ++++---- pkg/workflows/models_yaml_test.go | 4 ++-- .../fixtures/workflows/marshalling/workflow_1.yaml | 6 +++--- .../fixtures/workflows/marshalling/workflow_2.yaml | 4 ++-- .../fixtures/workflows/marshalling/workflow_2_spec.json | 4 ++-- .../testdata/fixtures/workflows/references/failing_1.yaml | 6 +++--- .../testdata/fixtures/workflows/references/passing_1.yaml | 6 +++--- .../testdata/fixtures/workflows/versioning/failing_1.yaml | 3 +-- .../testdata/fixtures/workflows/versioning/failing_2.yaml | 7 +++---- .../testdata/fixtures/workflows/versioning/passing_1.yaml | 6 +++--- .../testdata/fixtures/workflows/workflow_schema.json | 4 ++-- 11 files changed, 28 insertions(+), 30 deletions(-) diff --git a/pkg/workflows/models_yaml.go b/pkg/workflows/models_yaml.go index 877d8835c..b8f76ca1b 100644 --- a/pkg/workflows/models_yaml.go +++ b/pkg/workflows/models_yaml.go @@ -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) // @@ -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 @@ -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{ @@ -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"` } diff --git a/pkg/workflows/models_yaml_test.go b/pkg/workflows/models_yaml_test.go index e7e638070..6abfe5930 100644 --- a/pkg/workflows/models_yaml_test.go +++ b/pkg/workflows/models_yaml_test.go @@ -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) @@ -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) diff --git a/pkg/workflows/testdata/fixtures/workflows/marshalling/workflow_1.yaml b/pkg/workflows/testdata/fixtures/workflows/marshalling/workflow_1.yaml index 9a9870af8..b2be6f5c8 100644 --- a/pkg/workflows/testdata/fixtures/workflows/marshalling/workflow_1.yaml +++ b/pkg/workflows/testdata/fixtures/workflows/marshalling/workflow_1.yaml @@ -1,5 +1,5 @@ triggers: - - id: mercury-trigger@1 + - id: mercury-trigger@1.0.0 ref: report_data config: boolean_coercion: @@ -54,7 +54,7 @@ # no actions consensus: - - id: offchain_reporting@1 + - id: offchain_reporting@1.0.0 inputs: observations: - triggers.report_data.outputs @@ -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 diff --git a/pkg/workflows/testdata/fixtures/workflows/marshalling/workflow_2.yaml b/pkg/workflows/testdata/fixtures/workflows/marshalling/workflow_2.yaml index be40a91da..c875b995f 100644 --- a/pkg/workflows/testdata/fixtures/workflows/marshalling/workflow_2.yaml +++ b/pkg/workflows/testdata/fixtures/workflows/marshalling/workflow_2.yaml @@ -1,5 +1,5 @@ triggers: - - id: on_mercury_report@1 + - id: on_mercury_report@1.0.0 ref: report_data config: {} @@ -19,7 +19,7 @@ - triggers.report_data.outputs targets: - - id: write_polygon_mainnet@1 + - id: write_polygon_mainnet@1.0.0 config: {} inputs: report: diff --git a/pkg/workflows/testdata/fixtures/workflows/marshalling/workflow_2_spec.json b/pkg/workflows/testdata/fixtures/workflows/marshalling/workflow_2_spec.json index 000fa4692..7c77b6c00 100644 --- a/pkg/workflows/testdata/fixtures/workflows/marshalling/workflow_2_spec.json +++ b/pkg/workflows/testdata/fixtures/workflows/marshalling/workflow_2_spec.json @@ -1,7 +1,7 @@ { "triggers": [ { - "id": "on_mercury_report@1", + "id": "on_mercury_report@1.0.0", "ref": "report_data", "config": {} } @@ -19,7 +19,7 @@ ], "targets": [ { - "id": "write_polygon_mainnet@1", + "id": "write_polygon_mainnet@1.0.0", "inputs": { "report": [ "consensus.evm_median.outputs.report" diff --git a/pkg/workflows/testdata/fixtures/workflows/references/failing_1.yaml b/pkg/workflows/testdata/fixtures/workflows/references/failing_1.yaml index b3c984e98..9b2d45516 100644 --- a/pkg/workflows/testdata/fixtures/workflows/references/failing_1.yaml +++ b/pkg/workflows/testdata/fixtures/workflows/references/failing_1.yaml @@ -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: {} diff --git a/pkg/workflows/testdata/fixtures/workflows/references/passing_1.yaml b/pkg/workflows/testdata/fixtures/workflows/references/passing_1.yaml index cb2f424e9..1daea851d 100644 --- a/pkg/workflows/testdata/fixtures/workflows/references/passing_1.yaml +++ b/pkg/workflows/testdata/fixtures/workflows/references/passing_1.yaml @@ -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: {} diff --git a/pkg/workflows/testdata/fixtures/workflows/versioning/failing_1.yaml b/pkg/workflows/testdata/fixtures/workflows/versioning/failing_1.yaml index 2e41eeb98..85ec011d5 100644 --- a/pkg/workflows/testdata/fixtures/workflows/versioning/failing_1.yaml +++ b/pkg/workflows/testdata/fixtures/workflows/versioning/failing_1.yaml @@ -1,4 +1,3 @@ -# Should fail since version is more specific than major triggers: - id: trigger_test@1.0 config: {} @@ -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: {} diff --git a/pkg/workflows/testdata/fixtures/workflows/versioning/failing_2.yaml b/pkg/workflows/testdata/fixtures/workflows/versioning/failing_2.yaml index 36cd5b68b..a947de76e 100644 --- a/pkg/workflows/testdata/fixtures/workflows/versioning/failing_2.yaml +++ b/pkg/workflows/testdata/fixtures/workflows/versioning/failing_2.yaml @@ -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: {} diff --git a/pkg/workflows/testdata/fixtures/workflows/versioning/passing_1.yaml b/pkg/workflows/testdata/fixtures/workflows/versioning/passing_1.yaml index 4579c2899..261c90995 100644 --- a/pkg/workflows/testdata/fixtures/workflows/versioning/passing_1.yaml +++ b/pkg/workflows/testdata/fixtures/workflows/versioning/passing_1.yaml @@ -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: {} diff --git a/pkg/workflows/testdata/fixtures/workflows/workflow_schema.json b/pkg/workflows/testdata/fixtures/workflows/workflow_schema.json index 1c7fbc850..46beda0c2 100644 --- a/pkg/workflows/testdata/fixtures/workflows/workflow_schema.json +++ b/pkg/workflows/testdata/fixtures/workflows/workflow_schema.json @@ -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", @@ -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": {