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