Merge pull request #35 from github/joshmgross/validate-inputs-defined
Ensure `inputs` is defined
This commit is contained in:
@@ -241,11 +241,33 @@ jobs:
|
|||||||
expect(result.map(x => x.label)).toEqual(["another-name", "name"]);
|
expect(result.map(x => x.label)).toEqual(["another-name", "name"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("no inputs", async () => {
|
||||||
|
const input = `
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
jobs:
|
||||||
|
a:
|
||||||
|
outputs:
|
||||||
|
build_id: my-build-id
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- run: echo hello a
|
||||||
|
b:
|
||||||
|
needs: [a]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- run: echo "hello \${{ inputs.|
|
||||||
|
`;
|
||||||
|
const result = await complete(...getPositionFromCursor(input), undefined, contextProviderConfig);
|
||||||
|
|
||||||
|
expect(result).toEqual([]);
|
||||||
|
});
|
||||||
|
|
||||||
describe("steps context", () => {
|
describe("steps context", () => {
|
||||||
it("includes defined step IDs", async () => {
|
it("includes defined step IDs", async () => {
|
||||||
const input = `
|
const input = `
|
||||||
on: push
|
on: push
|
||||||
jobs:
|
jobs:
|
||||||
one:
|
one:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
@@ -255,7 +277,7 @@ jobs:
|
|||||||
run: echo hello b
|
run: echo hello b
|
||||||
- id: c
|
- id: c
|
||||||
run: echo "hello \${{ steps.|
|
run: echo "hello \${{ steps.|
|
||||||
`;
|
`;
|
||||||
const result = await complete(...getPositionFromCursor(input), undefined, contextProviderConfig);
|
const result = await complete(...getPositionFromCursor(input), undefined, contextProviderConfig);
|
||||||
|
|
||||||
expect(result.map(x => x.label)).toEqual(["a", "b"]);
|
expect(result.map(x => x.label)).toEqual(["a", "b"]);
|
||||||
@@ -263,8 +285,8 @@ jobs:
|
|||||||
|
|
||||||
it("step.<step_id>", async () => {
|
it("step.<step_id>", async () => {
|
||||||
const input = `
|
const input = `
|
||||||
on: push
|
on: push
|
||||||
jobs:
|
jobs:
|
||||||
one:
|
one:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
@@ -279,8 +301,8 @@ jobs:
|
|||||||
|
|
||||||
it("ignores IDs from later steps", async () => {
|
it("ignores IDs from later steps", async () => {
|
||||||
const input = `
|
const input = `
|
||||||
on: push
|
on: push
|
||||||
jobs:
|
jobs:
|
||||||
one:
|
one:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ export function getInputsContext(workflowContext: WorkflowContext): data.Diction
|
|||||||
}
|
}
|
||||||
|
|
||||||
const inputs = event.inputs;
|
const inputs = event.inputs;
|
||||||
|
if (!inputs) {
|
||||||
|
return d;
|
||||||
|
}
|
||||||
for (const inputName of Object.keys(inputs)) {
|
for (const inputName of Object.keys(inputs)) {
|
||||||
const input = inputs[inputName];
|
const input = inputs[inputName];
|
||||||
switch (input.type) {
|
switch (input.type) {
|
||||||
|
|||||||
Reference in New Issue
Block a user