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:
@@ -306,7 +306,7 @@ jobs:
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("multi-line strings", () => {
|
describe("multi-line strings warnings", () => {
|
||||||
it("indented |", async () => {
|
it("indented |", async () => {
|
||||||
const input = `on: push
|
const input = `on: push
|
||||||
jobs:
|
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", () => {
|
describe("matrix context", () => {
|
||||||
it("reference within a matrix job", async () => {
|
it("reference within a matrix job", async () => {
|
||||||
const input = `
|
const input = `
|
||||||
|
|||||||
@@ -209,8 +209,6 @@ async function validateExpression(
|
|||||||
severity: DiagnosticSeverity.Warning,
|
severity: DiagnosticSeverity.Warning,
|
||||||
range: mapRange(expression.range)
|
range: mapRange(expression.range)
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+6
-6
@@ -698,9 +698,9 @@
|
|||||||
"link": true
|
"link": true
|
||||||
},
|
},
|
||||||
"node_modules/@github/actions-workflow-parser": {
|
"node_modules/@github/actions-workflow-parser": {
|
||||||
"version": "0.0.31",
|
"version": "0.0.34",
|
||||||
"resolved": "https://npm.pkg.github.com/download/@github/actions-workflow-parser/0.0.31/ebc46956b91ed1a8c45efd41a3256ae818722557",
|
"resolved": "https://npm.pkg.github.com/download/@github/actions-workflow-parser/0.0.34/e369bdaca17cde594ad7420cd0df0efcd2804dc0",
|
||||||
"integrity": "sha512-3k+MBWG7Gn86aHeLdJTiYUTGm53npEelzleCbq/8Ir51xVkRINsyNe4HuGJizXxZ2WoTxAkLeZ6qpO1oCucSIg==",
|
"integrity": "sha512-ttjYUoO2bvi5v/SR267QpDhWJ+I4tXQlSMnscjqUp76IDLxS73I7nCD3KP7g4VxzHmT5j8AxSdjEE25UWpl43g==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@github/actions-expressions": "*",
|
"@github/actions-expressions": "*",
|
||||||
@@ -13533,9 +13533,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@github/actions-workflow-parser": {
|
"@github/actions-workflow-parser": {
|
||||||
"version": "0.0.31",
|
"version": "0.0.34",
|
||||||
"resolved": "https://npm.pkg.github.com/download/@github/actions-workflow-parser/0.0.31/ebc46956b91ed1a8c45efd41a3256ae818722557",
|
"resolved": "https://npm.pkg.github.com/download/@github/actions-workflow-parser/0.0.34/e369bdaca17cde594ad7420cd0df0efcd2804dc0",
|
||||||
"integrity": "sha512-3k+MBWG7Gn86aHeLdJTiYUTGm53npEelzleCbq/8Ir51xVkRINsyNe4HuGJizXxZ2WoTxAkLeZ6qpO1oCucSIg==",
|
"integrity": "sha512-ttjYUoO2bvi5v/SR267QpDhWJ+I4tXQlSMnscjqUp76IDLxS73I7nCD3KP7g4VxzHmT5j8AxSdjEE25UWpl43g==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@github/actions-expressions": "*",
|
"@github/actions-expressions": "*",
|
||||||
"yaml": "^2.0.0-8"
|
"yaml": "^2.0.0-8"
|
||||||
|
|||||||
Reference in New Issue
Block a user