Skip to content

Commit cdc05fd

Browse files
committed
Install Copilot CLI into the agent tool cache (ADR §10093)
Replace the prior `npm install -g` (which puts the binary on the global PATH but not in the agent tool cache) with a tool-cache install at $AGENT_TOOLSDIRECTORY/copilot-cli/<version>/x64/ plus the matching `x64.complete` marker. This matches the layout that the runtime resolver in gh-aw-actions/setup expects from `tc.find("copilot-cli", ...)`, so hosted runner jobs hit a warm cache instead of re-installing the CLI on every run. Mirrors the conventions already used by install-awf.sh and install-codeql-bundle.sh in the same directory. Updates the Pester test to validate the tool-cache layout (directory, bin/copilot, and .complete marker) in Tools.Tests.ps1, mirroring the existing AWF block, and drops the now-stale `copilot --version` check from CLI.Tools.Tests.ps1 since PATH augmentation is handled at runtime by the setup action, not by the bake.
1 parent c137786 commit cdc05fd

3 files changed

Lines changed: 38 additions & 9 deletions

File tree

images/ubuntu/scripts/build/install-copilot-cli.sh

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,21 @@ if ! [[ "$copilot_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; the
4848
exit 1
4949
fi
5050

51-
echo "Installing GitHub Copilot CLI v$copilot_version (pinned via compat.json)..."
52-
npm install -g "@github/copilot@${copilot_version}" --ignore-scripts
51+
# Install into the agent tool cache so the gh-aw-actions/setup action's
52+
# tc.find("copilot-cli", ...) lookup succeeds on hosted runners. Layout:
53+
# $AGENT_TOOLSDIRECTORY/copilot-cli/<version>/x64/{bin,lib}
54+
# $AGENT_TOOLSDIRECTORY/copilot-cli/<version>/x64.complete
55+
# Mirrors the conventions used by install-awf.sh and install-codeql-bundle.sh
56+
# and matches the layout the runtime resolver expects (see ADR
57+
# https://github.com/github/c2c-actions/blob/main/docs/adrs/10093-copilot-cli-stability-for-agentic-workflows.md).
58+
copilot_toolcache_path="$AGENT_TOOLSDIRECTORY/copilot-cli/$copilot_version/x64"
59+
mkdir -p "$copilot_toolcache_path"
5360

54-
invoke_tests "CLI.Tools" "Copilot CLI"
61+
echo "Installing GitHub Copilot CLI v$copilot_version into $copilot_toolcache_path (pinned via compat.json)..."
62+
npm install -g --prefix "$copilot_toolcache_path" \
63+
"@github/copilot@${copilot_version}" --ignore-scripts
64+
65+
# Mark the tool-cache entry complete so @actions/tool-cache#find returns it.
66+
touch "$copilot_toolcache_path.complete"
67+
68+
invoke_tests "Tools" "Copilot CLI"

images/ubuntu/scripts/tests/CLI.Tools.Tests.ps1

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,6 @@ Describe "GitHub CLI" {
3636
}
3737
}
3838

39-
Describe "Copilot CLI" -Skip:(Test-IsUbuntu22) {
40-
It "copilot cli" {
41-
"copilot --version" | Should -ReturnZeroExitCode
42-
}
43-
}
44-
4539
Describe "Google Cloud CLI" {
4640
It "Google Cloud CLI" {
4741
"gcloud --version" | Should -ReturnZeroExitCode

images/ubuntu/scripts/tests/Tools.Tests.ps1

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,3 +428,24 @@ Describe "AWF" -Skip:(Test-IsUbuntu22) {
428428
$bundlePath | Should -Exist
429429
}
430430
}
431+
432+
Describe "Copilot CLI" -Skip:(Test-IsUbuntu22) {
433+
It "Copilot CLI toolcache directory exists" {
434+
$copilotPath = Join-Path $env:AGENT_TOOLSDIRECTORY "copilot-cli"
435+
$copilotPath | Should -Exist
436+
}
437+
438+
It "Copilot CLI binary exists in toolcache" {
439+
$copilotPath = Join-Path $env:AGENT_TOOLSDIRECTORY "copilot-cli"
440+
$latestVersion = Get-ChildItem -Path $copilotPath -Directory | Sort-Object -Property { [version]$_.Name } -Descending | Select-Object -First 1
441+
$binPath = Join-Path $latestVersion.FullName "x64" "bin" "copilot"
442+
$binPath | Should -Exist
443+
}
444+
445+
It "Copilot CLI toolcache .complete marker exists" {
446+
$copilotPath = Join-Path $env:AGENT_TOOLSDIRECTORY "copilot-cli"
447+
$latestVersion = Get-ChildItem -Path $copilotPath -Directory | Sort-Object -Property { [version]$_.Name } -Descending | Select-Object -First 1
448+
$completeMarker = Join-Path $latestVersion.FullName "x64.complete"
449+
$completeMarker | Should -Exist
450+
}
451+
}

0 commit comments

Comments
 (0)