Fix caching for invalid YAML files
This commit is contained in:
@@ -20,14 +20,12 @@ export function clearCache() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function fetchOrParseWorkflow(file: File, uri: string): ParseWorkflowResult | undefined {
|
export function fetchOrParseWorkflow(file: File, uri: string): ParseWorkflowResult | undefined {
|
||||||
let result = parsedWorkflowCache.get(uri);
|
const cachedResult = parsedWorkflowCache.get(uri);
|
||||||
if (!result?.value) {
|
if (cachedResult) {
|
||||||
result = parseWorkflow(file, nullTrace);
|
return cachedResult;
|
||||||
if (!result.value) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
parsedWorkflowCache.set(uri, result);
|
|
||||||
}
|
}
|
||||||
|
const result = parseWorkflow(file, nullTrace);
|
||||||
|
parsedWorkflowCache.set(uri, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -195,6 +195,41 @@ jobs:
|
|||||||
} as Diagnostic);
|
} as Diagnostic);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("invalid YAML", async () => {
|
||||||
|
// This YAML has some mismatched single-quotes, which causes the string to be terminated early
|
||||||
|
// within the fromJSON() expression.
|
||||||
|
// Using double-quotes would make it valid:
|
||||||
|
// "Run a \${{ inputs.test }} one-line script \${{ fromJSON('test') == inputs.name }}"
|
||||||
|
const workflow = `
|
||||||
|
on: push
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
environment: TEST
|
||||||
|
steps:
|
||||||
|
- name: 'Run a \${{ inputs.test }} one-line script \${{ fromJSON('test') == inputs.name }}'
|
||||||
|
run: echo
|
||||||
|
`;
|
||||||
|
const result = await validate(createDocument("wf.yaml", workflow), {valueProviderConfig: defaultValueProviders});
|
||||||
|
|
||||||
|
expect(result).toEqual([
|
||||||
|
{
|
||||||
|
message:
|
||||||
|
"Unexpected scalar at node end at line 8, column 73:\n\n…un a ${{ inputs.test }} one-line script ${{ fromJSON('test') == inputs.name }}'\n ^^^^^^^^^^^^^^^^^^^^^^^^^\n",
|
||||||
|
range: {
|
||||||
|
start: {
|
||||||
|
line: 7,
|
||||||
|
character: 72
|
||||||
|
},
|
||||||
|
end: {
|
||||||
|
line: 7,
|
||||||
|
character: 97
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
describe("value provider case sensitivity", () => {
|
describe("value provider case sensitivity", () => {
|
||||||
it("value with a different case and case sensitive provider", async () => {
|
it("value with a different case and case sensitive provider", async () => {
|
||||||
const workflow = `
|
const workflow = `
|
||||||
|
|||||||
Reference in New Issue
Block a user