Visitar URL original
Auto-install official extension stubs in CI by BagToad · Pull Request #13581 · cli/cli · GitHub
Skip to content

Auto-install official extension stubs in CI - #13581

Merged
BagToad merged 2 commits into
cli:trunkfrom
BagToad:bagtoad/kw-extension-install-non-interactive
Jun 4, 2026
Merged

BagToad merged 2 commits into
cli:trunkfrom
BagToad:bagtoad/kw-extension-install-non-interactive

Conversation

@BagToad

@BagToad BagToad commented Jun 3, 2026 •

Copy link
Copy Markdown
Member

Description

Skip the install prompt when CI is detected so official extension stubs (like gh aw, gh stack) auto-install instead of blocking on Y/n in CI runners and agent sessions.

Key Points

  • The previous version of this diff mirrored runCopilot exactly: TTY always wins, so a pseudo-TTY agent session with CI=1 still hung on the prompt. This revision flips the order so CI wins over TTY.
  • Intentional divergence from gh copilot: a follow-up could apply the same change there for consistency, but extension stubs are the more pressing case (agents call gh <extname> frequently).
  • CI is detected via ci.IsCI() (any of CI, BUILD_NUMBER, or RUN_ID).

Notes for reviewers

Two commits, reviewable in order:

  1. fix(extension): auto-install official extension stubs in CI is the behavior change. The official_extension_stub file holds the new branching; the stub test extends the existing run-function table test and clears CI env vars per subtest; the acceptance test clears CI env vars and expects non-zero exit plus install instructions on stderr.
  2. docs(extension): explain CI bypass in stub install logic is a one-line comment addressing review feedback that the non-TTY+CI behavior wasn't obvious from the code.

Additional Context

Manually verified locally with gh stack uninstalled. The TTY+CI case is the one this revision actually fixes versus the previous version of the diff:

$ CI=1 ./bin/gh stack --help              # TTY + CI
Successfully installed github/gh-stack    # exit 0

$ CI=1 ./bin/gh stack --help < /dev/null  # non-TTY + CI
Successfully installed github/gh-stack    # exit 0

$ ./bin/gh stack --help < /dev/null       # non-TTY, no CI
gh stack is available as an official extension.
To install it, run:
  gh extension install github/gh-stack    # exit 1

Copilot AI review requested due to automatic review settings June 3, 2026 16:15
@BagToad
BagToad requested a review from a team as a code owner June 3, 2026 16:15
@BagToad
BagToad requested a review from babakks June 3, 2026 16:15
@github-actions github-actions Bot added external pull request originating outside of the CLI core team needs-triage needs to be reviewed unmet-requirements and removed needs-triage needs to be reviewed labels Jun 3, 2026
@github-actions

This comment was marked as off-topic.

@BagToad BagToad changed the title fix(extension): auto-install official extension stubs in CI Auto-install official extension stubs in CI Jun 3, 2026

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.

Pull request overview

Updates the hidden “official extension” stub command behavior so that invoking an uninstalled official extension no longer hangs in non-interactive CI: it auto-installs in CI when prompting isn’t possible, while preserving prompting behavior for interactive TTY sessions.

Changes:

  • Aligns official extension stub branching with ci.IsCI() detection to auto-install in non-TTY CI and show install instructions with a non-zero exit outside CI.
  • Extends unit tests for the stub run behavior across TTY/non-TTY and CI/non-CI permutations, including clearing CI-related env vars per subtest.
  • Updates telemetry acceptance test expectations to account for the new non-zero exit behavior outside CI.
Show a summary per file
File Description
pkg/cmd/root/official_extension_stub.go Adds CI-aware non-interactive behavior (auto-install in CI; instructions + SilentError outside CI).
pkg/cmd/root/official_extension_stub_test.go Expands table tests to cover CI/non-CI and TTY/non-TTY branches; resets CI env vars per case.
acceptance/testdata/telemetry/telemetry-for-official-extension-stub.txtar Ensures CI env vars are cleared and expects non-zero exit for the non-TTY outside-CI path.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comments suppressed due to low confidence (1)

pkg/cmd/root/official_extension_stub_test.go:61

  • If declining the interactive prompt is changed to return cmdutil.SilentError (to match copilot semantics), this test case should expect the non-zero exit (and install guidance on stderr) rather than treating the declined prompt as success.
		{
			name:          "TTY declined does not install",
			isTTY:         true,
			confirmResult: false,
		},
  • Files reviewed: 3/3 changed files
  • Comments generated: 1

Comment thread pkg/cmd/root/official_extension_stub.go Resolved

@babakks babakks left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

Comment thread pkg/cmd/root/official_extension_stub.go Resolved

@babakks babakks left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

When CI is detected, skip the install prompt and install directly so
the stub doesn't block agents and CI runners. Outside CI, keep the
existing TTY-prompt and non-TTY silent-error behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@BagToad
BagToad force-pushed the bagtoad/kw-extension-install-non-interactive branch from 08c6393 to ef8c7d8 Compare June 3, 2026 22:17
@BagToad
BagToad requested a review from babakks June 3, 2026 23:59
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@BagToad
BagToad enabled auto-merge (squash) June 4, 2026 16:09
@BagToad
BagToad merged commit 7ef9c54 into cli:trunk Jun 4, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external pull request originating outside of the CLI core team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants