From 7cc08955ec2f1d70d720e7d7c6f15d7b4e1b5832 Mon Sep 17 00:00:00 2001 From: mitchell amihod <4623+meeech@users.noreply.github.com> Date: Mon, 28 Apr 2025 18:22:00 -0400 Subject: [PATCH 1/6] feat: expand list of allowed job types --- pkg/parser/validate/workflow.go | 10 ++++++--- pkg/parser/validate/workflow_test.go | 33 +++++++++++++++++++++++++++- pkg/services/hover/workflow.go | 5 +++-- 3 files changed, 42 insertions(+), 6 deletions(-) diff --git a/pkg/parser/validate/workflow.go b/pkg/parser/validate/workflow.go index 30e2291e..deb20542 100644 --- a/pkg/parser/validate/workflow.go +++ b/pkg/parser/validate/workflow.go @@ -2,6 +2,7 @@ package validate import ( "fmt" + "slices" "github.com/CircleCI-Public/circleci-yaml-language-server/pkg/ast" "github.com/CircleCI-Public/circleci-yaml-language-server/pkg/utils" @@ -20,14 +21,17 @@ func (val Validate) validateSingleWorkflow(workflow ast.Workflow) error { continue } - isApprovalJob := jobRef.Type == "approval" - if isApprovalJob { + // Define valid job types + validJobTypes := []string{"approval", "build", "no-op", "release"} + + // Check if job type is valid + if slices.Contains(validJobTypes, 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..00cdc4ae 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 approval, build, no-op, release . 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 { From d2e97592f44b5cfa8bbc9f53a786fe704d705917 Mon Sep 17 00:00:00 2001 From: mitchell amihod <4623+meeech@users.noreply.github.com> Date: Mon, 28 Apr 2025 18:34:12 -0400 Subject: [PATCH 2/6] update go version --- HACKING.md | 2 +- go.mod | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/HACKING.md b/HACKING.md index 81b5800b..4eba7ca0 100644 --- a/HACKING.md +++ b/HACKING.md @@ -13,7 +13,7 @@ resources: ## Requirements -- Go 1.19+ +- Go 1.23+ - [Task](https://taskfile.dev/) - [detect-secrets](https://github.com/Yelp/detect-secrets) diff --git a/go.mod b/go.mod index e601e8ed..ee6bdff9 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/CircleCI-Public/circleci-yaml-language-server -go 1.22 +go 1.23 require ( github.com/Masterminds/semver v1.5.0 From 5937d9f3ac225e231396a65e87ec6670810b7cbb Mon Sep 17 00:00:00 2001 From: mitchell amihod <4623+meeech@users.noreply.github.com> Date: Mon, 28 Apr 2025 18:49:44 -0400 Subject: [PATCH 3/6] update task init for modern go, remove husky since i dont see how its being used --- Taskfile.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Taskfile.yml b/Taskfile.yml index 8e61b836..c21599a1 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -59,16 +59,15 @@ tasks: cmds: - ./bin/start_server env: - PORT: '{{.PORT | default 10001}}' + PORT: "{{.PORT | default 10001}}" SCHEMA_LOCATION: ./publicschema.json init: - - go install github.com/automation-co/husky@latest - - go get -d ./... - - husky install + - go install github.com/automation-co/husky@latest + - go mod download licenses: - - go-licenses csv ./cmd/start_server >licenses.csv 2>licenses.errors + - go-licenses csv ./cmd/start_server >licenses.csv 2>licenses.errors lint: cmds: From dedc3396f9973de8b1c6b2515c6fb61f64976be3 Mon Sep 17 00:00:00 2001 From: mitchell amihod <4623+meeech@users.noreply.github.com> Date: Mon, 28 Apr 2025 19:03:00 -0400 Subject: [PATCH 4/6] update for newer go --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b301f01f..e144cedc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -175,7 +175,7 @@ commands: jobs: Create version file: docker: - - image: cimg/go:1.22.3 + - image: cimg/go:1.23.4 description: | Create a version to be used by the /scripts/ldflags.sh when building the binaries parameters: @@ -211,7 +211,7 @@ jobs: environment: SCHEMA_LOCATION: /home/circleci/project/schema.json docker: - - image: cimg/go:1.22.3 + - image: cimg/go:1.23.4 parallelism: 5 steps: - checkout From ecde9c73a93e086c66f7360a8412fe7e9c615b90 Mon Sep 17 00:00:00 2001 From: mitchell amihod <4623+meeech@users.noreply.github.com> Date: Mon, 28 Apr 2025 23:17:11 -0400 Subject: [PATCH 5/6] ci(executor): standardize Go executor to use cimg/go:1.23.4 --- .circleci/config.yml | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e144cedc..4706cb43 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -33,6 +33,11 @@ orbs: slack: circleci/slack@4.12.1 github-cli: circleci/github-cli@2.2.0 +executors: + go-executor: + docker: + - image: cimg/go:1.23.4 + commands: install-zig: steps: @@ -174,8 +179,7 @@ commands: jobs: Create version file: - docker: - - image: cimg/go:1.23.4 + executor: go-executor description: | Create a version to be used by the /scripts/ldflags.sh when building the binaries parameters: @@ -210,8 +214,7 @@ jobs: Unit Tests: environment: SCHEMA_LOCATION: /home/circleci/project/schema.json - docker: - - image: cimg/go:1.23.4 + executor: go-executor parallelism: 5 steps: - checkout @@ -231,8 +234,7 @@ jobs: type: string arch: type: string - docker: - - image: cimg/go:1.22.3 + executor: go-executor resource_class: << parameters.resource_class >> steps: - attach_workspace: @@ -277,8 +279,7 @@ jobs: - project/bin Build Windows: - docker: - - image: cimg/go:1.22.3 + executor: go-executor steps: - attach_workspace: at: ~/ @@ -347,8 +348,7 @@ jobs: path: /tmp/circleci-lsp-vsix.zip Lint: - docker: - - image: cimg/go:1.22.3 + executor: go-executor steps: - checkout - run: @@ -400,8 +400,7 @@ jobs: --manifest-file .circleci/release/release-please-manifest.json Pre-Release: - docker: - - image: cimg/go:1.22.3 + executor: go-executor steps: - checkout - attach_workspace: @@ -487,8 +486,7 @@ jobs: destination: . Security Scan release: - docker: - - image: cimg/go:1.22.3 + executor: go-executor steps: - checkout - run: From f3b3c855a058386c8bc32f8840c6616d091e6257 Mon Sep 17 00:00:00 2001 From: mitchell amihod <4623+meeech@users.noreply.github.com> Date: Mon, 28 Apr 2025 23:22:31 -0400 Subject: [PATCH 6/6] ci(macos): update macOS Go version to 1.23.4 for consistency --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4706cb43..1d397fd1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -262,7 +262,7 @@ jobs: at: ~/ - checkout - go/install: - version: 1.22.3 + version: 1.23.4 - run: name: Build command: |