Skip to content

Support shorthand forms for getRemoteConfig#3973

Open
mbg wants to merge 17 commits into
mainfrom
mbg/repo-props/config-file-shorthands
Open

Support shorthand forms for getRemoteConfig#3973
mbg wants to merge 17 commits into
mainfrom
mbg/repo-props/config-file-shorthands

Conversation

@mbg

@mbg mbg commented Jun 23, 2026

Copy link
Copy Markdown
Member

This is a follow-up to #3963 which modifies getRemoteConfig to accept shorthand addresses for remote files. Concretely, the owner, path, and ref components are now optional and default to the owner of the current repo (as given by GITHUB_REPOSITORY), .github/codeql-action.yaml, and main respectively.

Examples:

  • owner/repo resolves to owner/repo/.github/codeql-action.yaml@main
  • owner/repo@dev resolves to owner/repo/.github/codeql-action.yaml@dev
  • owner/repo/.github/codeql/config.yml resolves to owner/repo/.github/codeql/config.yml@main

Notes for reviewers

  • We should discuss whether there's a better default we want for the path component
  • The default ref of main may not always be the default branch for the target repo, but that's OK since it can be manually set to a different ref if needed.
  • I originally implemented the shorthand forms from my proposal, but then noticed that getRemoteConfig already had a similar (but not equivalent) shorthand format. I then updated that instead so that the components other than the repo are optional. However, this isn't as nice, because / is used as a separator and can also appear in the path component. That means e.g. it is not possible with this format to specify a repo + path since it would be interpreted as owner + repo by the regex instead.

Risk assessment

For internal use only. Please select the risk level of this change:

  • Low risk: Changes are fully under feature flags, or have been fully tested and validated in pre-production environments and are highly observable, or are documentation or test only.

Which use cases does this change impact?

Workflow types:

  • Advanced setup - Impacts users who have custom CodeQL workflows.
  • Managed - Impacts users with dynamic workflows (Default Setup, Code Quality, ...).

Products:

  • Code Scanning - The changes impact analyses when analysis-kinds: code-scanning.
  • Code Quality - The changes impact analyses when analysis-kinds: code-quality.
  • Other first-party - The changes impact other first-party analyses.

Environments:

  • Dotcom - Impacts CodeQL workflows on github.com and/or GitHub Enterprise Cloud with Data Residency.
  • GHES - Impacts CodeQL workflows on GitHub Enterprise Server.

How did/will you validate this change?

  • Test repository - This change will be tested on a test repository before merging.
  • Unit tests - I am depending on unit test coverage (i.e. tests in .test.ts files).
  • End-to-end tests - I am depending on PR checks (i.e. tests in pr-checks).

If something goes wrong after this change is released, what are the mitigation and rollback strategies?

  • Rollback - Change can only be disabled by rolling back the release or releasing a new version with a fix.

How will you know if something goes wrong after this change is released?

  • Telemetry - I rely on existing telemetry or have made changes to the telemetry.
    • Dashboards - I will watch relevant dashboards for issues after the release. Consider whether this requires this change to be released at a particular time rather than as part of a regular release.
    • Alerts - New or existing monitors will trip if something goes wrong with this change.

Are there any special considerations for merging or releasing this change?

  • No special considerations - This change can be merged at any time.

Merge / deployment checklist

  • Confirm this change is backwards compatible with existing workflows.
  • Consider adding a changelog entry for this change.
  • Confirm the readme and docs have been updated if necessary.

@mbg mbg requested a review from mario-campos June 23, 2026 17:03
@mbg mbg self-assigned this Jun 23, 2026
@github-actions github-actions Bot added the size/L May be hard to review label Jun 23, 2026
@mbg mbg force-pushed the mbg/repo-props/config-file-shorthands branch from a2218f1 to 12821cf Compare June 23, 2026 17:13
@mbg mbg marked this pull request as ready for review June 23, 2026 17:15
@mbg mbg requested a review from a team as a code owner June 23, 2026 17:15
Copilot AI review requested due to automatic review settings June 23, 2026 17:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warning

  • Copilot's review of this pull request may be incomplete because some of the changed files are excluded by your Copilot content exclusion settings. See Excluding content from Copilot for details.

Pull request overview

This PR extends remote configuration file support by enhancing getRemoteConfig to accept shorthand remote addresses (optional owner, path, and ref with sensible defaults), and refactors environment access to be more testable via an Env wrapper.

Changes:

  • Added parseRemoteFileAddress (and tests) to parse shorthand remote config references with defaults for owner/path/ref.
  • Moved getRemoteConfig into src/config/file.ts and updated callers to use the new parsing logic.
  • Introduced ActionsEnvVars and an Env abstraction to reduce raw string usage and improve testability.
Show a summary per file
File Description
src/util.ts Adds Env accessor helpers and refactors env var getters.
src/testing-utils.ts Adds getTestEnv() and tightens typing for default Actions env vars.
src/environment.ts Introduces Env interface abstraction for environment access.
src/config/remote-file.ts New parser for shorthand remote config references and defaults.
src/config/remote-file.test.ts Unit tests for remote file address parsing and defaults.
src/config/file.ts Adds getRemoteConfig() using parsed remote address components.
src/config-utils.ts Switches to the new getRemoteConfig() implementation.
src/config-utils.test.ts Removes a test that no longer matches the supported shorthand syntax.
src/api-client.ts Replaces raw env var names with ActionsEnvVars.
src/actions-util.ts Adds ActionsEnvVars enum and updates env var usages.
lib/entry-points.js Changed but excluded from review (generated/contents unavailable).

Copilot's findings

Files excluded by content exclusion policy (1)
  • lib/entry-points.js
  • Files reviewed: 10/11 changed files
  • Comments generated: 6

Comment thread src/util.ts
Comment thread src/config/remote-file.ts
Comment thread src/config/remote-file.ts Outdated
Comment thread src/config/remote-file.ts
Comment thread src/config/remote-file.test.ts Outdated
Comment thread src/config/remote-file.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L May be hard to review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants