From 1359974e10e0f13e8ad55753217f382d51583157 Mon Sep 17 00:00:00 2001 From: Stuart Leeks Date: Thu, 19 Nov 2026 08:45:18 +0000 Subject: [PATCH 1/2] Update devcontainer node version --- .devcontainer/devcontainer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 0ea74b3..aff62e5 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -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": [ From 719a41261343b433a4bb405823cd7398ad6b6ee7 Mon Sep 17 00:00:00 2001 From: Stuart Leeks Date: Thu, 19 Nov 2026 08:46:23 +0000 Subject: [PATCH 2/2] Update github-copilot-cli to install as user-writable to allow auto-updates of CLI --- .github/workflows/release.yaml | 2 +- .github/workflows/test.yaml | 1 + Makefile | 3 +++ src/github-copilot-cli/NOTES.md | 1 + src/github-copilot-cli/devcontainer-feature.json | 5 +++-- src/github-copilot-cli/install.sh | 5 ++++- src/github-copilot-cli/oncreate.sh | 3 +++ test/github-copilot-cli/non-root.sh | 15 +++++++++++++++ test/github-copilot-cli/scenarios.json | 10 ++++++++++ test/github-copilot-cli/test.sh | 10 ++++++++++ 10 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 test/github-copilot-cli/non-root.sh create mode 100644 test/github-copilot-cli/scenarios.json create mode 100644 test/github-copilot-cli/test.sh diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 002b89e..5f85051 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -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 diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 60e63da..947b3c2 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -38,6 +38,7 @@ jobs: - azure-cli-persistence - shell-history - dev-tunnels + - github-copilot-cli steps: - uses: actions/checkout@v4 diff --git a/Makefile b/Makefile index 535a934..5f2edd9 100644 --- a/Makefile +++ b/Makefile @@ -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 \ No newline at end of file diff --git a/src/github-copilot-cli/NOTES.md b/src/github-copilot-cli/NOTES.md index aad713a..4ecea78 100644 --- a/src/github-copilot-cli/NOTES.md +++ b/src/github-copilot-cli/NOTES.md @@ -3,4 +3,5 @@ | Version | Notes | | ------- | ------------------------------------------------------------ | +| 0.0.3 | Use a user-writable installation directory for CLI updates | | 0.0.1 | Initial version | \ No newline at end of file diff --git a/src/github-copilot-cli/devcontainer-feature.json b/src/github-copilot-cli/devcontainer-feature.json index 9dfbadc..a6ccb04 100644 --- a/src/github-copilot-cli/devcontainer-feature.json +++ b/src/github-copilot-cli/devcontainer-feature.json @@ -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": [ { diff --git a/src/github-copilot-cli/install.sh b/src/github-copilot-cli/install.sh index 8544f98..4363c95 100644 --- a/src/github-copilot-cli/install.sh +++ b/src/github-copilot-cli/install.sh @@ -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" @@ -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 \ No newline at end of file diff --git a/src/github-copilot-cli/oncreate.sh b/src/github-copilot-cli/oncreate.sh index ea70917..374d8ad 100644 --- a/src/github-copilot-cli/oncreate.sh +++ b/src/github-copilot-cli/oncreate.sh @@ -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() { @@ -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 diff --git a/test/github-copilot-cli/non-root.sh b/test/github-copilot-cli/non-root.sh new file mode 100644 index 0000000..71539a3 --- /dev/null +++ b/test/github-copilot-cli/non-root.sh @@ -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" diff --git a/test/github-copilot-cli/scenarios.json b/test/github-copilot-cli/scenarios.json new file mode 100644 index 0000000..af7519e --- /dev/null +++ b/test/github-copilot-cli/scenarios.json @@ -0,0 +1,10 @@ +{ + "non-root": { + "image": "mcr.microsoft.com/devcontainers/base:ubuntu", + "remoteUser": "vscode", + "updateRemoteUserUID": true, + "features": { + "github-copilot-cli": {} + } + } +} diff --git a/test/github-copilot-cli/test.sh b/test/github-copilot-cli/test.sh new file mode 100644 index 0000000..a2c6c5d --- /dev/null +++ b/test/github-copilot-cli/test.sh @@ -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