Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/copilot-cli/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "copilot-cli",
"version": "1.1.2",
"version": "1.1.3",
"name": "GitHub Copilot CLI",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/copilot-cli",
"description": "Installs the GitHub Copilot CLI.",
Expand Down
12 changes: 11 additions & 1 deletion src/copilot-cli/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ check_packages() {
fi
}

resolve_prerelease_version() {
local repo_versions="${1:?resolve_prerelease_version requires the copilot-cli repo tags as input}"
printf '%s\n' "${repo_versions}" \
| awk '{print $2}' | sed 's|refs/tags/||' \
| grep -E '^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9]+)?$' \
| sort -V | tail -n1
}

download_from_github() {
local release_url=$1
echo "Downloading GitHub Copilot CLI from ${release_url}..."
Expand Down Expand Up @@ -63,8 +71,10 @@ install_using_github() {
if [ "${CLI_VERSION}" = "latest" ]; then
download_from_github "https://github.com/github/copilot-cli/releases/latest/download/${cli_filename}"
elif [ "${CLI_VERSION}" = "prerelease" ]; then
prerelease_version="$(git ls-remote --tags https://github.com/github/copilot-cli | tail -1 | awk -F/ '{print $NF}')"

prerelease_version="$(resolve_prerelease_version "$(git ls-remote --tags https://github.com/github/copilot-cli)")"
download_from_github "https://github.com/github/copilot-cli/releases/download/${prerelease_version}/${cli_filename}"

else
# Install specific version
# Add leading v to version if it doesn't start with v
Expand Down
19 changes: 19 additions & 0 deletions test/copilot-cli/install_prerelease.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

set -e

# Optional: Import test library
source dev-container-features-test-lib

# End-to-end check that the "prerelease" channel actually resolves a tag and
# installs the binary. Regression guard for the inline pipeline in
# src/copilot-cli/install.sh.

check "copilot binary is on PATH" which copilot
check "copilot reports a version" bash -c "copilot -v"

# Auto-update flag file must exist for prerelease channel.
check "auto-update flag created for prerelease" test -f /etc/devcontainer-copilot-cli/auto-update

# Report result
reportResults
32 changes: 32 additions & 0 deletions test/copilot-cli/resolve_prerelease_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

set -e

# Optional: Import test library
source dev-container-features-test-lib

resolve_prerelease_version() {
local repo_versions="${1:?resolve_prerelease_version requires the copilot-cli repo tags as input}"
printf '%s\n' "${repo_versions}" \
| awk '{print $2}' | sed 's|refs/tags/||' \
| grep -E '^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9]+)?$' \
| sort -V | tail -n1
}

# Tests the tag-resolution pipeline used by src/copilot-cli/install.sh for the
# "prerelease" channel.

check "copilot binary is on PATH" which copilot
check "copilot reports a version" bash -c "copilot -v"

result1="$(resolve_prerelease_version $'abc1234\trefs/tags/v1.0.1\ndef5678\trefs/tags/v1.0.9\nghi9012\trefs/tags/v1.0.10\njkl3456\trefs/tags/v1.0.45\nmno7890\trefs/tags/v1.0.2\n')"
check "picks highest version (v1.0.45)" bash -c "[ '${result1}' = 'v1.0.45' ]"

result2="$(resolve_prerelease_version $'abc1234\trefs/tags/v1.0.44\ndef5678\trefs/tags/v1.0.45-1\nghi9012\trefs/tags/v1.0.45-10\njkl3456\trefs/tags/v1.0.45-2\nmno7890\trefs/tags/v1.0.45\n')"
check "picks highest prerelease (v1.0.45-10)" bash -c "[ '${result2}' = 'v1.0.45-10' ]"

result3="$(resolve_prerelease_version $'abc1234\trefs/tags/latest\ndef5678\trefs/tags/v1.0.3\nghi9012\trefs/tags/nightly\njkl3456\trefs/tags/v1.0.20\n')"
check "picks highest version ignoring non-version tags (v1.0.20)" bash -c "[ '${result3}' = 'v1.0.20' ]"

# Report result
reportResults
18 changes: 18 additions & 0 deletions test/copilot-cli/scenarios.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"resolve_prerelease_version": {
"image": "ubuntu:noble",
"features": {
"copilot-cli": {
"version": "latest"
}
}
},
"install_prerelease": {
"image": "ubuntu:noble",
"features": {
"copilot-cli": {
"version": "prerelease"
}
}
}
}
Loading