Skip to content

feat: add job.workflow_* context properties#348

Open
salmanmkc wants to merge 1 commit intomainfrom
salmanmkc/job-workflow-context-properties
Open

feat: add job.workflow_* context properties#348
salmanmkc wants to merge 1 commit intomainfrom
salmanmkc/job-workflow-context-properties

Conversation

@salmanmkc
Copy link
Copy Markdown
Contributor

Summary

Adds four new properties to the job context 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 file
  • job.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

File Change
job.ts Add 4 new data.StringData fields with descriptions
descriptions.json Add descriptions for the 4 new fields
job.test.ts Add unit tests for field presence and descriptions
validate.expressions.test.ts Add validation test for all 4 fields
complete.expressions.test.ts Update autocomplete expectations to include new fields

Related PRs

Testing

  • 765 tests pass across 42 test suites
  • Autocomplete correctly suggests the new fields
  • Validation passes for expressions using the new fields

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
Copilot AI review requested due to automatic review settings April 10, 2026 21:23
@salmanmkc salmanmkc requested a review from a team as a code owner April 10, 2026 21:23
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 job context provider to include four workflow_* 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

Comment on lines +45 to +49
// 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"));
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines 21 to +30
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();
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +435 to +446
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 }}
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
"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`."
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/....

Suggested change
"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`."

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants