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 .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dev-container-features",
"image": "mcr.microsoft.com/devcontainers/javascript-node:1-22-bookworm",
"image": "mcr.microsoft.com/devcontainers/javascript-node:24-bookworm",
"customizations": {
"vscode": {
"extensions": [
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v6

- name: "Publish Features"
uses: devcontainers/action@v1
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
- azure-cli-persistence
- shell-history
- dev-tunnels
- github-copilot-cli
steps:
- uses: actions/checkout@v4

Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@ test:
test-azure-cli-persistence:
devcontainer features test --features azure-cli-persistence --base-image mcr.microsoft.com/devcontainers/base:ubuntu

test-github-copilot-cli:
devcontainer features test --features github-copilot-cli --base-image mcr.microsoft.com/devcontainers/base:ubuntu

test-railway-cli:
devcontainer features test --features railway-cli --base-image mcr.microsoft.com/devcontainers/base:ubuntu
1 change: 1 addition & 0 deletions src/github-copilot-cli/NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@

| Version | Notes |
| ------- | ------------------------------------------------------------ |
| 0.0.3 | Use a user-writable installation directory for CLI updates |
| 0.0.1 | Initial version |
5 changes: 3 additions & 2 deletions src/github-copilot-cli/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "GitHub Copilot CLI (with persistence)",
"id": "github-copilot-cli",
"version": "0.0.2",
"version": "0.0.3",
"description": "Install GitHub Copilot CLI and configure it to store configuration in a mounted volume to preserve across container builds",
"options": {},
"containerEnv": {
"COPILOT_HOME": "/dc/github-copilot-cli"
"COPILOT_HOME": "/dc/github-copilot-cli",
"PATH": "/usr/local/share/stuartleeks-devcontainer-features/github-copilot-cli/cli/bin:${PATH}"
},
"mounts": [
{
Expand Down
5 changes: 4 additions & 1 deletion src/github-copilot-cli/install.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/sh

FEATURE_DIR="/usr/local/share/stuartleeks-devcontainer-features/github-copilot-cli"
INSTALL_PREFIX="$FEATURE_DIR/cli"
LIFECYCLE_SCRIPTS_DIR="$FEATURE_DIR/scripts"
LOG_FILE="$FEATURE_DIR/log.txt"

Expand All @@ -18,10 +19,12 @@ log "Activating feature 'github-copilot-cli'"
log "User: ${_REMOTE_USER} User home: ${_REMOTE_USER_HOME}"

log "Installing GitHub Copilot CLI..."
curl -fsSL https://gh.io/copilot-install | bash
curl -fsSL https://gh.io/copilot-install | PREFIX="$INSTALL_PREFIX" bash
chown -R "$(id -u "$_REMOTE_USER"):$(id -g "$_REMOTE_USER")" "$INSTALL_PREFIX"
log "GitHub Copilot CLI installed"

if [ -f oncreate.sh ]; then
mkdir -p "${LIFECYCLE_SCRIPTS_DIR}"
cp oncreate.sh "${LIFECYCLE_SCRIPTS_DIR}/oncreate.sh"
chmod +x "${LIFECYCLE_SCRIPTS_DIR}/oncreate.sh"
fi
3 changes: 3 additions & 0 deletions src/github-copilot-cli/oncreate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ set -e
# - installs GitHub Copilot CLI via https://gh.io/copilot-install
#
# `oncreate.sh`
# - fixes installation ownership after remote user UID/GID remapping
# - fixes permissions on the mounted volume so the user can write to it
# (COPILOT_HOME is set to /dc/github-copilot-cli via containerEnv in devcontainer-feature.json)

FEATURE_DIR="/usr/local/share/stuartleeks-devcontainer-features/github-copilot-cli"
INSTALL_PREFIX="$FEATURE_DIR/cli"
LOG_FILE="$FEATURE_DIR/log.txt"

log() {
Expand All @@ -25,6 +27,7 @@ else
fi

$SUDO chown -R "$(id -u):$(id -g)" "$LOG_FILE"
$SUDO chown -R "$(id -u):$(id -g)" "$INSTALL_PREFIX"

log "In OnCreate script"
if [ -f "$FEATURE_DIR/markers/oncreate" ]; then
Expand Down
15 changes: 15 additions & 0 deletions test/github-copilot-cli/non-root.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
set -e

test "$(id -u)" -ne 0

FEATURE_DIR="/usr/local/share/stuartleeks-devcontainer-features/github-copilot-cli"

# Simulate stale ownership after UID/GID remapping, including an existing marker.
sudo chown -R root:root "$FEATURE_DIR/cli"
test ! -w "$FEATURE_DIR/cli/bin"
sudo mkdir -p "$FEATURE_DIR/markers"
sudo touch "$FEATURE_DIR/markers/oncreate"
bash "$FEATURE_DIR/scripts/oncreate.sh"

exec bash "$(dirname "$0")/test.sh"
10 changes: 10 additions & 0 deletions test/github-copilot-cli/scenarios.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"non-root": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"remoteUser": "vscode",
"updateRemoteUserUID": true,
"features": {
"github-copilot-cli": {}
}
}
}
10 changes: 10 additions & 0 deletions test/github-copilot-cli/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -e

INSTALL_DIR="/usr/local/share/stuartleeks-devcontainer-features/github-copilot-cli/cli/bin"

test "$(command -v copilot)" = "$INSTALL_DIR/copilot"
test -w "$INSTALL_DIR/copilot"
staging_dir="$(mktemp -d "$INSTALL_DIR/.copilot-update-test-XXXXXX")"
rmdir "$staging_dir"
COPILOT_AUTO_UPDATE=false copilot --version
Loading