Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ orbs:
slack: circleci/[email protected]
github-cli: circleci/[email protected]

executors:
go-executor:
docker:
- image: cimg/go:1.23.4

commands:
install-zig:
steps:
Expand Down Expand Up @@ -174,8 +179,7 @@ commands:

jobs:
Create version file:
docker:
- image: cimg/go:1.22.3
executor: go-executor
description: |
Create a version to be used by the /scripts/ldflags.sh when building the binaries
parameters:
Expand Down Expand Up @@ -210,8 +214,7 @@ jobs:
Unit Tests:
environment:
SCHEMA_LOCATION: /home/circleci/project/schema.json
docker:
- image: cimg/go:1.22.3
executor: go-executor
parallelism: 5
steps:
- checkout
Expand All @@ -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:
Expand Down Expand Up @@ -260,7 +262,7 @@ jobs:
at: ~/
- checkout
- go/install:
version: 1.22.3
version: 1.23.4
- run:
name: Build
command: |
Expand All @@ -277,8 +279,7 @@ jobs:
- project/bin

Build Windows:
docker:
- image: cimg/go:1.22.3
executor: go-executor
steps:
- attach_workspace:
at: ~/
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -487,8 +486,7 @@ jobs:
destination: .

Security Scan release:
docker:
- image: cimg/go:1.22.3
executor: go-executor
steps:
- checkout
- run:
Expand Down
2 changes: 1 addition & 1 deletion HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ resources:

## Requirements

- Go 1.19+
- Go 1.23+
- [Task](https://taskfile.dev/)
- [detect-secrets](https://github.com/Yelp/detect-secrets)

Expand Down
9 changes: 4 additions & 5 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 7 additions & 3 deletions pkg/parser/validate/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
}

Expand Down
33 changes: 32 additions & 1 deletion pkg/parser/validate/workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
},
},
{
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions pkg/services/hover/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down