Skip to content

Commit c095783

Browse files
authored
feat: add resource classes and images for Windows & GPU executors (#293)
1 parent a875486 commit c095783

File tree

17 files changed

+598
-397
lines changed

17 files changed

+598
-397
lines changed

.circleci/config.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ parameters:
2727
type: string
2828
default: ""
2929
orbs:
30-
go: circleci/go@1.9.0
30+
go: circleci/go@1.11.0
3131
node: circleci/[email protected]
3232
snyk: snyk/[email protected]
3333
slack: circleci/[email protected]
@@ -175,7 +175,7 @@ commands:
175175
jobs:
176176
Create version file:
177177
docker:
178-
- image: cimg/go:1.21.5
178+
- image: cimg/go:1.22.3
179179
description: |
180180
Create a version to be used by the /scripts/ldflags.sh when building the binaries
181181
parameters:
@@ -211,7 +211,7 @@ jobs:
211211
environment:
212212
SCHEMA_LOCATION: /home/circleci/project/schema.json
213213
docker:
214-
- image: cimg/go:1.21.5
214+
- image: cimg/go:1.22.3
215215
parallelism: 5
216216
steps:
217217
- checkout
@@ -232,7 +232,7 @@ jobs:
232232
arch:
233233
type: string
234234
docker:
235-
- image: cimg/go:1.21.5
235+
- image: cimg/go:1.22.3
236236
resource_class: << parameters.resource_class >>
237237
steps:
238238
- attach_workspace:
@@ -282,7 +282,7 @@ jobs:
282282

283283
Build Windows:
284284
docker:
285-
- image: cimg/go:1.21.5
285+
- image: cimg/go:1.22.3
286286
steps:
287287
- attach_workspace:
288288
at: ~/
@@ -352,7 +352,7 @@ jobs:
352352

353353
Lint:
354354
docker:
355-
- image: cimg/go:1.21.5
355+
- image: cimg/go:1.22.3
356356
steps:
357357
- checkout
358358
- run:
@@ -405,7 +405,7 @@ jobs:
405405
406406
Pre-Release:
407407
docker:
408-
- image: cimg/go:1.21.5
408+
- image: cimg/go:1.22.3
409409
steps:
410410
- checkout
411411
- attach_workspace:
@@ -492,7 +492,7 @@ jobs:
492492

493493
Security Scan release:
494494
docker:
495-
- image: cimg/go:1.21.5
495+
- image: cimg/go:1.22.3
496496
steps:
497497
- checkout
498498
- run:
@@ -507,7 +507,7 @@ jobs:
507507

508508
Security Scan feature:
509509
docker:
510-
- image: cimg/go:1.21.5
510+
- image: cimg/go:1.22.3
511511
steps:
512512
- checkout
513513
- run:

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ indent_size = 2
1212
indent_style = tab
1313

1414
[*.yml]
15-
indent_size = 4
15+
indent_size = 2

.vscode/launch.json

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818
"--extensionDevelopmentPath=${workspaceFolder}/editors/vscode",
1919
"--disable-extensions"
2020
],
21-
"outFiles": [
22-
"${workspaceFolder}/editors/vscode/dist/**/*.js"
23-
],
21+
"outFiles": ["${workspaceFolder}/editors/vscode/dist/**/*.js"],
2422
"preLaunchTask": "task: task build",
2523
"env": {
2624
"CCI_DEV": "true",
@@ -37,12 +35,8 @@
3735
},
3836
"type": "extensionHost",
3937
"request": "launch",
40-
"args": [
41-
"--extensionDevelopmentPath=${workspaceFolder}/editors/vscode"
42-
],
43-
"outFiles": [
44-
"${workspaceFolder}/editors/vscode/dist/**/*.js"
45-
],
38+
"args": ["--extensionDevelopmentPath=${workspaceFolder}/editors/vscode"],
39+
"outFiles": ["${workspaceFolder}/editors/vscode/dist/**/*.js"],
4640
"preLaunchTask": "task: task build",
4741
"env": {
4842
"CCI_DEV": "true"
@@ -75,9 +69,7 @@
7569
},
7670
"program": "${workspaceFolder}/node_modules/jest/bin/jest.js",
7771
"request": "launch",
78-
"skipFiles": [
79-
"<node_internals>/**"
80-
],
72+
"skipFiles": ["<node_internals>/**"],
8173
"type": "node"
8274
},
8375
{
@@ -92,9 +84,7 @@
9284
},
9385
"program": "${workspaceFolder}/node_modules/jest/bin/jest.js",
9486
"request": "launch",
95-
"skipFiles": [
96-
"<node_internals>/**"
97-
],
87+
"skipFiles": ["<node_internals>/**"],
9888
"type": "node"
9989
},
10090
{

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/CircleCI-Public/circleci-yaml-language-server
22

3-
go 1.21
3+
go 1.22
44

55
require (
66
github.com/Masterminds/semver v1.5.0

pkg/ast/executor.go

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -219,41 +219,4 @@ func (e MacOSExecutor) GetEnvs() Environment {
219219
return e.Environment
220220
}
221221

222-
type WindowsExecutor struct {
223-
BaseExecutor
224-
Image string
225-
}
226-
227-
func (e WindowsExecutor) GetRange() protocol.Range {
228-
return e.Range
229-
}
230-
231-
func (e WindowsExecutor) GetName() string {
232-
return e.Name
233-
}
234-
235-
func (e WindowsExecutor) GetNameRange() protocol.Range {
236-
return e.NameRange
237-
}
238-
239-
func (e WindowsExecutor) IsUncomplete() bool {
240-
return e.Uncomplete
241-
}
242-
243-
func (e WindowsExecutor) GetResourceClass() string {
244-
return e.ResourceClass
245-
}
246-
247-
func (e WindowsExecutor) GetParameters() map[string]Parameter {
248-
return e.UserParameters
249-
}
250-
251-
func (e WindowsExecutor) GetParametersRange() protocol.Range {
252-
return e.UserParametersRange
253-
}
254-
255-
func (e WindowsExecutor) GetEnvs() Environment {
256-
return e.Environment
257-
}
258-
259222
type EnvironmentParameter map[string]string

pkg/parser/executors.go

Lines changed: 12 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ func (doc *YamlDocument) parseSingleExecutor(executorNode *sitter.Node) {
5858
doc.Executors[executorName] = doc.parseSingleExecutorMachine(executorNameNode, blockMappingNode)
5959
case "macos":
6060
doc.Executors[executorName] = doc.parseSingleExecutorMacOS(executorNameNode, blockMappingNode)
61-
case "windows":
62-
doc.Executors[executorName] = doc.parseSingleExecutorWindows(executorNameNode, blockMappingNode)
6361
}
6462
})
6563

@@ -200,32 +198,6 @@ func (doc *YamlDocument) parseSingleExecutorMacOS(nameNode *sitter.Node, valueNo
200198
return res
201199
}
202200

203-
func (doc *YamlDocument) parseSingleExecutorWindows(nameNode *sitter.Node, valueNode *sitter.Node) ast.WindowsExecutor {
204-
// valueNode is a block_mapping
205-
res := ast.WindowsExecutor{}
206-
207-
parseWindows := func(blockNode *sitter.Node) {
208-
// blockNode is a block_node
209-
blockMappingNode := GetChildMapping(blockNode)
210-
211-
if blockMappingNode == nil { //TODO: deal with errors
212-
return
213-
}
214-
215-
doc.iterateOnBlockMapping(blockMappingNode, func(child *sitter.Node) {
216-
keyNode, valueNode := doc.GetKeyValueNodes(child)
217-
keyName := doc.GetNodeText(keyNode)
218-
switch keyName {
219-
case "image":
220-
res.Image = doc.GetNodeText(valueNode)
221-
}
222-
})
223-
}
224-
225-
doc.parseBaseExecutor(&res.BaseExecutor, nameNode, valueNode, parseWindows, "windows")
226-
return res
227-
}
228-
229201
func (doc *YamlDocument) parseSingleExecutorDocker(nameNode *sitter.Node, valueNode *sitter.Node) ast.DockerExecutor {
230202
// valueNode is a block_mapping
231203
res := ast.DockerExecutor{
@@ -236,7 +208,7 @@ func (doc *YamlDocument) parseSingleExecutorDocker(nameNode *sitter.Node, valueN
236208
// blockNode is a block_node
237209
blockSequence := GetChildSequence(blockNode)
238210

239-
if blockSequence == nil { //TODO: deal with errors
211+
if blockSequence == nil { // TODO: deal with errors
240212
return
241213
}
242214

@@ -257,14 +229,14 @@ func (doc *YamlDocument) parseDockerImage(imageNode *sitter.Node) ast.DockerImag
257229
dockerImg := ast.DockerImage{}
258230
blockNode := GetChildOfType(imageNode, "block_node")
259231

260-
if blockNode == nil { //TODO: deal with errors
232+
if blockNode == nil { // TODO: deal with errors
261233
// Can happen if the docker is an alias/anchor
262234
return dockerImg
263235
}
264236

265237
blockMappingNode := GetChildMapping(blockNode)
266238

267-
if blockMappingNode == nil { //TODO: deal with errors
239+
if blockMappingNode == nil { // TODO: deal with errors
268240
return dockerImg
269241
}
270242

@@ -331,7 +303,7 @@ func (doc *YamlDocument) parseExecutorRef(valueNode *sitter.Node, child *sitter.
331303

332304
name := ""
333305
blockMapping := GetChildMapping(valueNode)
334-
if blockMapping == nil { //TODO: deal with errors
306+
if blockMapping == nil { // TODO: deal with errors
335307
return "", protocol.Range{}, executorParameters
336308
}
337309

@@ -368,11 +340,11 @@ func (doc *YamlDocument) addedMachineTrueDeprecatedDiag(child *sitter.Node, reso
368340
return false
369341
}
370342

371-
if !doc.Context.Api.UseDefaultInstance() || doc.IsSelfHostedRunner(resourceClass) {
343+
if !doc.Context.Api.UseDefaultInstance() || utils.IsSelfHostedRunner(resourceClass) {
372344
return false
373345
}
374346

375-
if doc.IsSelfHostedRunner(resourceClass) {
347+
if utils.IsSelfHostedRunner(resourceClass) {
376348
return false
377349
}
378350
machineRange := doc.NodeToRange(child)
@@ -382,18 +354,19 @@ func (doc *YamlDocument) addedMachineTrueDeprecatedDiag(child *sitter.Node, reso
382354
}
383355

384356
func (doc *YamlDocument) machineTrueFix(machineRange protocol.Range) {
385-
img := utils.GetLatestUbuntu2204Image()
386357
diagnostic := utils.CreateDiagnosticFromRange(
387358
machineRange,
388359
protocol.DiagnosticSeverityWarning,
389-
utils.GetMachineTrueMessage(img),
360+
utils.GetMachineTrueMessage(utils.CurrentLinuxImage),
390361
[]protocol.CodeAction{
391-
utils.CreateCodeActionTextEdit("Replace with most updated ubuntu image", doc.URI,
362+
utils.CreateCodeActionTextEdit("Replace with current Ubuntu image", doc.URI,
392363
[]protocol.TextEdit{
393364
{
394365
Range: machineRange,
395-
NewText: `machine:
396-
` + strings.Repeat(" ", int(machineRange.Start.Character)) + ` image: ` + utils.GetLatestUbuntu2204Image(),
366+
NewText: "machine:\n" +
367+
strings.Repeat(" ", int(machineRange.Start.Character)) +
368+
" image: " +
369+
utils.CurrentLinuxImage,
397370
},
398371
}, false),
399372
},
@@ -402,9 +375,4 @@ func (doc *YamlDocument) machineTrueFix(machineRange protocol.Range) {
402375
protocol.DiagnosticTagDeprecated,
403376
}
404377
doc.addDiagnostic(diagnostic)
405-
406-
}
407-
408-
func (doc *YamlDocument) IsSelfHostedRunner(resourceClass string) bool {
409-
return len(strings.Split(resourceClass, "/")) > 1
410378
}

pkg/parser/validate/dockerImage_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ executors:
7272
Diagnostics: []ComparableDiagnostic{
7373
{
7474
Severity: protocol.DiagnosticSeverityError,
75-
Message: "Docker image not found namespace/image:tag",
75+
Message: "Docker image not found \"namespace/image:tag\"",
7676
},
7777
},
7878

@@ -93,7 +93,7 @@ executors:
9393
Diagnostics: []ComparableDiagnostic{
9494
{
9595
Severity: protocol.DiagnosticSeverityError,
96-
Message: "Docker image namespace/image:tag has no tag tag",
96+
Message: "Docker image \"namespace/image:tag\" has no tag \"tag\"",
9797
},
9898
},
9999

@@ -115,7 +115,7 @@ executors:
115115
Diagnostics: []ComparableDiagnostic{
116116
{
117117
Severity: protocol.DiagnosticSeverityError,
118-
Message: "Docker image namespace/image has no tag latest",
118+
Message: "Docker image \"namespace/image\" has no tag \"latest\"",
119119
},
120120
},
121121

@@ -134,7 +134,7 @@ executors:
134134
Diagnostics: []ComparableDiagnostic{
135135
{
136136
Severity: protocol.DiagnosticSeverityError,
137-
Message: "Docker image namespace/image has no tag latest",
137+
Message: "Docker image \"namespace/image\" has no tag \"latest\"",
138138
Actions: []ComparableAction{
139139
{
140140
Title: "Use last tag",
@@ -266,6 +266,7 @@ func TestChooseTagToRecommend(t *testing.T) {
266266
})
267267
}
268268
}
269+
269270
func TestCreateTagTextEdit(t *testing.T) {
270271
tag := "16.20.1-browsers"
271272
img := ast.DockerImage{

0 commit comments

Comments
 (0)