Conversation
Add workflow_ref, workflow_sha, workflow_repository, and workflow_file_path to the job context for reusable workflow jobs. These fields provide direct access to the workflow file information without needing to parse github.workflow_ref. - Add 4 new fields to getJobContext() in job.ts - Add descriptions in descriptions.json - Update autocomplete test expectations - Add validation and unit tests
There was a problem hiding this comment.
Pull request overview
Adds language-service support for four new job context properties (workflow_ref, workflow_sha, workflow_repository, workflow_file_path) so validation and autocomplete recognize reusable-workflow runtime-populated workflow metadata.
Changes:
- Extend
jobcontext provider to include fourworkflow_*string fields with descriptions. - Add/extend unit tests to assert field presence, expression validation, and completion suggestions.
- Add human-readable descriptions for the new context keys.
Show a summary per file
| File | Description |
|---|---|
| languageservice/src/context-providers/job.ts | Adds job.workflow_* fields to the job context dictionary. |
| languageservice/src/context-providers/descriptions.json | Adds descriptions for the new job.workflow_* fields. |
| languageservice/src/context-providers/job.test.ts | Verifies the new fields and their descriptions are present in the job context. |
| languageservice/src/validate.expressions.test.ts | Validates expressions referencing the new job.workflow_* fields produce no diagnostics. |
| languageservice/src/complete.expressions.test.ts | Updates completion expectations to include the new job.workflow_* keys. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 5/5 changed files
- Comments generated: 4
| // Workflow context fields (populated at runtime for reusable workflow jobs) | ||
| jobContext.add("workflow_file_path", new data.StringData(""), getDescription("job", "workflow_file_path")); | ||
| jobContext.add("workflow_ref", new data.StringData(""), getDescription("job", "workflow_ref")); | ||
| jobContext.add("workflow_repository", new data.StringData(""), getDescription("job", "workflow_repository")); | ||
| jobContext.add("workflow_sha", new data.StringData(""), getDescription("job", "workflow_sha")); |
There was a problem hiding this comment.
The function-level doc comment above getJobContext says it returns only container/services/status/check_run_id, but this change adds workflow_* fields too. Please update the doc comment so it accurately reflects the returned context keys.
| it("returns status and check_run_id when job has no container or services", () => { | ||
| const workflowContext = {job: {}} as WorkflowContext; | ||
| const context = getJobContext(workflowContext); | ||
|
|
||
| expect(context.get("status")).toBeDefined(); | ||
| expect(context.get("check_run_id")).toBeDefined(); | ||
| expect(context.get("workflow_ref")).toBeDefined(); | ||
| expect(context.get("workflow_sha")).toBeDefined(); | ||
| expect(context.get("workflow_repository")).toBeDefined(); | ||
| expect(context.get("workflow_file_path")).toBeDefined(); |
There was a problem hiding this comment.
The test name says it "returns status and check_run_id" but the expectations now also include the workflow_* fields. Rename the test (or split it) so the description matches what is being asserted.
| it("job.workflow_ref", async () => { | ||
| const input = ` | ||
| on: push | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - run: echo \${{ job.workflow_ref }} | ||
| - run: echo \${{ job.workflow_sha }} | ||
| - run: echo \${{ job.workflow_repository }} | ||
| - run: echo \${{ job.workflow_file_path }} |
There was a problem hiding this comment.
This test title mentions only job.workflow_ref, but the body validates four fields (workflow_ref, workflow_sha, workflow_repository, workflow_file_path). Consider renaming the test to cover all four (e.g., job.workflow_*) to keep test output clear when failures occur.
| "description": "The path of the workflow file that contains the job. For example, `.github/workflows/my-workflow.yml`." | ||
| }, | ||
| "workflow_ref": { | ||
| "description": "The ref of the workflow file that contains the job. For example, `octocat/hello-world/.github/workflows/my-workflow.yml@refs/heads/my_branch`." |
There was a problem hiding this comment.
The wording "The ref of the workflow file" is ambiguous given the example includes the full ref path (owner/repo/.github/workflows/...@refs/...). For consistency with github.workflow_ref earlier in this file, consider changing this to "The ref path to the workflow file" (or similar) so it’s clear this is not just refs/heads/....
| "description": "The ref of the workflow file that contains the job. For example, `octocat/hello-world/.github/workflows/my-workflow.yml@refs/heads/my_branch`." | |
| "description": "The ref path to the workflow file that contains the job. For example, `octocat/hello-world/.github/workflows/my-workflow.yml@refs/heads/my_branch`." |
Summary
Adds four new properties to the
jobcontext for language service support:job.workflow_ref— The ref path to the workflow file (e.g.,octocat/hello-world/.github/workflows/my-workflow.yml@refs/heads/my_branch)job.workflow_sha— The commit SHA of the workflow filejob.workflow_repository— The owner and repository name of the workflow file (e.g.,octocat/Hello-World)job.workflow_file_path— The path of the workflow file (e.g.,.github/workflows/my-workflow.yml)These fields are populated at runtime for reusable workflow jobs and provide direct access to workflow file information without needing to parse
github.workflow_ref.Changes
job.tsdata.StringDatafields with descriptionsdescriptions.jsonjob.test.tsvalidate.expressions.test.tscomplete.expressions.test.tsRelated PRs
job.workflow_*typed accessors to JobContext runner#4335Testing