Merge pull request #50 from github/cschleiden/expression-errors-multi-line-strings

Correctly report errors in multi-line expression strings
This commit is contained in:
Christopher Schleiden
2022-12-12 15:01:24 -08:00
committed by GitHub
3 changed files with 125 additions and 9 deletions
@@ -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 = `
-2
View File
@@ -209,8 +209,6 @@ async function validateExpression(
severity: DiagnosticSeverity.Warning,
range: mapRange(expression.range)
});
} else {
throw e;
}
}
}
+6 -6
View File
@@ -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.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.31",
"resolved": "https://npm.pkg.github.com/download/@github/actions-workflow-parser/0.0.31/ebc46956b91ed1a8c45efd41a3256ae818722557",
"integrity": "sha512-3k+MBWG7Gn86aHeLdJTiYUTGm53npEelzleCbq/8Ir51xVkRINsyNe4HuGJizXxZ2WoTxAkLeZ6qpO1oCucSIg==",
"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"