diff --git a/actions-languageservice/src/complete.expressions.test.ts b/actions-languageservice/src/complete.expressions.test.ts index 87692dd..78e1166 100644 --- a/actions-languageservice/src/complete.expressions.test.ts +++ b/actions-languageservice/src/complete.expressions.test.ts @@ -749,6 +749,57 @@ jobs: expect(result.map(x => x.label)).toEqual(["container", "services", "status"]); }); + it("job context is suggested within a job output", async () => { + const input = ` +on: push +jobs: + test: + runs-on: ubuntu-latest + outputs: + environment: \${{ | }} + steps: + - id: a + run: echo hi +`; + + const result = await complete(...getPositionFromCursor(input), undefined, contextProviderConfig); + expect(result.map(x => x.label)).toEqual([ + "env", + "github", + "inputs", + "job", + "needs", + "runner", + "secrets", + "steps", + "vars", + "contains", + "endsWith", + "format", + "fromJson", + "join", + "startsWith", + "toJson", + ]); + }); + + it("step context is suggested within a job output", async () => { + const input = ` +on: push +jobs: + test: + runs-on: ubuntu-latest + outputs: + environment: \${{ steps.| }} + steps: + - id: foo + run: echo hi +`; + + const result = await complete(...getPositionFromCursor(input), undefined, contextProviderConfig); + expect(result.map(x => x.label)).toEqual(["foo"]); + }); + it("container context is suggested within a job container", async () => { const input = ` on: push diff --git a/actions-languageservice/src/validate.expressions.test.ts b/actions-languageservice/src/validate.expressions.test.ts index f9777f7..5882796 100644 --- a/actions-languageservice/src/validate.expressions.test.ts +++ b/actions-languageservice/src/validate.expressions.test.ts @@ -190,6 +190,39 @@ jobs: ]); }); + it("reference of invalid step in job outputs", async () => { + const input = ` + on: push + jobs: + a: + outputs: + environment: \${{ steps.foo }} + runs-on: ubuntu-latest + steps: + - id: a + run: echo hello a + `; + + const result = await validate(createDocument("wf.yaml", input)); + + expect(result).toEqual([ + { + "message": "Context access might be invalid: foo", + "range": { + "end": { + "character": 41, + "line": 5, + }, + "start": { + "character": 25, + "line": 5, + }, + }, + "severity": 2, + }, + ]); + }); + it("invalid reference of generated step name", async () => { const input = ` on: push