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 } diff --git a/pkg/parser/validate/workflow_test.go b/pkg/parser/validate/workflow_test.go index 767a79a2..572c80e5 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"), }, }, { @@ -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) diff --git a/pkg/services/hover/workflow.go b/pkg/services/hover/workflow.go index 623f2b48..995f27db 100644 --- a/pkg/services/hover/workflow.go +++ b/pkg/services/hover/workflow.go @@ -50,10 +50,11 @@ 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" + "- `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 3d8a5503..3e1fa5c6 100644 --- a/publicschema.json +++ b/publicschema.json @@ -1100,10 +1100,18 @@ "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" + }, + "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", @@ -1346,4 +1354,4 @@ ], "title": "JSON schema for CircleCI configuration files", "type": "object" -} \ No newline at end of file +}