From 681236bbca342faf9ce86b5c4105be7a040e90ae Mon Sep 17 00:00:00 2001 From: Christopher Schleiden Date: Mon, 12 Dec 2022 10:43:39 -0800 Subject: [PATCH 1/3] Correctly report errors in multi-line expression strings --- .../src/validate.expressions.test.ts | 120 +++++++++++++++++- actions-languageservice/src/validate.ts | 2 - 2 files changed, 119 insertions(+), 3 deletions(-) diff --git a/actions-languageservice/src/validate.expressions.test.ts b/actions-languageservice/src/validate.expressions.test.ts index b914ec9..9157a0b 100644 --- a/actions-languageservice/src/validate.expressions.test.ts +++ b/actions-languageservice/src/validate.expressions.test.ts @@ -306,7 +306,7 @@ jobs: }); }); - describe("multi-line strings", () => { + describe("multi-line strings warnings", () => { it("indented |", async () => { const input = `on: push jobs: @@ -428,6 +428,124 @@ jobs: }); }); + describe("multi-line strings errors", () => { + it("indented |", async () => { + const input = `on: push +jobs: + build: + runs-on: ubuntu-latest + steps: + - run: | + first line + test \${{ fromJSON2('') }} + test2`; + const result = await validate(createDocument("wf.yaml", input)); + + expect(result).toEqual([ + { + message: "Unrecognized function: 'fromJSON2'", + range: { + end: { + character: 35, + line: 7 + }, + start: { + character: 15, + line: 7 + } + } + } + ]); + }); + + it("indented |+", async () => { + const input = `on: push +jobs: + build: + runs-on: ubuntu-latest + steps: + - run: |+ + first line + test \${{ fromJSON2('') }} + test2`; + const result = await validate(createDocument("wf.yaml", input)); + + expect(result).toEqual([ + { + message: "Unrecognized function: 'fromJSON2'", + range: { + end: { + character: 35, + line: 7 + }, + start: { + character: 15, + line: 7 + } + } + } + ]); + }); + + it("indented >", async () => { + const input = `on: push +jobs: + build: + runs-on: ubuntu-latest + steps: + - run: > + first line + test \${{ fromJSON2('') }} + test2`; + const result = await validate(createDocument("wf.yaml", input)); + + expect(result).toEqual([ + { + message: "Unrecognized function: 'fromJSON2'", + range: { + end: { + character: 35, + line: 7 + }, + start: { + character: 15, + line: 7 + } + } + } + ]); + }); + + it("indented >+", async () => { + const input = `on: push +jobs: + build: + runs-on: ubuntu-latest + steps: + - run: >+ + first line + test \${{ fromJSON2('') }} + test2`; + const result = await validate(createDocument("wf.yaml", input)); + + expect(result).toEqual([ + { + message: "Unrecognized function: 'fromJSON2'", + range: { + end: { + character: 35, + line: 7 + }, + start: { + character: 15, + line: 7 + } + } + } + ]); + }); + }); + describe("matrix context", () => { it("reference within a matrix job", async () => { const input = ` diff --git a/actions-languageservice/src/validate.ts b/actions-languageservice/src/validate.ts index 8d2938e..d913a26 100644 --- a/actions-languageservice/src/validate.ts +++ b/actions-languageservice/src/validate.ts @@ -209,8 +209,6 @@ async function validateExpression( severity: DiagnosticSeverity.Warning, range: mapRange(expression.range) }); - } else { - throw e; } } } From f059497eb18c8e3eafd0e65b67ed408e4577c285 Mon Sep 17 00:00:00 2001 From: Christopher Schleiden Date: Mon, 12 Dec 2022 12:55:04 -0800 Subject: [PATCH 2/3] Consume parser --- package-lock.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5106819..ccc4223 100644 --- a/package-lock.json +++ b/package-lock.json @@ -698,9 +698,9 @@ "link": true }, "node_modules/@github/actions-workflow-parser": { - "version": "0.0.31", - "resolved": "https://npm.pkg.github.com/download/@github/actions-workflow-parser/0.0.31/ebc46956b91ed1a8c45efd41a3256ae818722557", - "integrity": "sha512-3k+MBWG7Gn86aHeLdJTiYUTGm53npEelzleCbq/8Ir51xVkRINsyNe4HuGJizXxZ2WoTxAkLeZ6qpO1oCucSIg==", + "version": "0.0.33", + "resolved": "https://npm.pkg.github.com/download/@github/actions-workflow-parser/0.0.33/9f4c42ae90a9b010676fec9d9f39b4ea555753b4", + "integrity": "sha512-5yzSAMKCdxy4awZMRNHOIo52E/xx3RtSjHX5I70/Gx9NlnoCQBSLEdd64dY3/fguLLQxksnhiUy/mmUWTqJyLg==", "license": "MIT", "dependencies": { "@github/actions-expressions": "*", @@ -13533,9 +13533,9 @@ } }, "@github/actions-workflow-parser": { - "version": "0.0.31", - "resolved": "https://npm.pkg.github.com/download/@github/actions-workflow-parser/0.0.31/ebc46956b91ed1a8c45efd41a3256ae818722557", - "integrity": "sha512-3k+MBWG7Gn86aHeLdJTiYUTGm53npEelzleCbq/8Ir51xVkRINsyNe4HuGJizXxZ2WoTxAkLeZ6qpO1oCucSIg==", + "version": "0.0.33", + "resolved": "https://npm.pkg.github.com/download/@github/actions-workflow-parser/0.0.33/9f4c42ae90a9b010676fec9d9f39b4ea555753b4", + "integrity": "sha512-5yzSAMKCdxy4awZMRNHOIo52E/xx3RtSjHX5I70/Gx9NlnoCQBSLEdd64dY3/fguLLQxksnhiUy/mmUWTqJyLg==", "requires": { "@github/actions-expressions": "*", "yaml": "^2.0.0-8" From 7f7c632939c50a5916437e8c0f36ae9a3fd9202a Mon Sep 17 00:00:00 2001 From: Christopher Schleiden Date: Mon, 12 Dec 2022 14:45:02 -0800 Subject: [PATCH 3/3] Update parser --- package-lock.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index ccc4223..bccbc21 100644 --- a/package-lock.json +++ b/package-lock.json @@ -698,9 +698,9 @@ "link": true }, "node_modules/@github/actions-workflow-parser": { - "version": "0.0.33", - "resolved": "https://npm.pkg.github.com/download/@github/actions-workflow-parser/0.0.33/9f4c42ae90a9b010676fec9d9f39b4ea555753b4", - "integrity": "sha512-5yzSAMKCdxy4awZMRNHOIo52E/xx3RtSjHX5I70/Gx9NlnoCQBSLEdd64dY3/fguLLQxksnhiUy/mmUWTqJyLg==", + "version": "0.0.34", + "resolved": "https://npm.pkg.github.com/download/@github/actions-workflow-parser/0.0.34/e369bdaca17cde594ad7420cd0df0efcd2804dc0", + "integrity": "sha512-ttjYUoO2bvi5v/SR267QpDhWJ+I4tXQlSMnscjqUp76IDLxS73I7nCD3KP7g4VxzHmT5j8AxSdjEE25UWpl43g==", "license": "MIT", "dependencies": { "@github/actions-expressions": "*", @@ -13533,9 +13533,9 @@ } }, "@github/actions-workflow-parser": { - "version": "0.0.33", - "resolved": "https://npm.pkg.github.com/download/@github/actions-workflow-parser/0.0.33/9f4c42ae90a9b010676fec9d9f39b4ea555753b4", - "integrity": "sha512-5yzSAMKCdxy4awZMRNHOIo52E/xx3RtSjHX5I70/Gx9NlnoCQBSLEdd64dY3/fguLLQxksnhiUy/mmUWTqJyLg==", + "version": "0.0.34", + "resolved": "https://npm.pkg.github.com/download/@github/actions-workflow-parser/0.0.34/e369bdaca17cde594ad7420cd0df0efcd2804dc0", + "integrity": "sha512-ttjYUoO2bvi5v/SR267QpDhWJ+I4tXQlSMnscjqUp76IDLxS73I7nCD3KP7g4VxzHmT5j8AxSdjEE25UWpl43g==", "requires": { "@github/actions-expressions": "*", "yaml": "^2.0.0-8"