From c653ad4043a68dbe5cb04fc6644b6c2d1ce0f6b8 Mon Sep 17 00:00:00 2001 From: Joshua Ji Date: Sat, 6 Jan 2024 16:44:47 +0000 Subject: [PATCH 01/22] Add failing tests --- test/aws-cli-persistence/scenarios.json | 10 ++++++++++ test/aws-cli-persistence/zsh_shell.sh | 22 ++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 test/aws-cli-persistence/zsh_shell.sh diff --git a/test/aws-cli-persistence/scenarios.json b/test/aws-cli-persistence/scenarios.json index 31dbef2..2d712a8 100644 --- a/test/aws-cli-persistence/scenarios.json +++ b/test/aws-cli-persistence/scenarios.json @@ -5,5 +5,15 @@ "aws-cli-persistence": {}, "ghcr.io/devcontainers/features/aws-cli": {} } + }, + "zsh_shell": { + "image": "mcr.microsoft.com/devcontainers/javascript-node:1-18", + "features": { + "aws-cli-persistence": {}, + "ghcr.io/devcontainers/features/aws-cli": {}, + "ghcr.io/devcontainers/features/common-utils:2": { + "configureZshAsDefaultShell": true + } + } } } diff --git a/test/aws-cli-persistence/zsh_shell.sh b/test/aws-cli-persistence/zsh_shell.sh new file mode 100644 index 0000000..bd22931 --- /dev/null +++ b/test/aws-cli-persistence/zsh_shell.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# check that `aws --help` works +check "help" bash -c "aws help | grep 'usage'" + +# check that `.aws` and `/dc/aws-cli` exist under the user (should be node) +check "~/.aws existence" bash -c "ls -la ~ | grep '.aws'" +check "/dc/aws-cli existence" bash -c "ls -la /dc | grep 'aws-cli'" + +# check that the folders are owned by the user +# `stat -c "%U %G" ~/.aws` returns "$USER $GROUP", in this case "node node" +# https://askubuntu.com/a/175060 +check "~/.aws owned by user" bash -c "test \"$(stat -c "%U %G" ~/.aws)\" = 'node node'" +check "/dc/aws-cli owned by user" bash -c "test \"$(stat -c "%U %G" /dc/aws-cli)\" = 'node node'" + +# Report result +reportResults From cca47e5d6a00493d453efd1b62699516fe941ed5 Mon Sep 17 00:00:00 2001 From: Joshua Ji Date: Mon, 8 Jan 2024 19:18:17 +0000 Subject: [PATCH 02/22] add stuff to `.zshrc` --- src/aws-cli-persistence/install.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/aws-cli-persistence/install.sh b/src/aws-cli-persistence/install.sh index 92bf3c4..b540126 100644 --- a/src/aws-cli-persistence/install.sh +++ b/src/aws-cli-persistence/install.sh @@ -4,7 +4,7 @@ set -e echo "Activating feature 'aws-cli-persistence'" echo "User: ${_REMOTE_USER} User home: ${_REMOTE_USER_HOME}" -if [ -z "$_REMOTE_USER" ] || [ -z "$_REMOTE_USER_HOME" ]; then +if [ -z "$_REMOTE_USER" ] || [ -z "$_REMOTE_USER_HOME" ]; then echo "***********************************************************************************" echo "*** Require _REMOTE_USER and _REMOTE_USER_HOME to be set (by dev container CLI) ***" echo "***********************************************************************************" @@ -24,8 +24,16 @@ ln -s /dc/aws-cli "$_REMOTE_USER_HOME/.aws" # chown .aws folder chown -R "${_REMOTE_USER}:${_REMOTE_USER}" "$_REMOTE_USER_HOME/.aws" -# chown mount (only attached on startup) -cat << EOF >> "$_REMOTE_USER_HOME/.bashrc" +# === chown mount + +# Bash +cat <>"$_REMOTE_USER_HOME/.bashrc" +sudo chown -R "${_REMOTE_USER}:${_REMOTE_USER}" /dc/aws-cli +EOF +chown -R "$_REMOTE_USER" "$_REMOTE_USER_HOME/.bashrc" + +# zsh +cat <>"$_REMOTE_USER_HOME/.zshrc" sudo chown -R "${_REMOTE_USER}:${_REMOTE_USER}" /dc/aws-cli EOF -chown -R $_REMOTE_USER $_REMOTE_USER_HOME/.bashrc +chown -R $_REMOTE_USER $_REMOTE_USER_HOME/.zshrc From bb12ff5fc3ee5440d9ce3844b4b7c99c06d28d2e Mon Sep 17 00:00:00 2001 From: Joshua Ji Date: Tue, 9 Jan 2024 00:30:00 +0000 Subject: [PATCH 03/22] Use `postCreateCommand` everywhere lol --- .../devcontainer-feature.json | 3 ++- src/aws-cli-persistence/install.sh | 14 ------------ .../devcontainer-feature.json | 3 ++- src/gcloud-cli-persistence/install.sh | 6 ----- .../devcontainer-feature.json | 3 ++- src/github-cli-persistence/install.sh | 14 ++++-------- .../devcontainer-feature.json | 5 ++++- src/mount-pnpm-store/install.sh | 14 ++++-------- .../devcontainer-feature.json | 3 ++- src/terraform-cli-persistence/install.sh | 12 +++------- test/aws-cli-persistence/with_node.sh | 3 +++ test/gcloud-cli-persistence/scenarios.json | 10 +++++++++ test/gcloud-cli-persistence/zsh_shell.sh | 0 test/github-cli-persistence/scenarios.json | 12 +++++++++- test/github-cli-persistence/zsh_shell.sh | 22 +++++++++++++++++++ test/mount-pnpm-store/scenarios.json | 20 ++++++++++------- test/mount-pnpm-store/zsh_shell.sh | 19 ++++++++++++++++ test/terraform-cli-persistence/scenarios.json | 12 +++++++++- test/terraform-cli-persistence/zsh_shell.sh | 22 +++++++++++++++++++ 19 files changed, 133 insertions(+), 64 deletions(-) create mode 100644 test/gcloud-cli-persistence/zsh_shell.sh create mode 100644 test/github-cli-persistence/zsh_shell.sh create mode 100644 test/mount-pnpm-store/zsh_shell.sh create mode 100644 test/terraform-cli-persistence/zsh_shell.sh diff --git a/src/aws-cli-persistence/devcontainer-feature.json b/src/aws-cli-persistence/devcontainer-feature.json index 0543436..11fcb40 100644 --- a/src/aws-cli-persistence/devcontainer-feature.json +++ b/src/aws-cli-persistence/devcontainer-feature.json @@ -14,5 +14,6 @@ ], "installsAfter": [ "ghcr.io/devcontainers/features/aws-cli" - ] + ], + "postCreateCommand": "sudo chown -R $USER:$USER /dc/aws-cli" } \ No newline at end of file diff --git a/src/aws-cli-persistence/install.sh b/src/aws-cli-persistence/install.sh index b540126..a182c4a 100644 --- a/src/aws-cli-persistence/install.sh +++ b/src/aws-cli-persistence/install.sh @@ -23,17 +23,3 @@ fi ln -s /dc/aws-cli "$_REMOTE_USER_HOME/.aws" # chown .aws folder chown -R "${_REMOTE_USER}:${_REMOTE_USER}" "$_REMOTE_USER_HOME/.aws" - -# === chown mount - -# Bash -cat <>"$_REMOTE_USER_HOME/.bashrc" -sudo chown -R "${_REMOTE_USER}:${_REMOTE_USER}" /dc/aws-cli -EOF -chown -R "$_REMOTE_USER" "$_REMOTE_USER_HOME/.bashrc" - -# zsh -cat <>"$_REMOTE_USER_HOME/.zshrc" -sudo chown -R "${_REMOTE_USER}:${_REMOTE_USER}" /dc/aws-cli -EOF -chown -R $_REMOTE_USER $_REMOTE_USER_HOME/.zshrc diff --git a/src/gcloud-cli-persistence/devcontainer-feature.json b/src/gcloud-cli-persistence/devcontainer-feature.json index 098ffee..35fb445 100644 --- a/src/gcloud-cli-persistence/devcontainer-feature.json +++ b/src/gcloud-cli-persistence/devcontainer-feature.json @@ -14,5 +14,6 @@ ], "installsAfter": [ "ghcr.io/dhoeric/features/google-cloud-cli" - ] + ], + "postCreateCommand": "sudo chown -R $USER:$USER /dc/aws-cli" } \ No newline at end of file diff --git a/src/gcloud-cli-persistence/install.sh b/src/gcloud-cli-persistence/install.sh index adbf2f8..72cd96d 100644 --- a/src/gcloud-cli-persistence/install.sh +++ b/src/gcloud-cli-persistence/install.sh @@ -27,9 +27,3 @@ ln -s /dc/gcloud-cli "$_REMOTE_USER_HOME/.config/gcloud" # chown the entire `.config` folder because devcontainers creates # a `~/.config/vscode-dev-containers` folder later on chown -R "${_REMOTE_USER}:${_REMOTE_USER}" "$_REMOTE_USER_HOME/.config" - -# chown mount (only attached on startup) -cat <>"$_REMOTE_USER_HOME/.bashrc" -sudo chown -R "${_REMOTE_USER}:${_REMOTE_USER}" /dc/gcloud-cli -EOF -chown -R $_REMOTE_USER $_REMOTE_USER_HOME/.bashrc diff --git a/src/github-cli-persistence/devcontainer-feature.json b/src/github-cli-persistence/devcontainer-feature.json index b3c166f..8717ebc 100644 --- a/src/github-cli-persistence/devcontainer-feature.json +++ b/src/github-cli-persistence/devcontainer-feature.json @@ -14,5 +14,6 @@ ], "installsAfter": [ "ghcr.io/devcontainers/features/github-cli" - ] + ], + "postCreateCommand": "sudo chown -R $USER:$USER /dc/github-cli" } \ No newline at end of file diff --git a/src/github-cli-persistence/install.sh b/src/github-cli-persistence/install.sh index 6098295..2fa7748 100644 --- a/src/github-cli-persistence/install.sh +++ b/src/github-cli-persistence/install.sh @@ -4,7 +4,7 @@ set -e echo "Activating feature 'github-cli-persistence'" echo "User: ${_REMOTE_USER} User home: ${_REMOTE_USER_HOME}" -if [ -z "$_REMOTE_USER" ] || [ -z "$_REMOTE_USER_HOME" ]; then +if [ -z "$_REMOTE_USER" ] || [ -z "$_REMOTE_USER_HOME" ]; then echo "***********************************************************************************" echo "*** Require _REMOTE_USER and _REMOTE_USER_HOME to be set (by dev container CLI) ***" echo "***********************************************************************************" @@ -15,7 +15,7 @@ fi mkdir -p "$_REMOTE_USER_HOME/.config" mkdir -p "/dc/github-cli" -# if `.config/gh` already exists, the `ln -s` command will create an extra +# if `.config/gh` already exists, the `ln -s` command will create an extra # folder *inside* `.config/gh` that symlinks to `github-cli` # Thus, we want to make sure the folder does NOT exist so the symlink will actually be to ~/.config/gh if [ -e "$_REMOTE_USER_HOME/.config/gh" ]; then @@ -24,12 +24,6 @@ if [ -e "$_REMOTE_USER_HOME/.config/gh" ]; then fi ln -s /dc/github-cli "$_REMOTE_USER_HOME/.config/gh" -# chown the entire `.config` folder because devcontainers creates -# a `~/.config/vscode-dev-containers` folder later on +# chown the entire `.config` folder because devcontainers creates +# a `~/.config/vscode-dev-containers` folder later on chown -R "${_REMOTE_USER}:${_REMOTE_USER}" "$_REMOTE_USER_HOME/.config" - -# chown mount (only attached on startup) -cat << EOF >> "$_REMOTE_USER_HOME/.bashrc" -sudo chown -R "${_REMOTE_USER}:${_REMOTE_USER}" /dc/github-cli -EOF -chown -R $_REMOTE_USER $_REMOTE_USER_HOME/.bashrc diff --git a/src/mount-pnpm-store/devcontainer-feature.json b/src/mount-pnpm-store/devcontainer-feature.json index 048800b..5d2f73f 100644 --- a/src/mount-pnpm-store/devcontainer-feature.json +++ b/src/mount-pnpm-store/devcontainer-feature.json @@ -12,5 +12,8 @@ "type": "volume" } ], - "installsAfter": [] + "installsAfter": [ + "ghcr.io/devcontainers/features/node" + ], + "postCreateCommand": "sudo chown -R $USER:$USER /dc/mounted-pnpm-store" } \ No newline at end of file diff --git a/src/mount-pnpm-store/install.sh b/src/mount-pnpm-store/install.sh index 576712c..23b79dd 100644 --- a/src/mount-pnpm-store/install.sh +++ b/src/mount-pnpm-store/install.sh @@ -4,7 +4,7 @@ set -e echo "Activating feature 'mount-pnpm-store'" echo "User: ${_REMOTE_USER} User home: ${_REMOTE_USER_HOME}" -if [ -z "$_REMOTE_USER" ] || [ -z "$_REMOTE_USER_HOME" ]; then +if [ -z "$_REMOTE_USER" ] || [ -z "$_REMOTE_USER_HOME" ]; then echo "***********************************************************************************" echo "*** Require _REMOTE_USER and _REMOTE_USER_HOME to be set (by dev container CLI) ***" echo "***********************************************************************************" @@ -16,22 +16,16 @@ mkdir -p "/dc/mounted-pnpm-store" # as to why we move around the folder, check `github-cli-persistence/install.sh` if [ -e "$_REMOTE_USER_HOME/.pnpm-store" ]; then - echo "Moving existing .pnpm-store folder to .pnpm-store-old" - mv "$_REMOTE_USER_HOME/.pnpm-store" "$_REMOTE_USER_HOME/.pnpm-store-old" + echo "Moving existing .pnpm-store folder to .pnpm-store-old" + mv "$_REMOTE_USER_HOME/.pnpm-store" "$_REMOTE_USER_HOME/.pnpm-store-old" fi ln -s /dc/mounted-pnpm-store "$_REMOTE_USER_HOME/.pnpm-store" chown -R "$_REMOTE_USER:$_REMOTE_USER" "$_REMOTE_USER_HOME/.pnpm-store" -# chown mount (only attached on startup) -cat << EOF >> "$_REMOTE_USER_HOME/.bashrc" -sudo chown -R "$_REMOTE_USER:$_REMOTE_USER" /dc/mounted-pnpm-store -EOF -chown -R $_REMOTE_USER $_REMOTE_USER_HOME/.bashrc - # set pnpm store location # if pnpm is not installed, print out a warning -if type pnpm > /dev/null 2>&1; then +if type pnpm >/dev/null 2>&1; then echo "Setting pnpm store location to $_REMOTE_USER_HOME/.pnpm-store" # we have to run the `pnpm config set store-dir` as the remote user # because the remote user is the one that will be using pnpm diff --git a/src/terraform-cli-persistence/devcontainer-feature.json b/src/terraform-cli-persistence/devcontainer-feature.json index ede2ad4..e6b0789 100644 --- a/src/terraform-cli-persistence/devcontainer-feature.json +++ b/src/terraform-cli-persistence/devcontainer-feature.json @@ -14,5 +14,6 @@ ], "installsAfter": [ "ghcr.io/devcontainers/features/terraform" - ] + ], + "postCreateCommand": "sudo chown -R $USER:$USER /dc/terraform-cli" } \ No newline at end of file diff --git a/src/terraform-cli-persistence/install.sh b/src/terraform-cli-persistence/install.sh index 609bd50..8eba89b 100644 --- a/src/terraform-cli-persistence/install.sh +++ b/src/terraform-cli-persistence/install.sh @@ -4,7 +4,7 @@ set -e echo "Activating feature 'terraform-cli-persistence'" echo "User: ${_REMOTE_USER} User home: ${_REMOTE_USER_HOME}" -if [ -z "$_REMOTE_USER" ] || [ -z "$_REMOTE_USER_HOME" ]; then +if [ -z "$_REMOTE_USER" ] || [ -z "$_REMOTE_USER_HOME" ]; then echo "***********************************************************************************" echo "*** Require _REMOTE_USER and _REMOTE_USER_HOME to be set (by dev container CLI) ***" echo "***********************************************************************************" @@ -21,12 +21,6 @@ if [ -e "$_REMOTE_USER_HOME/.terraform.d" ]; then fi ln -s /dc/terraform-cli "$_REMOTE_USER_HOME/.terraform.d" -# chown the entire `.config` folder because devcontainers creates -# a `~/.config/vscode-dev-containers` folder later on +# chown the entire `.config` folder because devcontainers creates +# a `~/.config/vscode-dev-containers` folder later on chown -R "${_REMOTE_USER}:${_REMOTE_USER}" "$_REMOTE_USER_HOME/.terraform.d" - -# chown mount (only attached on startup) -cat << EOF >> "$_REMOTE_USER_HOME/.bashrc" -sudo chown -R "${_REMOTE_USER}:${_REMOTE_USER}" /dc/terraform-cli -EOF -chown -R $_REMOTE_USER $_REMOTE_USER_HOME/.bashrc diff --git a/test/aws-cli-persistence/with_node.sh b/test/aws-cli-persistence/with_node.sh index bd22931..f86688e 100644 --- a/test/aws-cli-persistence/with_node.sh +++ b/test/aws-cli-persistence/with_node.sh @@ -15,6 +15,9 @@ check "/dc/aws-cli existence" bash -c "ls -la /dc | grep 'aws-cli'" # check that the folders are owned by the user # `stat -c "%U %G" ~/.aws` returns "$USER $GROUP", in this case "node node" # https://askubuntu.com/a/175060 +echo "Checking ownership of ~/.aws and /dc/aws-cli" +stat -c "%U %G" /dc/aws-cli + check "~/.aws owned by user" bash -c "test \"$(stat -c "%U %G" ~/.aws)\" = 'node node'" check "/dc/aws-cli owned by user" bash -c "test \"$(stat -c "%U %G" /dc/aws-cli)\" = 'node node'" diff --git a/test/gcloud-cli-persistence/scenarios.json b/test/gcloud-cli-persistence/scenarios.json index 6e274b1..9c1017b 100644 --- a/test/gcloud-cli-persistence/scenarios.json +++ b/test/gcloud-cli-persistence/scenarios.json @@ -5,5 +5,15 @@ "gcloud-cli-persistence": {}, "ghcr.io/dhoeric/features/google-cloud-cli": {} } + }, + "zsh_shell": { + "image": "mcr.microsoft.com/devcontainers/javascript-node:1-18", + "features": { + "gcloud-cli-persistence": {}, + "ghcr.io/dhoeric/features/google-cloud-cli": {}, + "ghcr.io/devcontainers/features/common-utils:2": { + "configureZshAsDefaultShell": true + } + } } } \ No newline at end of file diff --git a/test/gcloud-cli-persistence/zsh_shell.sh b/test/gcloud-cli-persistence/zsh_shell.sh new file mode 100644 index 0000000..e69de29 diff --git a/test/github-cli-persistence/scenarios.json b/test/github-cli-persistence/scenarios.json index 0a25476..e2caf6c 100644 --- a/test/github-cli-persistence/scenarios.json +++ b/test/github-cli-persistence/scenarios.json @@ -5,5 +5,15 @@ "github-cli-persistence": {}, "ghcr.io/devcontainers/features/github-cli": {} } + }, + "zsh_shell": { + "image": "mcr.microsoft.com/devcontainers/javascript-node:1-18", + "features": { + "github-cli-persistence": {}, + "ghcr.io/devcontainers/features/github-cli": {}, + "ghcr.io/devcontainers/features/common-utils:2": { + "configureZshAsDefaultShell": true + } + } } -} +} \ No newline at end of file diff --git a/test/github-cli-persistence/zsh_shell.sh b/test/github-cli-persistence/zsh_shell.sh new file mode 100644 index 0000000..c55f121 --- /dev/null +++ b/test/github-cli-persistence/zsh_shell.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# check that `gh --help` works +check "help" bash -c "gh --help | grep 'USAGE'" + +# check that `.config/gh` and `/dc/github-cli` exist under the user (should be node) +check "config" bash -c "ls -la ~/.config | grep 'gh'" +check "dc" bash -c "ls -la /dc | grep 'github-cli'" + +# check that the folders are owned by the user +# `stat -c "%U %G" ~/.config` returns "$USER $GROUP", in this case "node node" +# https://askubuntu.com/a/175060 +check "~/.config/gh owned by user" bash -c "test \"$(stat -c "%U %G" ~/.config)\" = 'node node'" +check "/dc/github-cli owned by user" bash -c "test \"$(stat -c "%U %G" /dc/github-cli)\" = 'node node'" + +# Report result +reportResults diff --git a/test/mount-pnpm-store/scenarios.json b/test/mount-pnpm-store/scenarios.json index f0ab156..a0216af 100644 --- a/test/mount-pnpm-store/scenarios.json +++ b/test/mount-pnpm-store/scenarios.json @@ -8,13 +8,17 @@ "with_pnpm": { "image": "mcr.microsoft.com/devcontainers/base:bullseye", "features": { - "ghcr.io/devcontainers/features/node:1": { - "version": "20" - }, + "ghcr.io/devcontainers/features/node:1": {}, "mount-pnpm-store": {} - }, - "overrideFeatureInstallOrder": [ - "ghcr.io/devcontainers/features/node", "./mount-pnpm-store" - ] + } + }, + "zsh_shell": { + "image": "mcr.microsoft.com/devcontainers/javascript-node:1-18", + "features": { + "mount-pnpm-store": {}, + "ghcr.io/devcontainers/features/common-utils:2": { + "configureZshAsDefaultShell": true + } + } } -} +} \ No newline at end of file diff --git a/test/mount-pnpm-store/zsh_shell.sh b/test/mount-pnpm-store/zsh_shell.sh new file mode 100644 index 0000000..5694530 --- /dev/null +++ b/test/mount-pnpm-store/zsh_shell.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +set -e + +# tests installing pnpm after zsh shell + +# Optional: Import test library +source dev-container-features-test-lib + +echo "User: $(whoami)" +pnpm config list + +# check that `pnpm config get store-dir` returns /home/vscode/.pnpm-store +pnpmConfig=$(pnpm config get store-dir) +echo "pnpm config get store-dir: '$pnpmConfig'" +check "config" test $pnpmConfig = "/home/vscode/.pnpm-store" + +# Report result +reportResults diff --git a/test/terraform-cli-persistence/scenarios.json b/test/terraform-cli-persistence/scenarios.json index 042a81d..b01e292 100644 --- a/test/terraform-cli-persistence/scenarios.json +++ b/test/terraform-cli-persistence/scenarios.json @@ -5,5 +5,15 @@ "terraform-cli-persistence": {}, "ghcr.io/devcontainers/features/terraform:1": {} } + }, + "zsh_shell": { + "image": "mcr.microsoft.com/devcontainers/javascript-node:1-18", + "features": { + "terraform-cli-persistence": {}, + "ghcr.io/devcontainers/features/terraform:1": {}, + "ghcr.io/devcontainers/features/common-utils:2": { + "configureZshAsDefaultShell": true + } + } } -} +} \ No newline at end of file diff --git a/test/terraform-cli-persistence/zsh_shell.sh b/test/terraform-cli-persistence/zsh_shell.sh new file mode 100644 index 0000000..e6b8819 --- /dev/null +++ b/test/terraform-cli-persistence/zsh_shell.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# check that `terraform --help` works +check "help" bash -c "terraform --help | grep 'Usage'" + +# check that `.terraform.d` and `/dc/terraform-cli` exist under the user (should be node) +check "~/.terraform.d existence" bash -c "ls -la ~ | grep '.terraform.d'" +check "/dc/terraform-cli existence" bash -c "ls -la /dc | grep 'terraform-cli'" + +# check that the folders are owned by the user +# `stat -c "%U %G" ~/.terraform.d` returns "$USER $GROUP", in this case "node node" +# https://askubuntu.com/a/175060 +check "~/.terraform.d owned by user" bash -c "test \"$(stat -c "%U %G" ~/.terraform.d)\" = 'node node'" +check "/dc/terraform-cli owned by user" bash -c "test \"$(stat -c "%U %G" /dc/terraform-cli)\" = 'node node'" + +# Report result +reportResults From 9db83bc27fb28d864911e2bfee4793b16ef81bb0 Mon Sep 17 00:00:00 2001 From: Joshua Ji Date: Tue, 9 Jan 2024 01:13:36 +0000 Subject: [PATCH 04/22] meta: remove unnecessary remoteUser inside devcontainer.json --- .devcontainer.json | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.devcontainer.json b/.devcontainer.json index 8c6a80f..34596f9 100644 --- a/.devcontainer.json +++ b/.devcontainer.json @@ -14,12 +14,12 @@ ] }, "extensions": [ - "mads-hartmann.bash-ide-vscode", - "yzhang.markdown-all-in-one", - "github.vscode-github-actions", - "GitHub.copilot", - "foxundermoon.shell-format" - ] + "mads-hartmann.bash-ide-vscode", + "yzhang.markdown-all-in-one", + "github.vscode-github-actions", + "GitHub.copilot", + "foxundermoon.shell-format" + ] } }, "features": { @@ -27,6 +27,5 @@ "ghcr.io/devcontainers/features/github-cli:1": {}, "ghcr.io/joshuanianji/devcontainer-features/github-cli-persistence:0": {} }, - "remoteUser": "node", "updateContentCommand": "npm install -g @devcontainers/cli" } \ No newline at end of file From 0d8b5a5433fbd3c8c74e0bf140473cb33208e885 Mon Sep 17 00:00:00 2001 From: Joshua Ji Date: Tue, 9 Jan 2024 01:16:33 +0000 Subject: [PATCH 05/22] fix aws cli root user stuff --- .../devcontainer-feature.json | 2 +- src/aws-cli-persistence/install.sh | 20 +++++++++++++ test/aws-cli-persistence/default.sh | 28 +++++++++++++++++++ test/aws-cli-persistence/root_user.sh | 9 ++++++ test/aws-cli-persistence/scenarios.json | 10 ++++++- test/aws-cli-persistence/with_node.sh | 24 ++-------------- test/aws-cli-persistence/zsh_shell.sh | 21 ++------------ 7 files changed, 73 insertions(+), 41 deletions(-) create mode 100755 test/aws-cli-persistence/default.sh create mode 100644 test/aws-cli-persistence/root_user.sh diff --git a/src/aws-cli-persistence/devcontainer-feature.json b/src/aws-cli-persistence/devcontainer-feature.json index 11fcb40..dc47a80 100644 --- a/src/aws-cli-persistence/devcontainer-feature.json +++ b/src/aws-cli-persistence/devcontainer-feature.json @@ -15,5 +15,5 @@ "installsAfter": [ "ghcr.io/devcontainers/features/aws-cli" ], - "postCreateCommand": "sudo chown -R $USER:$USER /dc/aws-cli" + "postStartCommand": "/usr/local/share/aws-cli-persistence-post-create.sh" } \ No newline at end of file diff --git a/src/aws-cli-persistence/install.sh b/src/aws-cli-persistence/install.sh index a182c4a..8cb71d9 100644 --- a/src/aws-cli-persistence/install.sh +++ b/src/aws-cli-persistence/install.sh @@ -23,3 +23,23 @@ fi ln -s /dc/aws-cli "$_REMOTE_USER_HOME/.aws" # chown .aws folder chown -R "${_REMOTE_USER}:${_REMOTE_USER}" "$_REMOTE_USER_HOME/.aws" + +# --- Generate a 'aws-cli-persistence-post-create.sh' script to be executed by the 'postCreateCommand' lifecycle hook +# Looks like this is the best way to run a script in lifecycle hooks +# Source: https://github.com/devcontainers/features/blob/562305d37b97d47331d96306ffc2a0a3cce55e64/src/git-lfs/install.sh#L190C1-L190C109 +POST_CREATE_SCRIPT_PATH="/usr/local/share/aws-cli-persistence-post-create.sh" + +tee "$POST_CREATE_SCRIPT_PATH" >/dev/null \ + <<'EOF' +#!/bin/sh + +set -e + +# if the user is not root, chown /dc/aws-cli to the user +if [ "$(id -u)" != "0" ]; then + echo "Running post-start.sh for user $USER" + sudo chown -R "$USER:$USER" /dc/aws-cli +fi +EOF + +chmod 755 "$POST_CREATE_SCRIPT_PATH" diff --git a/test/aws-cli-persistence/default.sh b/test/aws-cli-persistence/default.sh new file mode 100755 index 0000000..64b7366 --- /dev/null +++ b/test/aws-cli-persistence/default.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +set -e + +# This script is the "default" test script for the aws-cli-persistence feature. +# It is not run as a scenario, but is run by other test scripts. + +# Optional: Import test library +source dev-container-features-test-lib + +# check that `aws --help` works +check "help" bash -c "aws help | grep 'usage'" + +# check that `.aws` and `/dc/aws-cli` exist under the user (should be node) +check "~/.aws existence" bash -c "ls -la ~ | grep '.aws'" +check "/dc/aws-cli existence" bash -c "ls -la /dc | grep 'aws-cli'" + +# check that the folders are owned by the user +# `stat -c "%U %G" ~/.aws` returns "$USER $GROUP", in this case "node node" +# https://askubuntu.com/a/175060 +echo "Checking ownership of ~/.aws and /dc/aws-cli (ensure it is owned by $USER)" +stat -c "%U" /dc/aws-cli + +check "~/.aws owned by user" bash -c "test \"$(stat -c "%U" ~/.aws)\" = \"$USER\"" +check "/dc/aws-cli owned by user" bash -c "test \"$(stat -c "%U" /dc/aws-cli)\" = \"$USER\"" + +# Report result +reportResults diff --git a/test/aws-cli-persistence/root_user.sh b/test/aws-cli-persistence/root_user.sh new file mode 100644 index 0000000..afeede6 --- /dev/null +++ b/test/aws-cli-persistence/root_user.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +set -e + +source dev-container-features-test-lib + +# Run default test script (in same folder) +# See: https://github.com/devcontainers/features/blob/562305d37b97d47331d96306ffc2a0a3cce55e64/test/azure-cli/install_extensions_bookworm.sh +./default.sh diff --git a/test/aws-cli-persistence/scenarios.json b/test/aws-cli-persistence/scenarios.json index 2d712a8..546ab1b 100644 --- a/test/aws-cli-persistence/scenarios.json +++ b/test/aws-cli-persistence/scenarios.json @@ -15,5 +15,13 @@ "configureZshAsDefaultShell": true } } + }, + "root_user": { + "image": "mcr.microsoft.com/devcontainers/base:debian", + "features": { + "aws-cli-persistence": {}, + "ghcr.io/devcontainers/features/aws-cli": {} + }, + "remoteUser": "root" } -} +} \ No newline at end of file diff --git a/test/aws-cli-persistence/with_node.sh b/test/aws-cli-persistence/with_node.sh index f86688e..b76d775 100644 --- a/test/aws-cli-persistence/with_node.sh +++ b/test/aws-cli-persistence/with_node.sh @@ -2,24 +2,6 @@ set -e -# Optional: Import test library -source dev-container-features-test-lib - -# check that `aws --help` works -check "help" bash -c "aws help | grep 'usage'" - -# check that `.aws` and `/dc/aws-cli` exist under the user (should be node) -check "~/.aws existence" bash -c "ls -la ~ | grep '.aws'" -check "/dc/aws-cli existence" bash -c "ls -la /dc | grep 'aws-cli'" - -# check that the folders are owned by the user -# `stat -c "%U %G" ~/.aws` returns "$USER $GROUP", in this case "node node" -# https://askubuntu.com/a/175060 -echo "Checking ownership of ~/.aws and /dc/aws-cli" -stat -c "%U %G" /dc/aws-cli - -check "~/.aws owned by user" bash -c "test \"$(stat -c "%U %G" ~/.aws)\" = 'node node'" -check "/dc/aws-cli owned by user" bash -c "test \"$(stat -c "%U %G" /dc/aws-cli)\" = 'node node'" - -# Report result -reportResults +# Run default test script (in same folder) +# See: https://github.com/devcontainers/features/blob/562305d37b97d47331d96306ffc2a0a3cce55e64/test/azure-cli/install_extensions_bookworm.sh +./default.sh diff --git a/test/aws-cli-persistence/zsh_shell.sh b/test/aws-cli-persistence/zsh_shell.sh index bd22931..b76d775 100644 --- a/test/aws-cli-persistence/zsh_shell.sh +++ b/test/aws-cli-persistence/zsh_shell.sh @@ -2,21 +2,6 @@ set -e -# Optional: Import test library -source dev-container-features-test-lib - -# check that `aws --help` works -check "help" bash -c "aws help | grep 'usage'" - -# check that `.aws` and `/dc/aws-cli` exist under the user (should be node) -check "~/.aws existence" bash -c "ls -la ~ | grep '.aws'" -check "/dc/aws-cli existence" bash -c "ls -la /dc | grep 'aws-cli'" - -# check that the folders are owned by the user -# `stat -c "%U %G" ~/.aws` returns "$USER $GROUP", in this case "node node" -# https://askubuntu.com/a/175060 -check "~/.aws owned by user" bash -c "test \"$(stat -c "%U %G" ~/.aws)\" = 'node node'" -check "/dc/aws-cli owned by user" bash -c "test \"$(stat -c "%U %G" /dc/aws-cli)\" = 'node node'" - -# Report result -reportResults +# Run default test script (in same folder) +# See: https://github.com/devcontainers/features/blob/562305d37b97d47331d96306ffc2a0a3cce55e64/test/azure-cli/install_extensions_bookworm.sh +./default.sh From 4172dde72229bd4a5489cfee0a491ce121ff23f4 Mon Sep 17 00:00:00 2001 From: Joshua Ji Date: Tue, 9 Jan 2024 01:20:24 +0000 Subject: [PATCH 06/22] Use `_default.sh` as default name --- test/aws-cli-persistence/{default.sh => _default.sh} | 1 - test/aws-cli-persistence/root_user.sh | 2 +- test/aws-cli-persistence/with_node.sh | 2 +- test/aws-cli-persistence/zsh_shell.sh | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) rename test/aws-cli-persistence/{default.sh => _default.sh} (92%) diff --git a/test/aws-cli-persistence/default.sh b/test/aws-cli-persistence/_default.sh similarity index 92% rename from test/aws-cli-persistence/default.sh rename to test/aws-cli-persistence/_default.sh index 64b7366..236e1fb 100755 --- a/test/aws-cli-persistence/default.sh +++ b/test/aws-cli-persistence/_default.sh @@ -16,7 +16,6 @@ check "~/.aws existence" bash -c "ls -la ~ | grep '.aws'" check "/dc/aws-cli existence" bash -c "ls -la /dc | grep 'aws-cli'" # check that the folders are owned by the user -# `stat -c "%U %G" ~/.aws` returns "$USER $GROUP", in this case "node node" # https://askubuntu.com/a/175060 echo "Checking ownership of ~/.aws and /dc/aws-cli (ensure it is owned by $USER)" stat -c "%U" /dc/aws-cli diff --git a/test/aws-cli-persistence/root_user.sh b/test/aws-cli-persistence/root_user.sh index afeede6..1898f45 100644 --- a/test/aws-cli-persistence/root_user.sh +++ b/test/aws-cli-persistence/root_user.sh @@ -6,4 +6,4 @@ source dev-container-features-test-lib # Run default test script (in same folder) # See: https://github.com/devcontainers/features/blob/562305d37b97d47331d96306ffc2a0a3cce55e64/test/azure-cli/install_extensions_bookworm.sh -./default.sh +./_default.sh diff --git a/test/aws-cli-persistence/with_node.sh b/test/aws-cli-persistence/with_node.sh index b76d775..1fe2fa4 100644 --- a/test/aws-cli-persistence/with_node.sh +++ b/test/aws-cli-persistence/with_node.sh @@ -4,4 +4,4 @@ set -e # Run default test script (in same folder) # See: https://github.com/devcontainers/features/blob/562305d37b97d47331d96306ffc2a0a3cce55e64/test/azure-cli/install_extensions_bookworm.sh -./default.sh +./_default.sh diff --git a/test/aws-cli-persistence/zsh_shell.sh b/test/aws-cli-persistence/zsh_shell.sh index b76d775..1fe2fa4 100644 --- a/test/aws-cli-persistence/zsh_shell.sh +++ b/test/aws-cli-persistence/zsh_shell.sh @@ -4,4 +4,4 @@ set -e # Run default test script (in same folder) # See: https://github.com/devcontainers/features/blob/562305d37b97d47331d96306ffc2a0a3cce55e64/test/azure-cli/install_extensions_bookworm.sh -./default.sh +./_default.sh From b404a700fb86e5eda3531a607cda56390cddecbc Mon Sep 17 00:00:00 2001 From: Joshua Ji Date: Tue, 9 Jan 2024 01:20:39 +0000 Subject: [PATCH 07/22] gcloud tests --- test/gcloud-cli-persistence/_default.sh | 27 ++++++++++++++++++++++ test/gcloud-cli-persistence/scenarios.json | 2 +- test/gcloud-cli-persistence/with_node.sh | 21 +++-------------- test/gcloud-cli-persistence/zsh_shell.sh | 7 ++++++ 4 files changed, 38 insertions(+), 19 deletions(-) create mode 100644 test/gcloud-cli-persistence/_default.sh diff --git a/test/gcloud-cli-persistence/_default.sh b/test/gcloud-cli-persistence/_default.sh new file mode 100644 index 0000000..c6d5231 --- /dev/null +++ b/test/gcloud-cli-persistence/_default.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +set -e + +# This is the default test script that tests everything +# It is not run as a scenario, but is run by other test scripts. + +# Optional: Import test library +source dev-container-features-test-lib + +# check that `gcloud --help` works +check "help" bash -c "gcloud --help | grep 'NAME'" + +# check that `.config/gcloud` and `/dc/gcloud-cli` exist under the user (should be node) +check "config" bash -c "ls -la ~/.config | grep 'gcloud'" +check "dc" bash -c "ls -la /dc | grep 'gcloud-cli'" + +# check that the folders are owned by the user +# https://askubuntu.com/a/175060 +echo "Checking ownership of ~/.config/gcloud and /dc/gcloud-cli (ensure it is owned by $USER)" +stat -c "%U" /dc/gcloud-cli + +check "~/.config/gloud owned by user" bash -c "test \"$(stat -c "%U" ~/.config/gcloud)\" = $USER" +check "/dc/gcloud-cli owned by user" bash -c "test \"$(stat -c "%U" /dc/gcloud-cli)\" = $USER" + +# Report result +reportResults diff --git a/test/gcloud-cli-persistence/scenarios.json b/test/gcloud-cli-persistence/scenarios.json index 9c1017b..91fd152 100644 --- a/test/gcloud-cli-persistence/scenarios.json +++ b/test/gcloud-cli-persistence/scenarios.json @@ -7,7 +7,7 @@ } }, "zsh_shell": { - "image": "mcr.microsoft.com/devcontainers/javascript-node:1-18", + "image": "mcr.microsoft.com/devcontainers/base:debian", "features": { "gcloud-cli-persistence": {}, "ghcr.io/dhoeric/features/google-cloud-cli": {}, diff --git a/test/gcloud-cli-persistence/with_node.sh b/test/gcloud-cli-persistence/with_node.sh index ba526cd..1fe2fa4 100644 --- a/test/gcloud-cli-persistence/with_node.sh +++ b/test/gcloud-cli-persistence/with_node.sh @@ -2,21 +2,6 @@ set -e -# Optional: Import test library -source dev-container-features-test-lib - -# check that `gcloud --help` works -check "help" bash -c "gcloud --help | grep 'NAME'" - -# check that `.config/gcloud` and `/dc/gcloud-cli` exist under the user (should be node) -check "config" bash -c "ls -la ~/.config | grep 'gcloud'" -check "dc" bash -c "ls -la /dc | grep 'gcloud-cli'" - -# check that the folders are owned by the user -# `stat -c "%U %G" ~/.config` returns "$USER $GROUP", in this case "node node" -# https://askubuntu.com/a/175060 -check "~/.config/gloud owned by user" bash -c "test \"$(stat -c "%U %G" ~/.config/gcloud)\" = 'node node'" -check "/dc/gcloud-cli owned by user" bash -c "test \"$(stat -c "%U %G" /dc/gcloud-cli)\" = 'node node'" - -# Report result -reportResults +# Run default test script (in same folder) +# See: https://github.com/devcontainers/features/blob/562305d37b97d47331d96306ffc2a0a3cce55e64/test/azure-cli/install_extensions_bookworm.sh +./_default.sh diff --git a/test/gcloud-cli-persistence/zsh_shell.sh b/test/gcloud-cli-persistence/zsh_shell.sh index e69de29..1fe2fa4 100644 --- a/test/gcloud-cli-persistence/zsh_shell.sh +++ b/test/gcloud-cli-persistence/zsh_shell.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +set -e + +# Run default test script (in same folder) +# See: https://github.com/devcontainers/features/blob/562305d37b97d47331d96306ffc2a0a3cce55e64/test/azure-cli/install_extensions_bookworm.sh +./_default.sh From f2b75092cc589868a1a8a7df7a7afe8ed537693b Mon Sep 17 00:00:00 2001 From: Joshua Ji Date: Tue, 9 Jan 2024 01:33:24 +0000 Subject: [PATCH 08/22] Finish refactoring all tests --- test/aws-cli-persistence/_default.sh | 4 ++-- test/github-cli-persistence/_default.sh | 22 ++++++++++++++++++ test/github-cli-persistence/with_node.sh | 21 +++-------------- test/github-cli-persistence/zsh_shell.sh | 21 +++-------------- test/mount-pnpm-store/_default.sh | 22 ++++++++++++++++++ test/mount-pnpm-store/with_node.sh | 16 +------------ test/mount-pnpm-store/with_pnpm.sh | 16 ++----------- test/mount-pnpm-store/zsh_shell.sh | 14 +----------- test/terraform-cli-persistence/_default.sh | 25 +++++++++++++++++++++ test/terraform-cli-persistence/with_node.sh | 19 +--------------- test/terraform-cli-persistence/zsh_shell.sh | 19 +--------------- 11 files changed, 83 insertions(+), 116 deletions(-) create mode 100644 test/github-cli-persistence/_default.sh create mode 100644 test/mount-pnpm-store/_default.sh create mode 100644 test/terraform-cli-persistence/_default.sh diff --git a/test/aws-cli-persistence/_default.sh b/test/aws-cli-persistence/_default.sh index 236e1fb..f7172c2 100755 --- a/test/aws-cli-persistence/_default.sh +++ b/test/aws-cli-persistence/_default.sh @@ -20,8 +20,8 @@ check "/dc/aws-cli existence" bash -c "ls -la /dc | grep 'aws-cli'" echo "Checking ownership of ~/.aws and /dc/aws-cli (ensure it is owned by $USER)" stat -c "%U" /dc/aws-cli -check "~/.aws owned by user" bash -c "test \"$(stat -c "%U" ~/.aws)\" = \"$USER\"" -check "/dc/aws-cli owned by user" bash -c "test \"$(stat -c "%U" /dc/aws-cli)\" = \"$USER\"" +check "~/.aws owned by user" bash -c "test \"$(stat -c "%U" ~/.aws)\" = $USER" +check "/dc/aws-cli owned by user" bash -c "test \"$(stat -c "%U" /dc/aws-cli)\" = $USER" # Report result reportResults diff --git a/test/github-cli-persistence/_default.sh b/test/github-cli-persistence/_default.sh new file mode 100644 index 0000000..c64a112 --- /dev/null +++ b/test/github-cli-persistence/_default.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# check that `gh --help` works +check "help" bash -c "gh --help | grep 'USAGE'" + +# check that `.config/gh` and `/dc/github-cli` exist under the user (should be node) +check "config" bash -c "ls -la ~/.config | grep 'gh'" +check "dc" bash -c "ls -la /dc | grep 'github-cli'" + +# check that the folders are owned by the user +# `stat -c "%U %G" ~/.config` returns "$USER $GROUP", in this case "node node" +# https://askubuntu.com/a/175060 +check "~/.config/gh owned by user" bash -c "test \"$(stat -c "%U %G" ~/.config)\" = $USER" +check "/dc/github-cli owned by user" bash -c "test \"$(stat -c "%U %G" /dc/github-cli)\" = $USER" + +# Report result +reportResults diff --git a/test/github-cli-persistence/with_node.sh b/test/github-cli-persistence/with_node.sh index c55f121..1fe2fa4 100644 --- a/test/github-cli-persistence/with_node.sh +++ b/test/github-cli-persistence/with_node.sh @@ -2,21 +2,6 @@ set -e -# Optional: Import test library -source dev-container-features-test-lib - -# check that `gh --help` works -check "help" bash -c "gh --help | grep 'USAGE'" - -# check that `.config/gh` and `/dc/github-cli` exist under the user (should be node) -check "config" bash -c "ls -la ~/.config | grep 'gh'" -check "dc" bash -c "ls -la /dc | grep 'github-cli'" - -# check that the folders are owned by the user -# `stat -c "%U %G" ~/.config` returns "$USER $GROUP", in this case "node node" -# https://askubuntu.com/a/175060 -check "~/.config/gh owned by user" bash -c "test \"$(stat -c "%U %G" ~/.config)\" = 'node node'" -check "/dc/github-cli owned by user" bash -c "test \"$(stat -c "%U %G" /dc/github-cli)\" = 'node node'" - -# Report result -reportResults +# Run default test script (in same folder) +# See: https://github.com/devcontainers/features/blob/562305d37b97d47331d96306ffc2a0a3cce55e64/test/azure-cli/install_extensions_bookworm.sh +./_default.sh diff --git a/test/github-cli-persistence/zsh_shell.sh b/test/github-cli-persistence/zsh_shell.sh index c55f121..1fe2fa4 100644 --- a/test/github-cli-persistence/zsh_shell.sh +++ b/test/github-cli-persistence/zsh_shell.sh @@ -2,21 +2,6 @@ set -e -# Optional: Import test library -source dev-container-features-test-lib - -# check that `gh --help` works -check "help" bash -c "gh --help | grep 'USAGE'" - -# check that `.config/gh` and `/dc/github-cli` exist under the user (should be node) -check "config" bash -c "ls -la ~/.config | grep 'gh'" -check "dc" bash -c "ls -la /dc | grep 'github-cli'" - -# check that the folders are owned by the user -# `stat -c "%U %G" ~/.config` returns "$USER $GROUP", in this case "node node" -# https://askubuntu.com/a/175060 -check "~/.config/gh owned by user" bash -c "test \"$(stat -c "%U %G" ~/.config)\" = 'node node'" -check "/dc/github-cli owned by user" bash -c "test \"$(stat -c "%U %G" /dc/github-cli)\" = 'node node'" - -# Report result -reportResults +# Run default test script (in same folder) +# See: https://github.com/devcontainers/features/blob/562305d37b97d47331d96306ffc2a0a3cce55e64/test/azure-cli/install_extensions_bookworm.sh +./_default.sh diff --git a/test/mount-pnpm-store/_default.sh b/test/mount-pnpm-store/_default.sh new file mode 100644 index 0000000..8d276e5 --- /dev/null +++ b/test/mount-pnpm-store/_default.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +set -e + +# Default test script that tests everything +# It is not run as a scenario, but is run by other test scripts. + +# Optional: Import test library +source dev-container-features-test-lib + +# user is `node` in dev container + +echo "User: $(whoami)" +pnpm config list + +# check that `pnpm config get store-dir` equals ~/.pnpm-store +pnpmConfig=$(pnpm config get store-dir) +echo "pnpm config get store-dir: '$pnpmConfig'" +check "config" test $pnpmConfig = "$(echo ~)/.pnpm-store" + +# Report result +reportResults diff --git a/test/mount-pnpm-store/with_node.sh b/test/mount-pnpm-store/with_node.sh index b20456b..2f6c9ea 100644 --- a/test/mount-pnpm-store/with_node.sh +++ b/test/mount-pnpm-store/with_node.sh @@ -4,18 +4,4 @@ set -e # tests installing pnpm mount when pnpm is already installed in the base image -# Optional: Import test library -source dev-container-features-test-lib - -# user is `node` in dev container - -echo "User: $(whoami)" -pnpm config list - -# check that `pnpm config get store-dir` equals /home/node/.pnpm-store -pnpmConfig=$(pnpm config get store-dir) -echo "pnpm config get store-dir: '$pnpmConfig'" -check "config" test $pnpmConfig = "/home/node/.pnpm-store" - -# Report result -reportResults +./_default.sh diff --git a/test/mount-pnpm-store/with_pnpm.sh b/test/mount-pnpm-store/with_pnpm.sh index b55cb7a..e9d42a7 100644 --- a/test/mount-pnpm-store/with_pnpm.sh +++ b/test/mount-pnpm-store/with_pnpm.sh @@ -2,18 +2,6 @@ set -e -# tests installing pnpm with a feature +# tests installing pnpm through a feature -# Optional: Import test library -source dev-container-features-test-lib - -echo "User: $(whoami)" -pnpm config list - -# check that `pnpm config get store-dir` returns /home/vscode/.pnpm-store -pnpmConfig=$(pnpm config get store-dir) -echo "pnpm config get store-dir: '$pnpmConfig'" -check "config" test $pnpmConfig = "/home/vscode/.pnpm-store" - -# Report result -reportResults +./_default.sh diff --git a/test/mount-pnpm-store/zsh_shell.sh b/test/mount-pnpm-store/zsh_shell.sh index 5694530..ace33be 100644 --- a/test/mount-pnpm-store/zsh_shell.sh +++ b/test/mount-pnpm-store/zsh_shell.sh @@ -4,16 +4,4 @@ set -e # tests installing pnpm after zsh shell -# Optional: Import test library -source dev-container-features-test-lib - -echo "User: $(whoami)" -pnpm config list - -# check that `pnpm config get store-dir` returns /home/vscode/.pnpm-store -pnpmConfig=$(pnpm config get store-dir) -echo "pnpm config get store-dir: '$pnpmConfig'" -check "config" test $pnpmConfig = "/home/vscode/.pnpm-store" - -# Report result -reportResults +./_default.sh diff --git a/test/terraform-cli-persistence/_default.sh b/test/terraform-cli-persistence/_default.sh new file mode 100644 index 0000000..baea4a8 --- /dev/null +++ b/test/terraform-cli-persistence/_default.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +set -e + +# Default test script that tests everything +# It is not run as a scenario, but is run by other test scripts. + +# Optional: Import test library +source dev-container-features-test-lib + +# check that `terraform --help` works +check "help" bash -c "terraform --help | grep 'Usage'" + +# check that `.terraform.d` and `/dc/terraform-cli` exist under the user (should be node) +check "~/.terraform.d existence" bash -c "ls -la ~ | grep '.terraform.d'" +check "/dc/terraform-cli existence" bash -c "ls -la /dc | grep 'terraform-cli'" + +# check that the folders are owned by the user +# `stat -c "%U %G" ~/.terraform.d` returns "$USER $GROUP", in this case "node node" +# https://askubuntu.com/a/175060 +check "~/.terraform.d owned by user" bash -c "test \"$(stat -c "%U %G" ~/.terraform.d)\" = 'node node'" +check "/dc/terraform-cli owned by user" bash -c "test \"$(stat -c "%U %G" /dc/terraform-cli)\" = 'node node'" + +# Report result +reportResults diff --git a/test/terraform-cli-persistence/with_node.sh b/test/terraform-cli-persistence/with_node.sh index e6b8819..9bbf662 100644 --- a/test/terraform-cli-persistence/with_node.sh +++ b/test/terraform-cli-persistence/with_node.sh @@ -2,21 +2,4 @@ set -e -# Optional: Import test library -source dev-container-features-test-lib - -# check that `terraform --help` works -check "help" bash -c "terraform --help | grep 'Usage'" - -# check that `.terraform.d` and `/dc/terraform-cli` exist under the user (should be node) -check "~/.terraform.d existence" bash -c "ls -la ~ | grep '.terraform.d'" -check "/dc/terraform-cli existence" bash -c "ls -la /dc | grep 'terraform-cli'" - -# check that the folders are owned by the user -# `stat -c "%U %G" ~/.terraform.d` returns "$USER $GROUP", in this case "node node" -# https://askubuntu.com/a/175060 -check "~/.terraform.d owned by user" bash -c "test \"$(stat -c "%U %G" ~/.terraform.d)\" = 'node node'" -check "/dc/terraform-cli owned by user" bash -c "test \"$(stat -c "%U %G" /dc/terraform-cli)\" = 'node node'" - -# Report result -reportResults +./_default.sh diff --git a/test/terraform-cli-persistence/zsh_shell.sh b/test/terraform-cli-persistence/zsh_shell.sh index e6b8819..9bbf662 100644 --- a/test/terraform-cli-persistence/zsh_shell.sh +++ b/test/terraform-cli-persistence/zsh_shell.sh @@ -2,21 +2,4 @@ set -e -# Optional: Import test library -source dev-container-features-test-lib - -# check that `terraform --help` works -check "help" bash -c "terraform --help | grep 'Usage'" - -# check that `.terraform.d` and `/dc/terraform-cli` exist under the user (should be node) -check "~/.terraform.d existence" bash -c "ls -la ~ | grep '.terraform.d'" -check "/dc/terraform-cli existence" bash -c "ls -la /dc | grep 'terraform-cli'" - -# check that the folders are owned by the user -# `stat -c "%U %G" ~/.terraform.d` returns "$USER $GROUP", in this case "node node" -# https://askubuntu.com/a/175060 -check "~/.terraform.d owned by user" bash -c "test \"$(stat -c "%U %G" ~/.terraform.d)\" = 'node node'" -check "/dc/terraform-cli owned by user" bash -c "test \"$(stat -c "%U %G" /dc/terraform-cli)\" = 'node node'" - -# Report result -reportResults +./_default.sh From a24ea99105d4fc1557f3a93b1af63246d977c40b Mon Sep 17 00:00:00 2001 From: Joshua Ji Date: Tue, 9 Jan 2024 01:33:45 +0000 Subject: [PATCH 09/22] Use custom scripts for postCreateCommand --- .../devcontainer-feature.json | 2 +- src/aws-cli-persistence/install.sh | 22 ++++++------ .../devcontainer-feature.json | 2 +- src/gcloud-cli-persistence/install.sh | 24 ++++++++++++- .../devcontainer-feature.json | 2 +- src/github-cli-persistence/install.sh | 36 +++++++++++++++---- .../devcontainer-feature.json | 2 +- src/mount-pnpm-store/install.sh | 24 ++++++++++++- .../devcontainer-feature.json | 2 +- src/terraform-cli-persistence/install.sh | 36 +++++++++++++++---- 10 files changed, 121 insertions(+), 31 deletions(-) diff --git a/src/aws-cli-persistence/devcontainer-feature.json b/src/aws-cli-persistence/devcontainer-feature.json index dc47a80..ac12178 100644 --- a/src/aws-cli-persistence/devcontainer-feature.json +++ b/src/aws-cli-persistence/devcontainer-feature.json @@ -15,5 +15,5 @@ "installsAfter": [ "ghcr.io/devcontainers/features/aws-cli" ], - "postStartCommand": "/usr/local/share/aws-cli-persistence-post-create.sh" + "postCreateCommand": "/usr/local/share/aws-cli-persistence-post-create.sh" } \ No newline at end of file diff --git a/src/aws-cli-persistence/install.sh b/src/aws-cli-persistence/install.sh index 8cb71d9..bf51027 100644 --- a/src/aws-cli-persistence/install.sh +++ b/src/aws-cli-persistence/install.sh @@ -1,14 +1,16 @@ #!/bin/sh set -e -echo "Activating feature 'aws-cli-persistence'" +FEATURE_ID="aws-cli-persistence" + +echo "Activating feature '$FEATURE_ID'" echo "User: ${_REMOTE_USER} User home: ${_REMOTE_USER_HOME}" if [ -z "$_REMOTE_USER" ] || [ -z "$_REMOTE_USER_HOME" ]; then - echo "***********************************************************************************" - echo "*** Require _REMOTE_USER and _REMOTE_USER_HOME to be set (by dev container CLI) ***" - echo "***********************************************************************************" - exit 1 + echo "***********************************************************************************" + echo "*** Require _REMOTE_USER and _REMOTE_USER_HOME to be set (by dev container CLI) ***" + echo "***********************************************************************************" + exit 1 fi # make /dc/aws-cli folder if doesn't exist @@ -16,21 +18,21 @@ mkdir -p "/dc/aws-cli" # as to why we move around the folder, check `github-cli-persistence/install.sh` if [ -e "$_REMOTE_USER_HOME/.aws" ]; then - echo "Moving existing .aws folder to .aws-old" - mv "$_REMOTE_USER_HOME/.aws" "$_REMOTE_USER_HOME/.aws-old" + echo "Moving existing .aws folder to .aws-old" + mv "$_REMOTE_USER_HOME/.aws" "$_REMOTE_USER_HOME/.aws-old" fi ln -s /dc/aws-cli "$_REMOTE_USER_HOME/.aws" # chown .aws folder chown -R "${_REMOTE_USER}:${_REMOTE_USER}" "$_REMOTE_USER_HOME/.aws" -# --- Generate a 'aws-cli-persistence-post-create.sh' script to be executed by the 'postCreateCommand' lifecycle hook +# --- Generate a '$FEATURE_ID-post-create.sh' script to be executed by the 'postCreateCommand' lifecycle hook # Looks like this is the best way to run a script in lifecycle hooks # Source: https://github.com/devcontainers/features/blob/562305d37b97d47331d96306ffc2a0a3cce55e64/src/git-lfs/install.sh#L190C1-L190C109 -POST_CREATE_SCRIPT_PATH="/usr/local/share/aws-cli-persistence-post-create.sh" +POST_CREATE_SCRIPT_PATH="/usr/local/share/$FEATURE_ID-post-create.sh" tee "$POST_CREATE_SCRIPT_PATH" >/dev/null \ - <<'EOF' + <<'EOF' #!/bin/sh set -e diff --git a/src/gcloud-cli-persistence/devcontainer-feature.json b/src/gcloud-cli-persistence/devcontainer-feature.json index 35fb445..ac238da 100644 --- a/src/gcloud-cli-persistence/devcontainer-feature.json +++ b/src/gcloud-cli-persistence/devcontainer-feature.json @@ -15,5 +15,5 @@ "installsAfter": [ "ghcr.io/dhoeric/features/google-cloud-cli" ], - "postCreateCommand": "sudo chown -R $USER:$USER /dc/aws-cli" + "postCreateCommand": "/usr/local/share/gcloud-cli-persistence-post-create.sh" } \ No newline at end of file diff --git a/src/gcloud-cli-persistence/install.sh b/src/gcloud-cli-persistence/install.sh index 72cd96d..16cb04f 100644 --- a/src/gcloud-cli-persistence/install.sh +++ b/src/gcloud-cli-persistence/install.sh @@ -1,7 +1,9 @@ #!/bin/sh set -e -echo "Activating feature 'gcloud-cli-persistence'" +FEATURE_ID="gcloud-cli-persistence" + +echo "Activating feature '$FEATURE_ID'" echo "User: ${_REMOTE_USER} User home: ${_REMOTE_USER_HOME}" if [ -z "$_REMOTE_USER" ] || [ -z "$_REMOTE_USER_HOME" ]; then @@ -27,3 +29,23 @@ ln -s /dc/gcloud-cli "$_REMOTE_USER_HOME/.config/gcloud" # chown the entire `.config` folder because devcontainers creates # a `~/.config/vscode-dev-containers` folder later on chown -R "${_REMOTE_USER}:${_REMOTE_USER}" "$_REMOTE_USER_HOME/.config" + +# --- Generate a '$FEATURE_ID-post-create.sh' script to be executed by the 'postCreateCommand' lifecycle hook +# Looks like this is the best way to run a script in lifecycle hooks +# Source: https://github.com/devcontainers/features/blob/562305d37b97d47331d96306ffc2a0a3cce55e64/src/git-lfs/install.sh#L190C1-L190C109 +POST_CREATE_SCRIPT_PATH="/usr/local/share/$FEATURE_ID-post-create.sh" + +tee "$POST_CREATE_SCRIPT_PATH" >/dev/null \ + <<'EOF' +#!/bin/sh + +set -e + +# if the user is not root, chown /dc/aws-cli to the user +if [ "$(id -u)" != "0" ]; then + echo "Running post-start.sh for user $USER" + sudo chown -R "$USER:$USER" /dc/gcloud-cli +fi +EOF + +chmod 755 "$POST_CREATE_SCRIPT_PATH" diff --git a/src/github-cli-persistence/devcontainer-feature.json b/src/github-cli-persistence/devcontainer-feature.json index 8717ebc..5227419 100644 --- a/src/github-cli-persistence/devcontainer-feature.json +++ b/src/github-cli-persistence/devcontainer-feature.json @@ -15,5 +15,5 @@ "installsAfter": [ "ghcr.io/devcontainers/features/github-cli" ], - "postCreateCommand": "sudo chown -R $USER:$USER /dc/github-cli" + "postCreateCommand": "/usr/local/share/github-cli-persistence-post-create.sh" } \ No newline at end of file diff --git a/src/github-cli-persistence/install.sh b/src/github-cli-persistence/install.sh index 2fa7748..9427170 100644 --- a/src/github-cli-persistence/install.sh +++ b/src/github-cli-persistence/install.sh @@ -1,14 +1,16 @@ #!/bin/sh set -e -echo "Activating feature 'github-cli-persistence'" +FEATURE_ID="gcloud-cli-persistence" + +echo "Activating feature '$FEATURE_ID'" echo "User: ${_REMOTE_USER} User home: ${_REMOTE_USER_HOME}" if [ -z "$_REMOTE_USER" ] || [ -z "$_REMOTE_USER_HOME" ]; then - echo "***********************************************************************************" - echo "*** Require _REMOTE_USER and _REMOTE_USER_HOME to be set (by dev container CLI) ***" - echo "***********************************************************************************" - exit 1 + echo "***********************************************************************************" + echo "*** Require _REMOTE_USER and _REMOTE_USER_HOME to be set (by dev container CLI) ***" + echo "***********************************************************************************" + exit 1 fi # make ~/.config folder if doesn't exist @@ -19,11 +21,31 @@ mkdir -p "/dc/github-cli" # folder *inside* `.config/gh` that symlinks to `github-cli` # Thus, we want to make sure the folder does NOT exist so the symlink will actually be to ~/.config/gh if [ -e "$_REMOTE_USER_HOME/.config/gh" ]; then - echo "Moving existing gh folder to gh-old" - mv "$_REMOTE_USER_HOME/.config/gh" "$_REMOTE_USER_HOME/.config/gh-old" + echo "Moving existing gh folder to gh-old" + mv "$_REMOTE_USER_HOME/.config/gh" "$_REMOTE_USER_HOME/.config/gh-old" fi ln -s /dc/github-cli "$_REMOTE_USER_HOME/.config/gh" # chown the entire `.config` folder because devcontainers creates # a `~/.config/vscode-dev-containers` folder later on chown -R "${_REMOTE_USER}:${_REMOTE_USER}" "$_REMOTE_USER_HOME/.config" + +# --- Generate a '$FEATURE_ID-post-create.sh' script to be executed by the 'postCreateCommand' lifecycle hook +# Looks like this is the best way to run a script in lifecycle hooks +# Source: https://github.com/devcontainers/features/blob/562305d37b97d47331d96306ffc2a0a3cce55e64/src/git-lfs/install.sh#L190C1-L190C109 +POST_CREATE_SCRIPT_PATH="/usr/local/share/$FEATURE_ID-post-create.sh" + +tee "$POST_CREATE_SCRIPT_PATH" >/dev/null \ + <<'EOF' +#!/bin/sh + +set -e + +# if the user is not root, chown /dc/aws-cli to the user +if [ "$(id -u)" != "0" ]; then + echo "Running post-start.sh for user $USER" + sudo chown -R "$USER:$USER" /dc/github-cli +fi +EOF + +chmod 755 "$POST_CREATE_SCRIPT_PATH" diff --git a/src/mount-pnpm-store/devcontainer-feature.json b/src/mount-pnpm-store/devcontainer-feature.json index 5d2f73f..7d27afb 100644 --- a/src/mount-pnpm-store/devcontainer-feature.json +++ b/src/mount-pnpm-store/devcontainer-feature.json @@ -15,5 +15,5 @@ "installsAfter": [ "ghcr.io/devcontainers/features/node" ], - "postCreateCommand": "sudo chown -R $USER:$USER /dc/mounted-pnpm-store" + "postCreateCommand": "/usr/local/share/mount-pnpm-store-post-create.sh" } \ No newline at end of file diff --git a/src/mount-pnpm-store/install.sh b/src/mount-pnpm-store/install.sh index 23b79dd..e180de8 100644 --- a/src/mount-pnpm-store/install.sh +++ b/src/mount-pnpm-store/install.sh @@ -1,7 +1,9 @@ #!/bin/sh set -e -echo "Activating feature 'mount-pnpm-store'" +FEATURE_ID="gcloud-cli-persistence" + +echo "Activating feature '$FEATURE_ID'" echo "User: ${_REMOTE_USER} User home: ${_REMOTE_USER_HOME}" if [ -z "$_REMOTE_USER" ] || [ -z "$_REMOTE_USER_HOME" ]; then @@ -34,3 +36,23 @@ else echo "WARN: pnpm is not installed! Please ensure pnpm is installed and in your PATH." echo "WARN: pnpm store location will not be set." fi + +# --- Generate a '$FEATURE_ID-post-create.sh' script to be executed by the 'postCreateCommand' lifecycle hook +# Looks like this is the best way to run a script in lifecycle hooks +# Source: https://github.com/devcontainers/features/blob/562305d37b97d47331d96306ffc2a0a3cce55e64/src/git-lfs/install.sh#L190C1-L190C109 +POST_CREATE_SCRIPT_PATH="/usr/local/share/$FEATURE_ID-post-create.sh" + +tee "$POST_CREATE_SCRIPT_PATH" >/dev/null \ + <<'EOF' +#!/bin/sh + +set -e + +# if the user is not root, chown /dc/aws-cli to the user +if [ "$(id -u)" != "0" ]; then + echo "Running post-start.sh for user $USER" + sudo chown -R "$USER:$USER" /dc/mounted-pnpm-store +fi +EOF + +chmod 755 "$POST_CREATE_SCRIPT_PATH" diff --git a/src/terraform-cli-persistence/devcontainer-feature.json b/src/terraform-cli-persistence/devcontainer-feature.json index e6b0789..0f852eb 100644 --- a/src/terraform-cli-persistence/devcontainer-feature.json +++ b/src/terraform-cli-persistence/devcontainer-feature.json @@ -15,5 +15,5 @@ "installsAfter": [ "ghcr.io/devcontainers/features/terraform" ], - "postCreateCommand": "sudo chown -R $USER:$USER /dc/terraform-cli" + "postCreateCommand": "/usr/local/share/terraform-cli-persistence-post-create.sh" } \ No newline at end of file diff --git a/src/terraform-cli-persistence/install.sh b/src/terraform-cli-persistence/install.sh index 8eba89b..22a7ed1 100644 --- a/src/terraform-cli-persistence/install.sh +++ b/src/terraform-cli-persistence/install.sh @@ -1,14 +1,16 @@ #!/bin/sh set -e -echo "Activating feature 'terraform-cli-persistence'" +FEATURE_ID="gcloud-cli-persistence" + +echo "Activating feature '$FEATURE_ID'" echo "User: ${_REMOTE_USER} User home: ${_REMOTE_USER_HOME}" if [ -z "$_REMOTE_USER" ] || [ -z "$_REMOTE_USER_HOME" ]; then - echo "***********************************************************************************" - echo "*** Require _REMOTE_USER and _REMOTE_USER_HOME to be set (by dev container CLI) ***" - echo "***********************************************************************************" - exit 1 + echo "***********************************************************************************" + echo "*** Require _REMOTE_USER and _REMOTE_USER_HOME to be set (by dev container CLI) ***" + echo "***********************************************************************************" + exit 1 fi # make /dc/terraform-cli folder if doesn't exist @@ -16,11 +18,31 @@ mkdir -p "/dc/terraform-cli" # as to why we move around the folder, check `github-cli-persistence/install.sh` if [ -e "$_REMOTE_USER_HOME/.terraform.d" ]; then - echo "Moving existing .terraform.d folder to .terraform.d-old" - mv "$_REMOTE_USER_HOME/.terraform.d" "$_REMOTE_USER_HOME/.terraform.d-old" + echo "Moving existing .terraform.d folder to .terraform.d-old" + mv "$_REMOTE_USER_HOME/.terraform.d" "$_REMOTE_USER_HOME/.terraform.d-old" fi ln -s /dc/terraform-cli "$_REMOTE_USER_HOME/.terraform.d" # chown the entire `.config` folder because devcontainers creates # a `~/.config/vscode-dev-containers` folder later on chown -R "${_REMOTE_USER}:${_REMOTE_USER}" "$_REMOTE_USER_HOME/.terraform.d" + +# --- Generate a '$FEATURE_ID-post-create.sh' script to be executed by the 'postCreateCommand' lifecycle hook +# Looks like this is the best way to run a script in lifecycle hooks +# Source: https://github.com/devcontainers/features/blob/562305d37b97d47331d96306ffc2a0a3cce55e64/src/git-lfs/install.sh#L190C1-L190C109 +POST_CREATE_SCRIPT_PATH="/usr/local/share/$FEATURE_ID-post-create.sh" + +tee "$POST_CREATE_SCRIPT_PATH" >/dev/null \ + <<'EOF' +#!/bin/sh + +set -e + +# if the user is not root, chown /dc/aws-cli to the user +if [ "$(id -u)" != "0" ]; then + echo "Running post-start.sh for user $USER" + sudo chown -R "$USER:$USER" /dc/terraform-cli +fi +EOF + +chmod 755 "$POST_CREATE_SCRIPT_PATH" From 6b7f35fa9de64a5c5d8853726bbe19154662aed5 Mon Sep 17 00:00:00 2001 From: Joshua Ji Date: Tue, 9 Jan 2024 01:36:04 +0000 Subject: [PATCH 10/22] fix FEATURE_ID env vars --- src/github-cli-persistence/install.sh | 2 +- src/mount-pnpm-store/install.sh | 2 +- src/terraform-cli-persistence/install.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/github-cli-persistence/install.sh b/src/github-cli-persistence/install.sh index 9427170..6811fcc 100644 --- a/src/github-cli-persistence/install.sh +++ b/src/github-cli-persistence/install.sh @@ -1,7 +1,7 @@ #!/bin/sh set -e -FEATURE_ID="gcloud-cli-persistence" +FEATURE_ID="github-cli-persistence" echo "Activating feature '$FEATURE_ID'" echo "User: ${_REMOTE_USER} User home: ${_REMOTE_USER_HOME}" diff --git a/src/mount-pnpm-store/install.sh b/src/mount-pnpm-store/install.sh index e180de8..0439861 100644 --- a/src/mount-pnpm-store/install.sh +++ b/src/mount-pnpm-store/install.sh @@ -1,7 +1,7 @@ #!/bin/sh set -e -FEATURE_ID="gcloud-cli-persistence" +FEATURE_ID="mount-pnpm-store" echo "Activating feature '$FEATURE_ID'" echo "User: ${_REMOTE_USER} User home: ${_REMOTE_USER_HOME}" diff --git a/src/terraform-cli-persistence/install.sh b/src/terraform-cli-persistence/install.sh index 22a7ed1..93cf38a 100644 --- a/src/terraform-cli-persistence/install.sh +++ b/src/terraform-cli-persistence/install.sh @@ -1,7 +1,7 @@ #!/bin/sh set -e -FEATURE_ID="gcloud-cli-persistence" +FEATURE_ID="terraform-cli-persistence" echo "Activating feature '$FEATURE_ID'" echo "User: ${_REMOTE_USER} User home: ${_REMOTE_USER_HOME}" From 4584c9a1cfd36bc17b29c92771cafd465631df76 Mon Sep 17 00:00:00 2001 From: Joshua Ji Date: Tue, 9 Jan 2024 01:51:46 +0000 Subject: [PATCH 11/22] Fix some tests --- src/github-cli-persistence/install.sh | 3 +-- test/aws-cli-persistence/_default.sh | 1 - test/gcloud-cli-persistence/_default.sh | 1 - test/github-cli-persistence/_default.sh | 7 ++++--- test/mount-pnpm-store/_default.sh | 6 ++++++ test/terraform-cli-persistence/_default.sh | 7 ++++--- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/github-cli-persistence/install.sh b/src/github-cli-persistence/install.sh index 6811fcc..7e2ce95 100644 --- a/src/github-cli-persistence/install.sh +++ b/src/github-cli-persistence/install.sh @@ -27,8 +27,7 @@ fi ln -s /dc/github-cli "$_REMOTE_USER_HOME/.config/gh" # chown the entire `.config` folder because devcontainers creates -# a `~/.config/vscode-dev-containers` folder later on -chown -R "${_REMOTE_USER}:${_REMOTE_USER}" "$_REMOTE_USER_HOME/.config" +chown -R "${_REMOTE_USER}:${_REMOTE_USER}" "$_REMOTE_USER_HOME/.config/gh" # --- Generate a '$FEATURE_ID-post-create.sh' script to be executed by the 'postCreateCommand' lifecycle hook # Looks like this is the best way to run a script in lifecycle hooks diff --git a/test/aws-cli-persistence/_default.sh b/test/aws-cli-persistence/_default.sh index f7172c2..a1295c1 100755 --- a/test/aws-cli-persistence/_default.sh +++ b/test/aws-cli-persistence/_default.sh @@ -18,7 +18,6 @@ check "/dc/aws-cli existence" bash -c "ls -la /dc | grep 'aws-cli'" # check that the folders are owned by the user # https://askubuntu.com/a/175060 echo "Checking ownership of ~/.aws and /dc/aws-cli (ensure it is owned by $USER)" -stat -c "%U" /dc/aws-cli check "~/.aws owned by user" bash -c "test \"$(stat -c "%U" ~/.aws)\" = $USER" check "/dc/aws-cli owned by user" bash -c "test \"$(stat -c "%U" /dc/aws-cli)\" = $USER" diff --git a/test/gcloud-cli-persistence/_default.sh b/test/gcloud-cli-persistence/_default.sh index c6d5231..9bc0e63 100644 --- a/test/gcloud-cli-persistence/_default.sh +++ b/test/gcloud-cli-persistence/_default.sh @@ -18,7 +18,6 @@ check "dc" bash -c "ls -la /dc | grep 'gcloud-cli'" # check that the folders are owned by the user # https://askubuntu.com/a/175060 echo "Checking ownership of ~/.config/gcloud and /dc/gcloud-cli (ensure it is owned by $USER)" -stat -c "%U" /dc/gcloud-cli check "~/.config/gloud owned by user" bash -c "test \"$(stat -c "%U" ~/.config/gcloud)\" = $USER" check "/dc/gcloud-cli owned by user" bash -c "test \"$(stat -c "%U" /dc/gcloud-cli)\" = $USER" diff --git a/test/github-cli-persistence/_default.sh b/test/github-cli-persistence/_default.sh index c64a112..b92af7c 100644 --- a/test/github-cli-persistence/_default.sh +++ b/test/github-cli-persistence/_default.sh @@ -13,10 +13,11 @@ check "config" bash -c "ls -la ~/.config | grep 'gh'" check "dc" bash -c "ls -la /dc | grep 'github-cli'" # check that the folders are owned by the user -# `stat -c "%U %G" ~/.config` returns "$USER $GROUP", in this case "node node" # https://askubuntu.com/a/175060 -check "~/.config/gh owned by user" bash -c "test \"$(stat -c "%U %G" ~/.config)\" = $USER" -check "/dc/github-cli owned by user" bash -c "test \"$(stat -c "%U %G" /dc/github-cli)\" = $USER" +echo "Checking ownership of ~/.config/gh and /dc/github-cli (ensure it is owned by $USER)" + +check "~/.config/gh owned by user" bash -c "test \"$(stat -c "%U" ~/.config/gh)\" = $USER" +check "/dc/github-cli owned by user" bash -c "test \"$(stat -c "%U" /dc/github-cli)\" = $USER" # Report result reportResults diff --git a/test/mount-pnpm-store/_default.sh b/test/mount-pnpm-store/_default.sh index 8d276e5..0beadc9 100644 --- a/test/mount-pnpm-store/_default.sh +++ b/test/mount-pnpm-store/_default.sh @@ -18,5 +18,11 @@ pnpmConfig=$(pnpm config get store-dir) echo "pnpm config get store-dir: '$pnpmConfig'" check "config" test $pnpmConfig = "$(echo ~)/.pnpm-store" +# check that the folders are owned by the user +# https://askubuntu.com/a/175060 +echo "Checking ownership of /dc/mounted-pnpm-store (ensure it is owned by $USER)" + +check "/dc/mounted-pnpm-store owned by user" bash -c "test \"$(stat -c "%U" /dc/mounted-pnpm-store)\" = $USER" + # Report result reportResults diff --git a/test/terraform-cli-persistence/_default.sh b/test/terraform-cli-persistence/_default.sh index baea4a8..9b6656f 100644 --- a/test/terraform-cli-persistence/_default.sh +++ b/test/terraform-cli-persistence/_default.sh @@ -16,10 +16,11 @@ check "~/.terraform.d existence" bash -c "ls -la ~ | grep '.terraform.d'" check "/dc/terraform-cli existence" bash -c "ls -la /dc | grep 'terraform-cli'" # check that the folders are owned by the user -# `stat -c "%U %G" ~/.terraform.d` returns "$USER $GROUP", in this case "node node" # https://askubuntu.com/a/175060 -check "~/.terraform.d owned by user" bash -c "test \"$(stat -c "%U %G" ~/.terraform.d)\" = 'node node'" -check "/dc/terraform-cli owned by user" bash -c "test \"$(stat -c "%U %G" /dc/terraform-cli)\" = 'node node'" +echo "Checking ownership of ~/.terraform.d and /dc/terraform-cli (ensure it is owned by $USER)" + +check "~/.terraform.d owned by user" bash -c "test \"$(stat -c "%U" ~/.terraform.d)\" = $USER" +check "/dc/terraform-cli owned by user" bash -c "test \"$(stat -c "%U" /dc/terraform-cli)\" = $USER" # Report result reportResults From c696afe9470176219c14afa981c4e45e1f0599bb Mon Sep 17 00:00:00 2001 From: Joshua Ji Date: Tue, 9 Jan 2024 01:54:52 +0000 Subject: [PATCH 12/22] Add root_user tests to volume features --- test/gcloud-cli-persistence/root_user.sh | 7 +++++++ test/gcloud-cli-persistence/scenarios.json | 8 ++++++++ test/github-cli-persistence/root_user.sh | 7 +++++++ test/github-cli-persistence/scenarios.json | 10 +++++++++- test/mount-pnpm-store/root_user.sh | 7 +++++++ test/mount-pnpm-store/scenarios.json | 8 ++++++++ test/terraform-cli-persistence/root_user.sh | 5 +++++ test/terraform-cli-persistence/scenarios.json | 10 +++++++++- 8 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 test/gcloud-cli-persistence/root_user.sh create mode 100644 test/github-cli-persistence/root_user.sh create mode 100644 test/mount-pnpm-store/root_user.sh create mode 100644 test/terraform-cli-persistence/root_user.sh diff --git a/test/gcloud-cli-persistence/root_user.sh b/test/gcloud-cli-persistence/root_user.sh new file mode 100644 index 0000000..1fe2fa4 --- /dev/null +++ b/test/gcloud-cli-persistence/root_user.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +set -e + +# Run default test script (in same folder) +# See: https://github.com/devcontainers/features/blob/562305d37b97d47331d96306ffc2a0a3cce55e64/test/azure-cli/install_extensions_bookworm.sh +./_default.sh diff --git a/test/gcloud-cli-persistence/scenarios.json b/test/gcloud-cli-persistence/scenarios.json index 91fd152..8b80d2b 100644 --- a/test/gcloud-cli-persistence/scenarios.json +++ b/test/gcloud-cli-persistence/scenarios.json @@ -15,5 +15,13 @@ "configureZshAsDefaultShell": true } } + }, + "root_user": { + "image": "mcr.microsoft.com/devcontainers/base:debian", + "features": { + "gcloud-cli-persistence": {}, + "ghcr.io/dhoeric/features/google-cloud-cli": {} + }, + "remoteUser": "root" } } \ No newline at end of file diff --git a/test/github-cli-persistence/root_user.sh b/test/github-cli-persistence/root_user.sh new file mode 100644 index 0000000..1fe2fa4 --- /dev/null +++ b/test/github-cli-persistence/root_user.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +set -e + +# Run default test script (in same folder) +# See: https://github.com/devcontainers/features/blob/562305d37b97d47331d96306ffc2a0a3cce55e64/test/azure-cli/install_extensions_bookworm.sh +./_default.sh diff --git a/test/github-cli-persistence/scenarios.json b/test/github-cli-persistence/scenarios.json index e2caf6c..4a582a2 100644 --- a/test/github-cli-persistence/scenarios.json +++ b/test/github-cli-persistence/scenarios.json @@ -7,7 +7,7 @@ } }, "zsh_shell": { - "image": "mcr.microsoft.com/devcontainers/javascript-node:1-18", + "image": "mcr.microsoft.com/devcontainers/base:debian", "features": { "github-cli-persistence": {}, "ghcr.io/devcontainers/features/github-cli": {}, @@ -15,5 +15,13 @@ "configureZshAsDefaultShell": true } } + }, + "root_user": { + "image": "mcr.microsoft.com/devcontainers/base:debian", + "features": { + "github-cli-persistence": {}, + "ghcr.io/devcontainers/features/github-cli": {} + }, + "remoteUser": "root" } } \ No newline at end of file diff --git a/test/mount-pnpm-store/root_user.sh b/test/mount-pnpm-store/root_user.sh new file mode 100644 index 0000000..e9d42a7 --- /dev/null +++ b/test/mount-pnpm-store/root_user.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +set -e + +# tests installing pnpm through a feature + +./_default.sh diff --git a/test/mount-pnpm-store/scenarios.json b/test/mount-pnpm-store/scenarios.json index a0216af..6695575 100644 --- a/test/mount-pnpm-store/scenarios.json +++ b/test/mount-pnpm-store/scenarios.json @@ -20,5 +20,13 @@ "configureZshAsDefaultShell": true } } + }, + "root_user": { + "image": "mcr.microsoft.com/devcontainers/javascript-node:1-18", + "features": { + "ghcr.io/devcontainers/features/node:1": {}, + "mount-pnpm-store": {} + }, + "remoteUser": "root" } } \ No newline at end of file diff --git a/test/terraform-cli-persistence/root_user.sh b/test/terraform-cli-persistence/root_user.sh new file mode 100644 index 0000000..9bbf662 --- /dev/null +++ b/test/terraform-cli-persistence/root_user.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +set -e + +./_default.sh diff --git a/test/terraform-cli-persistence/scenarios.json b/test/terraform-cli-persistence/scenarios.json index b01e292..776b26d 100644 --- a/test/terraform-cli-persistence/scenarios.json +++ b/test/terraform-cli-persistence/scenarios.json @@ -7,7 +7,7 @@ } }, "zsh_shell": { - "image": "mcr.microsoft.com/devcontainers/javascript-node:1-18", + "image": "mcr.microsoft.com/devcontainers/base:debian", "features": { "terraform-cli-persistence": {}, "ghcr.io/devcontainers/features/terraform:1": {}, @@ -15,5 +15,13 @@ "configureZshAsDefaultShell": true } } + }, + "root_user": { + "image": "mcr.microsoft.com/devcontainers/base:debian", + "features": { + "terraform-cli-persistence": {}, + "ghcr.io/devcontainers/features/terraform:1": {} + }, + "remoteUser": "root" } } \ No newline at end of file From 69c92e3b7fe64c9dbe1951123c6775c2fab22be3 Mon Sep 17 00:00:00 2001 From: Joshua Ji Date: Tue, 9 Jan 2024 01:58:31 +0000 Subject: [PATCH 13/22] test --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2f83c78..38ff2a6 100644 --- a/README.md +++ b/README.md @@ -12,4 +12,6 @@ This repo contains my custom devcontainer features. | [terraform-cli-persistence](./src/terraform-cli-persistence) | Avoid extra logins from the Terraform CLI by preserving the `~/.terraform.d` folder across container instances. | | [aws-cli-persistence](./src/aws-cli-persistence) | Avoid extra logins from the AWS CLI by preserving the `~/.aws` folder across container instances. | | [lamdera](./src/lamdera) | Installs [Lamdera](https://dashboard.lamdera.app/), a type-safe full-stack web-app platform for Elm (v1.1.0 and later). | -| [mount-pnpm-store](./src/mount-pnpm-store) | Mounts the pnpm store to a volume to share between multiple devcontainers. | +| [mount-pnpm-store](./src/mount-pnpm-store) | Mounts the pnpm store to a volume to share between multiple devcontainers. | + +See #38 From 3b927fac66ec5bc65dfddb0394019e3a696a1ef6 Mon Sep 17 00:00:00 2001 From: Joshua Ji Date: Tue, 9 Jan 2024 01:59:35 +0000 Subject: [PATCH 14/22] Update to mount features to 1.0.0 --- src/aws-cli-persistence/NOTES.md | 7 ++++--- src/aws-cli-persistence/devcontainer-feature.json | 2 +- src/gcloud-cli-persistence/NOTES.md | 7 ++++--- src/gcloud-cli-persistence/devcontainer-feature.json | 2 +- src/github-cli-persistence/NOTES.md | 1 + src/github-cli-persistence/devcontainer-feature.json | 2 +- src/mount-pnpm-store/NOTES.md | 11 ++++++----- src/mount-pnpm-store/devcontainer-feature.json | 2 +- src/terraform-cli-persistence/NOTES.md | 7 ++++--- .../devcontainer-feature.json | 2 +- 10 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/aws-cli-persistence/NOTES.md b/src/aws-cli-persistence/NOTES.md index 1d06834..df55460 100644 --- a/src/aws-cli-persistence/NOTES.md +++ b/src/aws-cli-persistence/NOTES.md @@ -1,8 +1,9 @@ ## Changelog -| Version | Notes | -| ------- | --------------- | -| 0.0.0 | Initial Version | +| Version | Notes | +| ------- | ---------------------- | +| 1.0.0 | Support zsh + refactor | +| 0.0.0 | Initial Version | ## References diff --git a/src/aws-cli-persistence/devcontainer-feature.json b/src/aws-cli-persistence/devcontainer-feature.json index ac12178..c703eb0 100644 --- a/src/aws-cli-persistence/devcontainer-feature.json +++ b/src/aws-cli-persistence/devcontainer-feature.json @@ -1,7 +1,7 @@ { "name": "AWS CLI Persistence", "id": "aws-cli-persistence", - "version": "0.0.0", + "version": "1.0.0", "documentationURL": "https://github.com/joshuanianji/devcontainer-features/tree/main/src/aws-cli-persistence", "description": "Avoid extra logins from the AWS CLI by preserving the `~/.aws` folder across container instances.", "options": {}, diff --git a/src/gcloud-cli-persistence/NOTES.md b/src/gcloud-cli-persistence/NOTES.md index 045b599..a9189b5 100644 --- a/src/gcloud-cli-persistence/NOTES.md +++ b/src/gcloud-cli-persistence/NOTES.md @@ -5,6 +5,7 @@ OS: `ubuntu`, `debian` ## Changelog -| Version | Notes | -| ------- | --------------- | -| 0.0.0 | Initial Version | +| Version | Notes | +| ------- | ---------------------- | +| 1.0.0 | Support zsh + refactor | +| 0.0.0 | Initial Version | diff --git a/src/gcloud-cli-persistence/devcontainer-feature.json b/src/gcloud-cli-persistence/devcontainer-feature.json index ac238da..8889297 100644 --- a/src/gcloud-cli-persistence/devcontainer-feature.json +++ b/src/gcloud-cli-persistence/devcontainer-feature.json @@ -1,7 +1,7 @@ { "name": "Google Cloud CLI Persistence", "id": "gcloud-cli-persistence", - "version": "0.0.0", + "version": "1.0.0", "documentationURL": "https://github.com/joshuanianji/devcontainer-features/tree/main/src/gcloud-cli-persistence", "description": "Avoid extra logins from the Google Cloud CLI by preserving the `~/.config/gcloud` folder across container instances.", "options": {}, diff --git a/src/github-cli-persistence/NOTES.md b/src/github-cli-persistence/NOTES.md index bca5fca..c9fad86 100644 --- a/src/github-cli-persistence/NOTES.md +++ b/src/github-cli-persistence/NOTES.md @@ -12,6 +12,7 @@ | Version | Notes | | ------- | ---------------------------------------------------- | +| 1.0.0 | Support zsh + refactor | | 0.0.3 | Delete some unnecessary "echo" statements | | 0.0.2 | `chown -R` the entire `~/.config` directory | | 0.0.1 | Rename ~/.config/gh to ~/.config/gh-old if it exists | diff --git a/src/github-cli-persistence/devcontainer-feature.json b/src/github-cli-persistence/devcontainer-feature.json index 5227419..fd88dee 100644 --- a/src/github-cli-persistence/devcontainer-feature.json +++ b/src/github-cli-persistence/devcontainer-feature.json @@ -1,7 +1,7 @@ { "name": "Github CLI Persistence", "id": "github-cli-persistence", - "version": "0.0.3", + "version": "1.0.0", "documentationURL": "https://github.com/joshuanianji/devcontainer-features/tree/main/src/github-cli-persistence", "description": "Avoid extra logins from the Github CLI by preserving the `~/.config/gh` folder across container instances.", "options": {}, diff --git a/src/mount-pnpm-store/NOTES.md b/src/mount-pnpm-store/NOTES.md index 3f902e4..7b16546 100644 --- a/src/mount-pnpm-store/NOTES.md +++ b/src/mount-pnpm-store/NOTES.md @@ -30,11 +30,12 @@ The volume mount is called `global-devcontainer-pnpm-store`, so ensure that no o ## Changelog -| Version | Notes | -| ------- | ---------------------------------------------------- | -| 0.1.1 | Fix mount name | -| 0.1.0 | Documentation | -| 0.0.0 | Initial Version | +| Version | Notes | +| ------- | ---------------------- | +| 1.0.0 | Support zsh + refactor | +| 0.1.1 | Fix mount name | +| 0.1.0 | Documentation | +| 0.0.0 | Initial Version | ## References diff --git a/src/mount-pnpm-store/devcontainer-feature.json b/src/mount-pnpm-store/devcontainer-feature.json index 7d27afb..138f112 100644 --- a/src/mount-pnpm-store/devcontainer-feature.json +++ b/src/mount-pnpm-store/devcontainer-feature.json @@ -1,7 +1,7 @@ { "name": "Mount pnpm Store", "id": "mount-pnpm-store", - "version": "0.1.1", + "version": "1.0.0", "documentationURL": "https://github.com/joshuanianji/devcontainer-features/tree/main/src/mount-pnpm-store", "description": "Sets pnpm store to ~/.pnpm-store and mounts it to a volume to share between multiple devcontainers", "options": {}, diff --git a/src/terraform-cli-persistence/NOTES.md b/src/terraform-cli-persistence/NOTES.md index 1d06834..df55460 100644 --- a/src/terraform-cli-persistence/NOTES.md +++ b/src/terraform-cli-persistence/NOTES.md @@ -1,8 +1,9 @@ ## Changelog -| Version | Notes | -| ------- | --------------- | -| 0.0.0 | Initial Version | +| Version | Notes | +| ------- | ---------------------- | +| 1.0.0 | Support zsh + refactor | +| 0.0.0 | Initial Version | ## References diff --git a/src/terraform-cli-persistence/devcontainer-feature.json b/src/terraform-cli-persistence/devcontainer-feature.json index 0f852eb..073c1e0 100644 --- a/src/terraform-cli-persistence/devcontainer-feature.json +++ b/src/terraform-cli-persistence/devcontainer-feature.json @@ -1,7 +1,7 @@ { "name": "Terraform CLI Persistence", "id": "terraform-cli-persistence", - "version": "0.0.0", + "version": "1.0.0", "documentationURL": "https://github.com/joshuanianji/devcontainer-features/tree/main/src/terraform-cli-persistence", "description": "Avoid extra logins from the Terraform CLI by preserving the `~/.terraform.d` folder across container instances.", "options": {}, From e85b030b36bfee4ad4fc7775f4b0be5e057db0e8 Mon Sep 17 00:00:00 2001 From: Joshua Ji Date: Tue, 9 Jan 2024 02:00:18 +0000 Subject: [PATCH 15/22] Rm test was trying to see if referencing a PR in markdown would link it but it wouldn't --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 38ff2a6..b7eab28 100644 --- a/README.md +++ b/README.md @@ -13,5 +13,3 @@ This repo contains my custom devcontainer features. | [aws-cli-persistence](./src/aws-cli-persistence) | Avoid extra logins from the AWS CLI by preserving the `~/.aws` folder across container instances. | | [lamdera](./src/lamdera) | Installs [Lamdera](https://dashboard.lamdera.app/), a type-safe full-stack web-app platform for Elm (v1.1.0 and later). | | [mount-pnpm-store](./src/mount-pnpm-store) | Mounts the pnpm store to a volume to share between multiple devcontainers. | - -See #38 From aadeb280558839610594acc6e7fe50482630818e Mon Sep 17 00:00:00 2001 From: Joshua Ji Date: Tue, 9 Jan 2024 02:08:57 +0000 Subject: [PATCH 16/22] Streaming OS/Arch support --- src/aws-cli-persistence/NOTES.md | 6 ++++++ src/gcloud-cli-persistence/NOTES.md | 1 + src/github-cli-persistence/NOTES.md | 10 +++------- src/mount-pnpm-store/NOTES.md | 6 ++++++ src/terraform-cli-persistence/NOTES.md | 6 ++++++ 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/aws-cli-persistence/NOTES.md b/src/aws-cli-persistence/NOTES.md index df55460..005e48e 100644 --- a/src/aws-cli-persistence/NOTES.md +++ b/src/aws-cli-persistence/NOTES.md @@ -1,3 +1,9 @@ +## OS and Architecture Support + +Architectures: `amd` and `arm`. +OS: `ubuntu`, `debian` +Shells: `bash`, `zsh` + ## Changelog | Version | Notes | diff --git a/src/gcloud-cli-persistence/NOTES.md b/src/gcloud-cli-persistence/NOTES.md index a9189b5..09d9139 100644 --- a/src/gcloud-cli-persistence/NOTES.md +++ b/src/gcloud-cli-persistence/NOTES.md @@ -2,6 +2,7 @@ Architectures: `amd` and `arm`. OS: `ubuntu`, `debian` +Shells: `bash`, `zsh` ## Changelog diff --git a/src/github-cli-persistence/NOTES.md b/src/github-cli-persistence/NOTES.md index c9fad86..608ed9a 100644 --- a/src/github-cli-persistence/NOTES.md +++ b/src/github-cli-persistence/NOTES.md @@ -1,12 +1,8 @@ ## OS and Architecture Support -| | amd64 | arm64 | -| ------ | ----- | ----- | -| ubuntu | ✅ | ✔️ | -| debian | ✅ | ✔️ | - -- ✅: Tested and verified on Github Actions -- ✔️: Tested locally on my mac (but not on GHA) +Architectures: `amd` and `arm`. +OS: `ubuntu`, `debian` +Shells: `bash`, `zsh` ## Changelog diff --git a/src/mount-pnpm-store/NOTES.md b/src/mount-pnpm-store/NOTES.md index 7b16546..3dbfdbd 100644 --- a/src/mount-pnpm-store/NOTES.md +++ b/src/mount-pnpm-store/NOTES.md @@ -1,3 +1,9 @@ +## OS and Architecture Support + +Architectures: `amd` and `arm`. +OS: `ubuntu`, `debian` +Shells: `bash`, `zsh` + ## Important Implementation Details ### pnpm `store-dir` diff --git a/src/terraform-cli-persistence/NOTES.md b/src/terraform-cli-persistence/NOTES.md index df55460..005e48e 100644 --- a/src/terraform-cli-persistence/NOTES.md +++ b/src/terraform-cli-persistence/NOTES.md @@ -1,3 +1,9 @@ +## OS and Architecture Support + +Architectures: `amd` and `arm`. +OS: `ubuntu`, `debian` +Shells: `bash`, `zsh` + ## Changelog | Version | Notes | From 2051f2af24f8d4a1e3d51e340f5d954d114f49cc Mon Sep 17 00:00:00 2001 From: Joshua Ji Date: Tue, 9 Jan 2024 02:15:15 +0000 Subject: [PATCH 17/22] test zsh shell for lamdera --- test/lamdera/scenarios.json | 11 ++++++++++- test/lamdera/zsh_shell.sh | 15 +++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 test/lamdera/zsh_shell.sh diff --git a/test/lamdera/scenarios.json b/test/lamdera/scenarios.json index aecd407..437b6e9 100644 --- a/test/lamdera/scenarios.json +++ b/test/lamdera/scenarios.json @@ -6,5 +6,14 @@ "version": "1.1.0" } } + }, + "zsh_shell": { + "image": "mcr.microsoft.com/devcontainers/base:debian", + "features": { + "ghcr.io/devcontainers/features/common-utils:2": { + "configureZshAsDefaultShell": true + }, + "lamdera": {} + } } -} +} \ No newline at end of file diff --git a/test/lamdera/zsh_shell.sh b/test/lamdera/zsh_shell.sh new file mode 100644 index 0000000..c408c70 --- /dev/null +++ b/test/lamdera/zsh_shell.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# check that running the binary by itself works +check "normal" bash -c "lamdera" + +# check version +check "version" bash -c "lamdera --version" + +# Report result +reportResults From e8667d52859bd213b51e7bac0c2d21a3e46b7900 Mon Sep 17 00:00:00 2001 From: Joshua Ji Date: Tue, 9 Jan 2024 02:19:37 +0000 Subject: [PATCH 18/22] Set dependencies on common-utils and fish --- src/aws-cli-persistence/devcontainer-feature.json | 3 ++- src/gcloud-cli-persistence/devcontainer-feature.json | 3 ++- src/github-cli-persistence/devcontainer-feature.json | 3 ++- src/lamdera/devcontainer-feature.json | 3 ++- src/mount-pnpm-store/NOTES.md | 12 ++++++------ src/mount-pnpm-store/devcontainer-feature.json | 4 +++- .../devcontainer-feature.json | 4 +++- 7 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/aws-cli-persistence/devcontainer-feature.json b/src/aws-cli-persistence/devcontainer-feature.json index c703eb0..db919d8 100644 --- a/src/aws-cli-persistence/devcontainer-feature.json +++ b/src/aws-cli-persistence/devcontainer-feature.json @@ -13,7 +13,8 @@ } ], "installsAfter": [ - "ghcr.io/devcontainers/features/aws-cli" + "ghcr.io/devcontainers/features/aws-cli", + "ghcr.io/meaningful-ooo/devcontainer-features/fish" ], "postCreateCommand": "/usr/local/share/aws-cli-persistence-post-create.sh" } \ No newline at end of file diff --git a/src/gcloud-cli-persistence/devcontainer-feature.json b/src/gcloud-cli-persistence/devcontainer-feature.json index 8889297..bbfb892 100644 --- a/src/gcloud-cli-persistence/devcontainer-feature.json +++ b/src/gcloud-cli-persistence/devcontainer-feature.json @@ -13,7 +13,8 @@ } ], "installsAfter": [ - "ghcr.io/dhoeric/features/google-cloud-cli" + "ghcr.io/dhoeric/features/google-cloud-cli", + "ghcr.io/meaningful-ooo/devcontainer-features/fish" ], "postCreateCommand": "/usr/local/share/gcloud-cli-persistence-post-create.sh" } \ No newline at end of file diff --git a/src/github-cli-persistence/devcontainer-feature.json b/src/github-cli-persistence/devcontainer-feature.json index fd88dee..422e4ff 100644 --- a/src/github-cli-persistence/devcontainer-feature.json +++ b/src/github-cli-persistence/devcontainer-feature.json @@ -13,7 +13,8 @@ } ], "installsAfter": [ - "ghcr.io/devcontainers/features/github-cli" + "ghcr.io/devcontainers/features/github-cli", + "ghcr.io/meaningful-ooo/devcontainer-features/fish" ], "postCreateCommand": "/usr/local/share/github-cli-persistence-post-create.sh" } \ No newline at end of file diff --git a/src/lamdera/devcontainer-feature.json b/src/lamdera/devcontainer-feature.json index 1a98550..cf2e370 100644 --- a/src/lamdera/devcontainer-feature.json +++ b/src/lamdera/devcontainer-feature.json @@ -16,6 +16,7 @@ } }, "installsAfter": [ - "ghcr.io/devcontainers/features/common-utils" + "ghcr.io/devcontainers/features/common-utils", + "ghcr.io/meaningful-ooo/devcontainer-features/fish" ] } \ No newline at end of file diff --git a/src/mount-pnpm-store/NOTES.md b/src/mount-pnpm-store/NOTES.md index 3dbfdbd..4edbeac 100644 --- a/src/mount-pnpm-store/NOTES.md +++ b/src/mount-pnpm-store/NOTES.md @@ -14,18 +14,18 @@ This is opinionated, but I dislike the pnpm store being in the workspace along w This feature does not install pnpm by itself and expects `pnpm` to be installed already, either by a base image or by a feature. If pnpm is not installed, it just gives a warning (you'll have a random ~/.pnpm-store folder in your home directory and the pnpm `store-dir` config will not be set) but does not fail. -If you are installing pnpm with a feature, you may need to ensure it is run **before** `mount-pnpm-store`. To make this work, use the [`overrideFeatureInstallOrder` property](https://containers.dev/implementors/features/#overrideFeatureInstallOrder), since the default feature installation order is based on ID (alphanumerically i think). Here is an example using `features/node`: +If you are installing pnpm with a feature, you may need to ensure it is run **before** `mount-pnpm-store`. I have set a soft dependency on `ghcr.io/devcontainers/features/node` already, but if it is any other feature that installs pnpm you might need to put some extra work. + +To make this work, use the [`overrideFeatureInstallOrder` property](https://containers.dev/implementors/features/#overrideFeatureInstallOrder), since the default feature installation order is based on ID (alphanumerically i think). Here is an example using a fake `unknown-install-pnpm`: ```json "image": "mcr.microsoft.com/devcontainers/base:bullseye", "features": { - "ghcr.io/devcontainers/features/node:1": { - "version": "20" - }, - "ghcr.io/joshuanianji/devcontainer-features/mount-pnpm-store": {} + "ghcr.io/random-user/devcontainer-features/unknown-install-pnpm:1": {}, + "ghcr.io/joshuanianji/devcontainer-features/mount-pnpm-store:1": {} }, "overrideFeatureInstallOrder": [ - "ghcr.io/devcontainers/features/node", + "ghcr.io/random-user/devcontainer-features/unknown-install-pnpm", "ghcr.io/joshuanianji/devcontainer-features/mount-pnpm-store" ] ``` diff --git a/src/mount-pnpm-store/devcontainer-feature.json b/src/mount-pnpm-store/devcontainer-feature.json index 138f112..51e017c 100644 --- a/src/mount-pnpm-store/devcontainer-feature.json +++ b/src/mount-pnpm-store/devcontainer-feature.json @@ -13,7 +13,9 @@ } ], "installsAfter": [ - "ghcr.io/devcontainers/features/node" + "ghcr.io/devcontainers/features/node", + "ghcr.io/devcontainers/features/common-utils", + "ghcr.io/meaningful-ooo/devcontainer-features/fish" ], "postCreateCommand": "/usr/local/share/mount-pnpm-store-post-create.sh" } \ No newline at end of file diff --git a/src/terraform-cli-persistence/devcontainer-feature.json b/src/terraform-cli-persistence/devcontainer-feature.json index 073c1e0..02751f4 100644 --- a/src/terraform-cli-persistence/devcontainer-feature.json +++ b/src/terraform-cli-persistence/devcontainer-feature.json @@ -13,7 +13,9 @@ } ], "installsAfter": [ - "ghcr.io/devcontainers/features/terraform" + "ghcr.io/devcontainers/features/terraform", + "ghcr.io/devcontainers/features/common-utils", + "ghcr.io/meaningful-ooo/devcontainer-features/fish" ], "postCreateCommand": "/usr/local/share/terraform-cli-persistence-post-create.sh" } \ No newline at end of file From 31b45b618a3811859458e31f820f28c2bbdee9fa Mon Sep 17 00:00:00 2001 From: Joshua Ji Date: Tue, 9 Jan 2024 02:29:21 +0000 Subject: [PATCH 19/22] add fish_shell tests, update notes also update lamdera to 1.0 --- src/aws-cli-persistence/NOTES.md | 2 +- src/gcloud-cli-persistence/NOTES.md | 2 +- src/github-cli-persistence/NOTES.md | 2 +- src/lamdera/NOTES.md | 27 +++++++------------ src/lamdera/devcontainer-feature.json | 2 +- src/mount-pnpm-store/NOTES.md | 2 +- src/terraform-cli-persistence/NOTES.md | 2 +- test/aws-cli-persistence/fish_shell.sh | 7 +++++ test/aws-cli-persistence/scenarios.json | 24 +++++++++++------ test/gcloud-cli-persistence/fish_shell.sh | 7 +++++ test/gcloud-cli-persistence/scenarios.json | 22 ++++++++++----- test/github-cli-persistence/_default.sh | 3 +++ test/github-cli-persistence/fish_shell.sh | 7 +++++ test/github-cli-persistence/scenarios.json | 22 ++++++++++----- test/lamdera/_default.sh | 18 +++++++++++++ test/lamdera/fish_shell.sh | 7 +++++ test/lamdera/scenarios.json | 7 +++++ test/lamdera/v1.1.0.sh | 14 +++------- test/lamdera/zsh_shell.sh | 14 +++------- test/mount-pnpm-store/fish_shell.sh | 7 +++++ test/mount-pnpm-store/scenarios.json | 12 ++++++--- test/terraform-cli-persistence/fish_shell.sh | 7 +++++ test/terraform-cli-persistence/scenarios.json | 22 ++++++++++----- 23 files changed, 162 insertions(+), 77 deletions(-) create mode 100644 test/aws-cli-persistence/fish_shell.sh create mode 100644 test/gcloud-cli-persistence/fish_shell.sh create mode 100644 test/github-cli-persistence/fish_shell.sh create mode 100644 test/lamdera/_default.sh create mode 100644 test/lamdera/fish_shell.sh create mode 100644 test/mount-pnpm-store/fish_shell.sh create mode 100644 test/terraform-cli-persistence/fish_shell.sh diff --git a/src/aws-cli-persistence/NOTES.md b/src/aws-cli-persistence/NOTES.md index 005e48e..824aa21 100644 --- a/src/aws-cli-persistence/NOTES.md +++ b/src/aws-cli-persistence/NOTES.md @@ -2,7 +2,7 @@ Architectures: `amd` and `arm`. OS: `ubuntu`, `debian` -Shells: `bash`, `zsh` +Shells: `bash`, `zsh`, `fish` ## Changelog diff --git a/src/gcloud-cli-persistence/NOTES.md b/src/gcloud-cli-persistence/NOTES.md index 09d9139..b50ac02 100644 --- a/src/gcloud-cli-persistence/NOTES.md +++ b/src/gcloud-cli-persistence/NOTES.md @@ -2,7 +2,7 @@ Architectures: `amd` and `arm`. OS: `ubuntu`, `debian` -Shells: `bash`, `zsh` +Shells: `bash`, `zsh`, `fish` ## Changelog diff --git a/src/github-cli-persistence/NOTES.md b/src/github-cli-persistence/NOTES.md index 608ed9a..b22ada7 100644 --- a/src/github-cli-persistence/NOTES.md +++ b/src/github-cli-persistence/NOTES.md @@ -2,7 +2,7 @@ Architectures: `amd` and `arm`. OS: `ubuntu`, `debian` -Shells: `bash`, `zsh` +Shells: `bash`, `zsh`, `fish` ## Changelog diff --git a/src/lamdera/NOTES.md b/src/lamdera/NOTES.md index 3aac32d..6170de5 100644 --- a/src/lamdera/NOTES.md +++ b/src/lamdera/NOTES.md @@ -8,27 +8,20 @@ curl "https://static.lamdera.com/bin/lamdera-$VERSION-linux-$ARCH" ``` Based on my tests, v1.1.0 is the only one that works reliably. -## OS and Arch Support +## OS and Architecture Support -`v1.1.0` Supports the following OS and architectures: - -| | amd64 | arm64 | -| ------ | ----- | ----- | -| ubuntu | ✅ | ✔️ | -| debian | ✅ | ✔️ | - -- ✅: Tested and verified on Github Actions -- ✔️: Tested locally on my mac (but not on GHA) - -Other lamdera versions are not tested, but please submit an issue/PR if you need to use them! +Architectures: `amd` and `arm`. +OS: `ubuntu`, `debian` +Shells: `bash`, `zsh`, `fish` ## Changelog -| Version | Notes | -| ------- | ----------------- | -| 0.0.2 | Fix typos in Docs | -| 0.0.1 | Update Docs | -| 0.0.0 | Initial Version | +| Version | Notes | +| ------- | ----------------------------- | +| 1.0.0 | Support zsh/fish and refactor | +| 0.0.2 | Fix typos in Docs | +| 0.0.1 | Update Docs | +| 0.0.0 | Initial Version | ## References diff --git a/src/lamdera/devcontainer-feature.json b/src/lamdera/devcontainer-feature.json index cf2e370..3437416 100644 --- a/src/lamdera/devcontainer-feature.json +++ b/src/lamdera/devcontainer-feature.json @@ -1,7 +1,7 @@ { "name": "Lamdera", "id": "lamdera", - "version": "0.0.2", + "version": "1.0.0", "documentationURL": "https://github.com/joshuanianji/devcontainer-features/tree/main/src/lamdera", "description": "Installs [Lamdera](https://dashboard.lamdera.app/), a type-safe full-stack web-app platform for Elm (v1.1.0 and later).", "options": { diff --git a/src/mount-pnpm-store/NOTES.md b/src/mount-pnpm-store/NOTES.md index 4edbeac..464b26c 100644 --- a/src/mount-pnpm-store/NOTES.md +++ b/src/mount-pnpm-store/NOTES.md @@ -2,7 +2,7 @@ Architectures: `amd` and `arm`. OS: `ubuntu`, `debian` -Shells: `bash`, `zsh` +Shells: `bash`, `zsh`, `fish` ## Important Implementation Details diff --git a/src/terraform-cli-persistence/NOTES.md b/src/terraform-cli-persistence/NOTES.md index 005e48e..824aa21 100644 --- a/src/terraform-cli-persistence/NOTES.md +++ b/src/terraform-cli-persistence/NOTES.md @@ -2,7 +2,7 @@ Architectures: `amd` and `arm`. OS: `ubuntu`, `debian` -Shells: `bash`, `zsh` +Shells: `bash`, `zsh`, `fish` ## Changelog diff --git a/test/aws-cli-persistence/fish_shell.sh b/test/aws-cli-persistence/fish_shell.sh new file mode 100644 index 0000000..1fe2fa4 --- /dev/null +++ b/test/aws-cli-persistence/fish_shell.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +set -e + +# Run default test script (in same folder) +# See: https://github.com/devcontainers/features/blob/562305d37b97d47331d96306ffc2a0a3cce55e64/test/azure-cli/install_extensions_bookworm.sh +./_default.sh diff --git a/test/aws-cli-persistence/scenarios.json b/test/aws-cli-persistence/scenarios.json index 546ab1b..52bf258 100644 --- a/test/aws-cli-persistence/scenarios.json +++ b/test/aws-cli-persistence/scenarios.json @@ -2,25 +2,33 @@ "with_node": { "image": "mcr.microsoft.com/devcontainers/javascript-node:1-18", "features": { - "aws-cli-persistence": {}, - "ghcr.io/devcontainers/features/aws-cli": {} + "ghcr.io/devcontainers/features/aws-cli": {}, + "aws-cli-persistence": {} } }, "zsh_shell": { - "image": "mcr.microsoft.com/devcontainers/javascript-node:1-18", + "image": "mcr.microsoft.com/devcontainers/base:debian", "features": { - "aws-cli-persistence": {}, - "ghcr.io/devcontainers/features/aws-cli": {}, "ghcr.io/devcontainers/features/common-utils:2": { "configureZshAsDefaultShell": true - } + }, + "ghcr.io/devcontainers/features/aws-cli": {}, + "aws-cli-persistence": {} + } + }, + "fish_shell": { + "image": "mcr.microsoft.com/devcontainers/base:debian", + "features": { + "ghcr.io/meaningful-ooo/devcontainer-features/fish:1": {}, + "ghcr.io/devcontainers/features/aws-cli": {}, + "aws-cli-persistence": {} } }, "root_user": { "image": "mcr.microsoft.com/devcontainers/base:debian", "features": { - "aws-cli-persistence": {}, - "ghcr.io/devcontainers/features/aws-cli": {} + "ghcr.io/devcontainers/features/aws-cli": {}, + "aws-cli-persistence": {} }, "remoteUser": "root" } diff --git a/test/gcloud-cli-persistence/fish_shell.sh b/test/gcloud-cli-persistence/fish_shell.sh new file mode 100644 index 0000000..1fe2fa4 --- /dev/null +++ b/test/gcloud-cli-persistence/fish_shell.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +set -e + +# Run default test script (in same folder) +# See: https://github.com/devcontainers/features/blob/562305d37b97d47331d96306ffc2a0a3cce55e64/test/azure-cli/install_extensions_bookworm.sh +./_default.sh diff --git a/test/gcloud-cli-persistence/scenarios.json b/test/gcloud-cli-persistence/scenarios.json index 8b80d2b..f0e926f 100644 --- a/test/gcloud-cli-persistence/scenarios.json +++ b/test/gcloud-cli-persistence/scenarios.json @@ -2,25 +2,33 @@ "with_node": { "image": "mcr.microsoft.com/devcontainers/javascript-node:1-18", "features": { - "gcloud-cli-persistence": {}, - "ghcr.io/dhoeric/features/google-cloud-cli": {} + "ghcr.io/dhoeric/features/google-cloud-cli": {}, + "gcloud-cli-persistence": {} } }, "zsh_shell": { "image": "mcr.microsoft.com/devcontainers/base:debian", "features": { - "gcloud-cli-persistence": {}, - "ghcr.io/dhoeric/features/google-cloud-cli": {}, "ghcr.io/devcontainers/features/common-utils:2": { "configureZshAsDefaultShell": true - } + }, + "ghcr.io/dhoeric/features/google-cloud-cli": {}, + "gcloud-cli-persistence": {} + } + }, + "fish_shell": { + "image": "mcr.microsoft.com/devcontainers/base:debian", + "features": { + "ghcr.io/meaningful-ooo/devcontainer-features/fish:1": {}, + "ghcr.io/dhoeric/features/google-cloud-cli": {}, + "gcloud-cli-persistence": {} } }, "root_user": { "image": "mcr.microsoft.com/devcontainers/base:debian", "features": { - "gcloud-cli-persistence": {}, - "ghcr.io/dhoeric/features/google-cloud-cli": {} + "ghcr.io/dhoeric/features/google-cloud-cli": {}, + "gcloud-cli-persistence": {} }, "remoteUser": "root" } diff --git a/test/github-cli-persistence/_default.sh b/test/github-cli-persistence/_default.sh index b92af7c..5fb5918 100644 --- a/test/github-cli-persistence/_default.sh +++ b/test/github-cli-persistence/_default.sh @@ -2,6 +2,9 @@ set -e +# This is the default test script that tests everything +# It is not run as a scenario, but is run by other test scripts. + # Optional: Import test library source dev-container-features-test-lib diff --git a/test/github-cli-persistence/fish_shell.sh b/test/github-cli-persistence/fish_shell.sh new file mode 100644 index 0000000..1fe2fa4 --- /dev/null +++ b/test/github-cli-persistence/fish_shell.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +set -e + +# Run default test script (in same folder) +# See: https://github.com/devcontainers/features/blob/562305d37b97d47331d96306ffc2a0a3cce55e64/test/azure-cli/install_extensions_bookworm.sh +./_default.sh diff --git a/test/github-cli-persistence/scenarios.json b/test/github-cli-persistence/scenarios.json index 4a582a2..71f0937 100644 --- a/test/github-cli-persistence/scenarios.json +++ b/test/github-cli-persistence/scenarios.json @@ -2,25 +2,33 @@ "with_node": { "image": "mcr.microsoft.com/devcontainers/javascript-node:1-18", "features": { - "github-cli-persistence": {}, - "ghcr.io/devcontainers/features/github-cli": {} + "ghcr.io/devcontainers/features/github-cli": {}, + "github-cli-persistence": {} } }, "zsh_shell": { "image": "mcr.microsoft.com/devcontainers/base:debian", "features": { - "github-cli-persistence": {}, - "ghcr.io/devcontainers/features/github-cli": {}, "ghcr.io/devcontainers/features/common-utils:2": { "configureZshAsDefaultShell": true - } + }, + "ghcr.io/devcontainers/features/github-cli": {}, + "github-cli-persistence": {} + } + }, + "fish_shell": { + "image": "mcr.microsoft.com/devcontainers/base:debian", + "features": { + "ghcr.io/meaningful-ooo/devcontainer-features/fish:1": {}, + "ghcr.io/devcontainers/features/github-cli": {}, + "github-cli-persistence": {} } }, "root_user": { "image": "mcr.microsoft.com/devcontainers/base:debian", "features": { - "github-cli-persistence": {}, - "ghcr.io/devcontainers/features/github-cli": {} + "ghcr.io/devcontainers/features/github-cli": {}, + "github-cli-persistence": {} }, "remoteUser": "root" } diff --git a/test/lamdera/_default.sh b/test/lamdera/_default.sh new file mode 100644 index 0000000..7e7c9b1 --- /dev/null +++ b/test/lamdera/_default.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +set -e + +# This is the default test script that tests everything +# It is not run as a scenario, but is run by other test scripts. + +# Optional: Import test library +source dev-container-features-test-lib + +# check that running the binary by itself works +check "normal" bash -c "lamdera" + +# check version +check "version" bash -c "lamdera --version" + +# Report result +reportResults diff --git a/test/lamdera/fish_shell.sh b/test/lamdera/fish_shell.sh new file mode 100644 index 0000000..1fe2fa4 --- /dev/null +++ b/test/lamdera/fish_shell.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +set -e + +# Run default test script (in same folder) +# See: https://github.com/devcontainers/features/blob/562305d37b97d47331d96306ffc2a0a3cce55e64/test/azure-cli/install_extensions_bookworm.sh +./_default.sh diff --git a/test/lamdera/scenarios.json b/test/lamdera/scenarios.json index 437b6e9..e1e3977 100644 --- a/test/lamdera/scenarios.json +++ b/test/lamdera/scenarios.json @@ -15,5 +15,12 @@ }, "lamdera": {} } + }, + "fish_shell": { + "image": "mcr.microsoft.com/devcontainers/base:debian", + "features": { + "ghcr.io/meaningful-ooo/devcontainer-features/fish:1": {}, + "lamdera": {} + } } } \ No newline at end of file diff --git a/test/lamdera/v1.1.0.sh b/test/lamdera/v1.1.0.sh index c408c70..1fe2fa4 100644 --- a/test/lamdera/v1.1.0.sh +++ b/test/lamdera/v1.1.0.sh @@ -2,14 +2,6 @@ set -e -# Optional: Import test library -source dev-container-features-test-lib - -# check that running the binary by itself works -check "normal" bash -c "lamdera" - -# check version -check "version" bash -c "lamdera --version" - -# Report result -reportResults +# Run default test script (in same folder) +# See: https://github.com/devcontainers/features/blob/562305d37b97d47331d96306ffc2a0a3cce55e64/test/azure-cli/install_extensions_bookworm.sh +./_default.sh diff --git a/test/lamdera/zsh_shell.sh b/test/lamdera/zsh_shell.sh index c408c70..1fe2fa4 100644 --- a/test/lamdera/zsh_shell.sh +++ b/test/lamdera/zsh_shell.sh @@ -2,14 +2,6 @@ set -e -# Optional: Import test library -source dev-container-features-test-lib - -# check that running the binary by itself works -check "normal" bash -c "lamdera" - -# check version -check "version" bash -c "lamdera --version" - -# Report result -reportResults +# Run default test script (in same folder) +# See: https://github.com/devcontainers/features/blob/562305d37b97d47331d96306ffc2a0a3cce55e64/test/azure-cli/install_extensions_bookworm.sh +./_default.sh diff --git a/test/mount-pnpm-store/fish_shell.sh b/test/mount-pnpm-store/fish_shell.sh new file mode 100644 index 0000000..ace33be --- /dev/null +++ b/test/mount-pnpm-store/fish_shell.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +set -e + +# tests installing pnpm after zsh shell + +./_default.sh diff --git a/test/mount-pnpm-store/scenarios.json b/test/mount-pnpm-store/scenarios.json index 6695575..b6ab103 100644 --- a/test/mount-pnpm-store/scenarios.json +++ b/test/mount-pnpm-store/scenarios.json @@ -15,16 +15,22 @@ "zsh_shell": { "image": "mcr.microsoft.com/devcontainers/javascript-node:1-18", "features": { - "mount-pnpm-store": {}, "ghcr.io/devcontainers/features/common-utils:2": { "configureZshAsDefaultShell": true - } + }, + "mount-pnpm-store": {} + } + }, + "fish_shell": { + "image": "mcr.microsoft.com/devcontainers/base:debian", + "features": { + "ghcr.io/meaningful-ooo/devcontainer-features/fish:1": {}, + "mount-pnpm-store": {} } }, "root_user": { "image": "mcr.microsoft.com/devcontainers/javascript-node:1-18", "features": { - "ghcr.io/devcontainers/features/node:1": {}, "mount-pnpm-store": {} }, "remoteUser": "root" diff --git a/test/terraform-cli-persistence/fish_shell.sh b/test/terraform-cli-persistence/fish_shell.sh new file mode 100644 index 0000000..ace33be --- /dev/null +++ b/test/terraform-cli-persistence/fish_shell.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +set -e + +# tests installing pnpm after zsh shell + +./_default.sh diff --git a/test/terraform-cli-persistence/scenarios.json b/test/terraform-cli-persistence/scenarios.json index 776b26d..6db9786 100644 --- a/test/terraform-cli-persistence/scenarios.json +++ b/test/terraform-cli-persistence/scenarios.json @@ -2,25 +2,33 @@ "with_node": { "image": "mcr.microsoft.com/devcontainers/javascript-node:1-18", "features": { - "terraform-cli-persistence": {}, - "ghcr.io/devcontainers/features/terraform:1": {} + "ghcr.io/devcontainers/features/terraform:1": {}, + "terraform-cli-persistence": {} } }, "zsh_shell": { "image": "mcr.microsoft.com/devcontainers/base:debian", "features": { - "terraform-cli-persistence": {}, - "ghcr.io/devcontainers/features/terraform:1": {}, "ghcr.io/devcontainers/features/common-utils:2": { "configureZshAsDefaultShell": true - } + }, + "ghcr.io/devcontainers/features/terraform:1": {}, + "terraform-cli-persistence": {} + } + }, + "fish_shell": { + "image": "mcr.microsoft.com/devcontainers/base:debian", + "features": { + "ghcr.io/meaningful-ooo/devcontainer-features/fish:1": {}, + "ghcr.io/devcontainers/features/terraform:1": {}, + "terraform-cli-persistence": {} } }, "root_user": { "image": "mcr.microsoft.com/devcontainers/base:debian", "features": { - "terraform-cli-persistence": {}, - "ghcr.io/devcontainers/features/terraform:1": {} + "ghcr.io/devcontainers/features/terraform:1": {}, + "terraform-cli-persistence": {} }, "remoteUser": "root" } From de5cf016486ec43203f097ea538161095c3a2d88 Mon Sep 17 00:00:00 2001 From: Joshua Ji Date: Tue, 9 Jan 2024 06:23:03 +0000 Subject: [PATCH 20/22] set `pnpm config` in post create script could not get it to work for the life of me --- src/mount-pnpm-store/install.sh | 14 ++------------ .../{with_pnpm.sh => pnpm_from_feature.sh} | 0 test/mount-pnpm-store/scenarios.json | 4 ++-- 3 files changed, 4 insertions(+), 14 deletions(-) rename test/mount-pnpm-store/{with_pnpm.sh => pnpm_from_feature.sh} (100%) diff --git a/src/mount-pnpm-store/install.sh b/src/mount-pnpm-store/install.sh index 0439861..6f2a2cc 100644 --- a/src/mount-pnpm-store/install.sh +++ b/src/mount-pnpm-store/install.sh @@ -25,18 +25,6 @@ fi ln -s /dc/mounted-pnpm-store "$_REMOTE_USER_HOME/.pnpm-store" chown -R "$_REMOTE_USER:$_REMOTE_USER" "$_REMOTE_USER_HOME/.pnpm-store" -# set pnpm store location -# if pnpm is not installed, print out a warning -if type pnpm >/dev/null 2>&1; then - echo "Setting pnpm store location to $_REMOTE_USER_HOME/.pnpm-store" - # we have to run the `pnpm config set store-dir` as the remote user - # because the remote user is the one that will be using pnpm - runuser -l $_REMOTE_USER -c "pnpm config set store-dir $_REMOTE_USER_HOME/.pnpm-store --global" -else - echo "WARN: pnpm is not installed! Please ensure pnpm is installed and in your PATH." - echo "WARN: pnpm store location will not be set." -fi - # --- Generate a '$FEATURE_ID-post-create.sh' script to be executed by the 'postCreateCommand' lifecycle hook # Looks like this is the best way to run a script in lifecycle hooks # Source: https://github.com/devcontainers/features/blob/562305d37b97d47331d96306ffc2a0a3cce55e64/src/git-lfs/install.sh#L190C1-L190C109 @@ -48,6 +36,8 @@ tee "$POST_CREATE_SCRIPT_PATH" >/dev/null \ set -e +pnpm config set store-dir ~/.pnpm-store --global + # if the user is not root, chown /dc/aws-cli to the user if [ "$(id -u)" != "0" ]; then echo "Running post-start.sh for user $USER" diff --git a/test/mount-pnpm-store/with_pnpm.sh b/test/mount-pnpm-store/pnpm_from_feature.sh similarity index 100% rename from test/mount-pnpm-store/with_pnpm.sh rename to test/mount-pnpm-store/pnpm_from_feature.sh diff --git a/test/mount-pnpm-store/scenarios.json b/test/mount-pnpm-store/scenarios.json index b6ab103..f7a1355 100644 --- a/test/mount-pnpm-store/scenarios.json +++ b/test/mount-pnpm-store/scenarios.json @@ -5,7 +5,7 @@ "mount-pnpm-store": {} } }, - "with_pnpm": { + "pnpm_from_feature": { "image": "mcr.microsoft.com/devcontainers/base:bullseye", "features": { "ghcr.io/devcontainers/features/node:1": {}, @@ -22,7 +22,7 @@ } }, "fish_shell": { - "image": "mcr.microsoft.com/devcontainers/base:debian", + "image": "mcr.microsoft.com/devcontainers/javascript-node:1-18", "features": { "ghcr.io/meaningful-ooo/devcontainer-features/fish:1": {}, "mount-pnpm-store": {} From 770ca1b2aab241c813b19df3590a9907c213a57d Mon Sep 17 00:00:00 2001 From: Joshua Ji Date: Tue, 9 Jan 2024 06:25:49 +0000 Subject: [PATCH 21/22] fix pnpm store again --- src/mount-pnpm-store/install.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/mount-pnpm-store/install.sh b/src/mount-pnpm-store/install.sh index 6f2a2cc..5f46917 100644 --- a/src/mount-pnpm-store/install.sh +++ b/src/mount-pnpm-store/install.sh @@ -36,9 +36,17 @@ tee "$POST_CREATE_SCRIPT_PATH" >/dev/null \ set -e +# set pnpm config (if it's installed) +if type pnpm >/dev/null 2>&1; then + echo "Setting pnpm store location to $_REMOTE_USER_HOME/.pnpm-store" + pnpm config set store-dir ~/.pnpm-store --global +else + echo "WARN: pnpm is not installed! Please ensure pnpm is installed and in your PATH." + echo "WARN: pnpm store location will not be set." +fi pnpm config set store-dir ~/.pnpm-store --global -# if the user is not root, chown /dc/aws-cli to the user +# if the user is not root, chown /dc/mounted-pnpm-store to the user if [ "$(id -u)" != "0" ]; then echo "Running post-start.sh for user $USER" sudo chown -R "$USER:$USER" /dc/mounted-pnpm-store From 04f30a442288dc768b57d276c8ba2a96843147d4 Mon Sep 17 00:00:00 2001 From: Joshua Ji Date: Tue, 9 Jan 2024 06:51:22 +0000 Subject: [PATCH 22/22] fix AGAIN --- src/mount-pnpm-store/install.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mount-pnpm-store/install.sh b/src/mount-pnpm-store/install.sh index 5f46917..e7b5693 100644 --- a/src/mount-pnpm-store/install.sh +++ b/src/mount-pnpm-store/install.sh @@ -44,7 +44,6 @@ else echo "WARN: pnpm is not installed! Please ensure pnpm is installed and in your PATH." echo "WARN: pnpm store location will not be set." fi -pnpm config set store-dir ~/.pnpm-store --global # if the user is not root, chown /dc/mounted-pnpm-store to the user if [ "$(id -u)" != "0" ]; then