From 2fec90818e890cc69ddbd2e3a545f935036e0b14 Mon Sep 17 00:00:00 2001 From: mitchell amihod <4623+meeech@users.noreply.github.com> Date: Thu, 24 Apr 2025 00:11:59 -0400 Subject: [PATCH 1/7] fix: add missing job types to publicschema.json --- publicschema.json | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/publicschema.json b/publicschema.json index 3d8a5503..1d0ab77a 100644 --- a/publicschema.json +++ b/publicschema.json @@ -1100,10 +1100,14 @@ "default": "org-global" }, "type": { - "description": "A job may have a `type` of `approval` indicating it must be manually approved before downstream jobs may proceed.", + "description": "Job type, can be build, release, no-op, or approval. If not specified, defaults to build.\nhttps://circleci.com/docs/configuration-reference/#job-type", "enum": [ - "approval" - ] + "approval", + "build", + "no-op", + "release" + ], + "default": "build" }, "filters": { "description": "A map defining rules for execution on specific branches", @@ -1346,4 +1350,4 @@ ], "title": "JSON schema for CircleCI configuration files", "type": "object" -} \ No newline at end of file +} From ddc9afbe4f331dacf5cc2ba5ea53e01851815862 Mon Sep 17 00:00:00 2001 From: mitchell amihod <4623+meeech@users.noreply.github.com> Date: Thu, 24 Apr 2025 00:20:15 -0400 Subject: [PATCH 2/7] fix description of job types --- pkg/services/hover/workflow.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/services/hover/workflow.go b/pkg/services/hover/workflow.go index 623f2b48..4cbba2e2 100644 --- a/pkg/services/hover/workflow.go +++ b/pkg/services/hover/workflow.go @@ -50,7 +50,7 @@ func jobReference(name string) string { "- `requires`: Jobs are run in parallel by default, so you must explicitly require any dependencies by their job name.\n" + "- `name`: can be used to invoke reusable jobs across any number of workflows. Using the `name` key ensures numbers are not appended to your job name (i.e. sayhello-1 , sayhello-2, etc.). The name you assign to the name key needs to be unique, otherwise the numbers will still be appended to the job name.\n" + "- `context`: Jobs may be configured to use global environment variables set for an organization, see the Contexts document for adding a context in the application settings.\n" + - "- `type`: A job may have a type of `approval` indicating it must be manually approved before downstream jobs may proceed.\n" + + "- `type`: Job type, can be build, release, no-op, or approval. If not specified, defaults to build.\n" + "- `filters`: Job Filters can have the key branches or tags.+\n" + "- `matrix` : requires config `2.1`. The `matrix` stanza allows you to run a parameterized job multiple times with different arguments.\n" + "- `pre-steps` and `post-steps`: requires config `2.1`. Steps under `pre-steps` are executed before any of the other steps in the job. The steps under `post-steps` are executed after all of the other steps.\n" From 8444d466864007d47b87f96057da3eca87b2dc56 Mon Sep 17 00:00:00 2001 From: mitchell amihod <4623+meeech@users.noreply.github.com> Date: Thu, 24 Apr 2025 00:23:32 -0400 Subject: [PATCH 3/7] allow all valid job types --- pkg/parser/validate/workflow.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/pkg/parser/validate/workflow.go b/pkg/parser/validate/workflow.go index 30e2291e..0c80f152 100644 --- a/pkg/parser/validate/workflow.go +++ b/pkg/parser/validate/workflow.go @@ -20,14 +20,22 @@ func (val Validate) validateSingleWorkflow(workflow ast.Workflow) error { continue } - isApprovalJob := jobRef.Type == "approval" - if isApprovalJob { + // Define valid job types + validJobTypesMap := map[string]bool{ + "approval": true, + "build": true, + "no-op": true, + "release": true, + } + + // Direct lookup in the map + if validJobTypesMap[jobRef.Type] { continue } jobTypeIsDefined := jobRef.Type != "" if jobTypeIsDefined { - val.addDiagnostic(utils.CreateErrorDiagnosticFromRange(jobRef.TypeRange, "Type can only be \"approval\"")) + val.addDiagnostic(utils.CreateErrorDiagnosticFromRange(jobRef.TypeRange, fmt.Sprintf("Job Type \"%s\" is not valid", jobRef.Type))) continue } From 658f79e6c3739cee7b3a04156ca5c2697502eb5c Mon Sep 17 00:00:00 2001 From: mitchell amihod <4623+meeech@users.noreply.github.com> Date: Thu, 24 Apr 2025 00:38:11 -0400 Subject: [PATCH 4/7] fix(test): reflect changed code --- pkg/parser/validate/workflow_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/parser/validate/workflow_test.go b/pkg/parser/validate/workflow_test.go index 767a79a2..0ef29f16 100644 --- a/pkg/parser/validate/workflow_test.go +++ b/pkg/parser/validate/workflow_test.go @@ -42,7 +42,7 @@ workflows: utils.CreateErrorDiagnosticFromRange(protocol.Range{ Start: protocol.Position{Line: 0x6, Character: 0x10}, End: protocol.Position{Line: 0x6, Character: 0x17}, - }, "Type can only be \"approval\""), + }, "Job Type \"invalid\" is not valid"), }, }, { From b45c7e4f876b2c9672d601a9ca8e9ee56f3fe768 Mon Sep 17 00:00:00 2001 From: mitchell amihod <4623+meeech@users.noreply.github.com> Date: Thu, 24 Apr 2025 00:53:23 -0400 Subject: [PATCH 5/7] Add awareness of plan_name --- pkg/services/hover/workflow.go | 2 ++ publicschema.json | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/pkg/services/hover/workflow.go b/pkg/services/hover/workflow.go index 4cbba2e2..a959b507 100644 --- a/pkg/services/hover/workflow.go +++ b/pkg/services/hover/workflow.go @@ -54,6 +54,8 @@ func jobReference(name string) string { "- `filters`: Job Filters can have the key branches or tags.+\n" + "- `matrix` : requires config `2.1`. The `matrix` stanza allows you to run a parameterized job multiple times with different arguments.\n" + "- `pre-steps` and `post-steps`: requires config `2.1`. Steps under `pre-steps` are executed before any of the other steps in the job. The steps under `post-steps` are executed after all of the other steps.\n" + "- `plan_name`: requires release job type. Used to link your release to a release plan. https://circleci.com/docs/deploy/deploys-overview/\n" + } func HoverInWorkflows(doc yamlparser.YamlDocument, path []string) string { diff --git a/publicschema.json b/publicschema.json index 1d0ab77a..3e1fa5c6 100644 --- a/publicschema.json +++ b/publicschema.json @@ -1109,6 +1109,10 @@ ], "default": "build" }, + "plan_name": { + "description": "Used with release job type.\nhttps://circleci.com/docs/deploy/deploys-overview/", + "type": "string" + }, "filters": { "description": "A map defining rules for execution on specific branches", "type": "object", From d29e744b7fab0103724d1917cf25977527564430 Mon Sep 17 00:00:00 2001 From: mitchell amihod <4623+meeech@users.noreply.github.com> Date: Thu, 24 Apr 2025 00:53:33 -0400 Subject: [PATCH 6/7] add more tests --- pkg/parser/validate/workflow_test.go | 31 ++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/pkg/parser/validate/workflow_test.go b/pkg/parser/validate/workflow_test.go index 0ef29f16..572c80e5 100644 --- a/pkg/parser/validate/workflow_test.go +++ b/pkg/parser/validate/workflow_test.go @@ -90,6 +90,37 @@ workflows: - deploy: override-with: local/deploy`, }, + { + Name: "No-op job type", + YamlContent: `version: 2.1 + +workflows: + someworkflow: + jobs: + - hold: + type: no-op`, + }, + { + Name: "Release job type", + YamlContent: `version: 2.1 + +workflows: + someworkflow: + jobs: + - hold: + type: release + plan_name: my-service-release`, + }, + { + Name: "Build job type", + YamlContent: `version: 2.1 + +workflows: + someworkflow: + jobs: + - hold: + type: build`, + }, } CheckYamlErrors(t, testCases) From 32aece306a1325f4bad51cdd962b815a0c0c4e26 Mon Sep 17 00:00:00 2001 From: mitchell amihod <4623+meeech@users.noreply.github.com> Date: Thu, 24 Apr 2025 00:57:45 -0400 Subject: [PATCH 7/7] fix tests --- pkg/services/hover/workflow.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkg/services/hover/workflow.go b/pkg/services/hover/workflow.go index a959b507..995f27db 100644 --- a/pkg/services/hover/workflow.go +++ b/pkg/services/hover/workflow.go @@ -53,9 +53,8 @@ func jobReference(name string) string { "- `type`: Job type, can be build, release, no-op, or approval. If not specified, defaults to build.\n" + "- `filters`: Job Filters can have the key branches or tags.+\n" + "- `matrix` : requires config `2.1`. The `matrix` stanza allows you to run a parameterized job multiple times with different arguments.\n" + - "- `pre-steps` and `post-steps`: requires config `2.1`. Steps under `pre-steps` are executed before any of the other steps in the job. The steps under `post-steps` are executed after all of the other steps.\n" - "- `plan_name`: requires release job type. Used to link your release to a release plan. https://circleci.com/docs/deploy/deploys-overview/\n" - + "- `pre-steps` and `post-steps`: requires config `2.1`. Steps under `pre-steps` are executed before any of the other steps in the job. The steps under `post-steps` are executed after all of the other steps.\n" + + "- `plan_name`: requires release job type. Used to link your release to a release plan. https://circleci.com/docs/deploy/deploys-overview/\n" } func HoverInWorkflows(doc yamlparser.YamlDocument, path []string) string {