2022-11-21 17:55:24 -08:00
|
|
|
import {DiagnosticSeverity} from "vscode-languageserver-types";
|
|
|
|
|
import {createDocument} from "./test-utils/document";
|
|
|
|
|
import {validate} from "./validate";
|
|
|
|
|
|
|
|
|
|
describe("expression validation", () => {
|
|
|
|
|
it("access invalid context field", async () => {
|
|
|
|
|
const result = await validate(
|
|
|
|
|
createDocument(
|
|
|
|
|
"wf.yaml",
|
|
|
|
|
"on: push\nrun-name: name-${{ github.does-not-exist }}\njobs:\n build:\n runs-on: ubuntu-latest\n steps:\n - run: echo"
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
expect(result).toEqual([
|
|
|
|
|
{
|
2022-11-22 10:59:55 -08:00
|
|
|
message: "Context access might be invalid: does-not-exist",
|
2022-11-21 17:55:24 -08:00
|
|
|
range: {
|
|
|
|
|
end: {
|
|
|
|
|
character: 43,
|
|
|
|
|
line: 1
|
|
|
|
|
},
|
|
|
|
|
start: {
|
2022-11-22 10:59:55 -08:00
|
|
|
character: 15,
|
2022-11-21 17:55:24 -08:00
|
|
|
line: 1
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
severity: DiagnosticSeverity.Warning
|
|
|
|
|
}
|
|
|
|
|
]);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("access invalid nested context field", async () => {
|
|
|
|
|
const result = await validate(
|
|
|
|
|
createDocument(
|
|
|
|
|
"wf.yaml",
|
|
|
|
|
"on: push\nrun-name: name-${{ github.does-not-exist.again }}\njobs:\n build:\n runs-on: ubuntu-latest\n steps:\n - run: echo"
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
expect(result).toEqual([
|
|
|
|
|
{
|
2022-11-22 10:59:55 -08:00
|
|
|
message: "Context access might be invalid: does-not-exist",
|
2022-11-21 17:55:24 -08:00
|
|
|
range: {
|
|
|
|
|
end: {
|
|
|
|
|
character: 49,
|
|
|
|
|
line: 1
|
|
|
|
|
},
|
|
|
|
|
start: {
|
2022-11-22 10:59:55 -08:00
|
|
|
character: 15,
|
2022-11-21 17:55:24 -08:00
|
|
|
line: 1
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
severity: DiagnosticSeverity.Warning
|
|
|
|
|
}
|
|
|
|
|
]);
|
|
|
|
|
});
|
2022-11-30 11:21:32 -05:00
|
|
|
|
|
|
|
|
it.failing("needs.<job_id>", async () => {
|
|
|
|
|
const input = `
|
|
|
|
|
on: push
|
|
|
|
|
jobs:
|
|
|
|
|
a:
|
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
steps:
|
|
|
|
|
- run: echo hello a
|
|
|
|
|
b:
|
|
|
|
|
needs: [a]
|
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
steps:
|
|
|
|
|
- run: echo "hello \${{ needs.a }}"
|
|
|
|
|
`;
|
|
|
|
|
const result = await validate(createDocument("wf.yaml", input));
|
|
|
|
|
|
|
|
|
|
expect(result).toEqual([]);
|
|
|
|
|
});
|
2022-11-21 17:55:24 -08:00
|
|
|
});
|