Accept $/ self repository uses syntax (steps + reusable workflows)#381
Open
nodeselector wants to merge 8 commits into
Open
Accept $/ self repository uses syntax (steps + reusable workflows)#381nodeselector wants to merge 8 commits into
nodeselector wants to merge 8 commits into
Conversation
GitHub Actions is introducing self-referencing `uses:` syntax written `$/` (e.g. `uses: $/actions/composite`), which resolves an action or reusable workflow from the same repository as the executing workflow/action. The language service previously flagged every `$/` reference as an `invalid-uses-format` error. - validate-uses.ts: accept `$/<path>` for step uses; error on empty path or a trailing `@ref`; keep the reusable-workflow-in-step error. - validate.ts: accept `$/<path>` for job-level reusable workflows with the same rules as local (`./`) references. - validate-action-reference.ts: resolve `$/` action references against the configured FileProvider and require an action.yml/action.yaml; skipped when no FileProvider is available. - action.ts: treat `$/` as a self/local ref in parseActionReference so remote metadata resolution is skipped. - workflow-parser file-reference.ts / steps.ts: parse `$/` as a repo-root-relative path and name self-reference step ids "self".
Scope correction: `$/` is only valid for action references in steps (workflow steps and composite `runs.steps[*].uses`), not for job-level reusable-workflow calls (`jobs.<id>.uses`). Job-level `$/` stays a validation error. - Reverts the `$/` handling in validateWorkflowUsesFormat (validate.ts) and in parseFileReference (workflow-parser), so job-level `$/` is rejected as before. - Step-level `$/<path>` now also accepts an optional `@ref` (e.g. `$/actions/foo@v1`); the existence check strips the ref before resolving the action manifest. - Tests: assert step-level `$/foo` and `$/foo@v1` are valid, and that a job-level reusable-workflow `$/` reference stays invalid.
Per the fleet standard / ADR, a self-reference (`$/<path>`) must not include a version. A trailing `@ref` (e.g. `$/actions/foo@v1`) is now a validation error instead of being accepted-and-ignored; the runtime parser is being fixed to match.
Eric Sciple confirmed the intent is for $/ to work when referencing reusable workflows at the job level, resolving to this repository at the running SHA exactly like ./ does for local reusable workflows. This reverses the earlier rule where any job-level $/ was rejected. validateWorkflowUsesFormat now treats $/.github/workflows(-lab)/*.yml like a local reusable-workflow reference: rooted-path, extension, and top-level checks apply, and a trailing @ref is rejected since a version is meaningless on a self-reference. parseFileReference resolves $/ to a local file reference so the referenced workflow can be loaded. Step-level $/ behavior is unchanged (bare valid, @ref invalid).
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support for $/{path} self-referencing uses syntax across the workflow parser and language service so actions and reusable workflows can be referenced within the same repository similarly to ./ local references.
Changes:
- Accept
$/...as a local/self file reference in the workflow parser and normalize it like other local references. - Extend languageservice validation to recognize and validate
$/...for stepuses(actions) and jobuses(reusable workflows), including new error cases (empty path,@ref). - Add/extend tests covering
$/{path}in workflows and actions, including optional resolution viafileProvider.
Show a summary per file
| File | Description |
|---|---|
| workflow-parser/src/workflows/file-reference.ts | Parses $/... as a local/self file reference. |
| workflow-parser/src/model/converter/steps.ts | Treats $/... like other self/local actions for step id generation. |
| languageservice/src/utils/validate-uses.ts | Adds step-level uses format validation for $/.... |
| languageservice/src/validate-action-reference.ts | Adds optional existence checks for self-referenced actions via fileProvider. |
| languageservice/src/action.ts | Excludes $/... from remote action reference parsing. |
| languageservice/src/validate.ts | Adds job-level reusable workflow uses validation for $/.... |
| languageservice/src/validate.uses-format.test.ts | Adds workflow/action uses format tests for $/... scenarios. |
| languageservice/src/validate.self-uses.test.ts | New tests validating self action resolution using a fake in-repo FileProvider. |
| languageservice/src/validate-action.test.ts | Adds action validation test for $/' used inside composite action steps. |
| languageservice/src/action.test.ts | Adds parseActionReference coverage for $/' inputs. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 10/10 changed files
- Comments generated: 3
- Review effort level: Low
Cover the $/ branch added to parseFileReference directly at the parser level: bare path, empty path, and a fileIdentifier round-trip asserting $/ normalizes to the same identifier as the equivalent ./ local reference. Addresses reviewer feedback that the new self-reference parsing lacked direct unit coverage.
The naming canonical for $/ is "self repository" (it resolves to the
same repository at the running SHA), not "self reference"/"self
referenced". Rename the user-facing diagnostic wording and the internal
helpers accordingly:
- Messages: "self repository references" / "self repository workflows".
- validateSelfUsesFormat -> validateSelfRepositoryUsesFormat.
- validateSelfActionReference -> validateSelfRepositoryActionReference.
- Rename validate.self-uses.test.ts -> validate.self-repository-uses.test.ts
and update its assertions.
The $/{path} format hint and behavior are unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Teaches the language service to understand the
$/self repositoryuses:syntax so the workflow and action editors validate it correctly.$/<path>wherever a same-repository reference is valid: action steps, composite-action steps, and job-level reusable-workflow calls.$/…@ref— a self repository reference is inherently pinned to the running commit and cannot specify a version.action.ymlor an out-of-tree workflow path.Pairs with the
$/self repository support landing across the parser, launch, and pin tooling.