From 8ae856919756abebf806fc14d7a15d2dae444cb4 Mon Sep 17 00:00:00 2001 From: Brice Nkengsa Date: Wed, 27 Nov 2024 21:59:42 +0100 Subject: [PATCH] feat(circleciconfig): extend the schema of the requires stanza --- .../invalid-workflow-job-requires.yml | 10 ++++++ src/schemas/json/circleciconfig.json | 32 ++++++++++++++++++- .../circleciconfig/workflow-job-requires.yaml | 16 ++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 src/negative_test/circleciconfig/invalid-workflow-job-requires.yml create mode 100644 src/test/circleciconfig/workflow-job-requires.yaml diff --git a/src/negative_test/circleciconfig/invalid-workflow-job-requires.yml b/src/negative_test/circleciconfig/invalid-workflow-job-requires.yml new file mode 100644 index 00000000000..a4483ed54ab --- /dev/null +++ b/src/negative_test/circleciconfig/invalid-workflow-job-requires.yml @@ -0,0 +1,10 @@ +# yaml-language-server: $schema=../../schemas/json/circleciconfig.json +version: 2.1 + +workflows: + test-workflow: + jobs: + - foo + - bar: + requires: + - foo: invalid_job_status diff --git a/src/schemas/json/circleciconfig.json b/src/schemas/json/circleciconfig.json index a2810323304..6280731a973 100644 --- a/src/schemas/json/circleciconfig.json +++ b/src/schemas/json/circleciconfig.json @@ -1071,7 +1071,37 @@ "description": "Jobs are run in parallel by default, so you must explicitly require any dependencies by their job name.", "type": "array", "items": { - "type": "string" + "oneOf": [ + { + "description": "A dependency defined by their job name.", + "type": "string" + }, + { + "description": "A dependency defined by their job name, and required statuses.", + "type": "object", + "minProperties": 1, + "maxProperties": 1, + "patternProperties": { + "^[A-Za-z][A-Za-z\\s\\d_-]*$": { + "oneOf": [ + { + "description": "A status that the job must have to satisfy the dependency.", + "type": "string", + "enum": ["success", "failed", "canceled"] + }, + { + "description": "A list of statuses that the job must have one of to satisfy the dependency.", + "type": "array", + "minLength": 1, + "items": { + "type": "string", + "enum": ["success", "failed", "canceled"] + } + } + ] + }} + } + ] } }, "name": { diff --git a/src/test/circleciconfig/workflow-job-requires.yaml b/src/test/circleciconfig/workflow-job-requires.yaml new file mode 100644 index 00000000000..fe4d41db1b8 --- /dev/null +++ b/src/test/circleciconfig/workflow-job-requires.yaml @@ -0,0 +1,16 @@ +# yaml-language-server: $schema=../../schemas/json/circleciconfig.json +version: 2.1 + +workflows: + test-workflow: + jobs: + - foo + - bar + - baz + - qux: + requires: + - foo + - bar: failed + - baz: + - success + - canceled