From 8d45f5c1af74d1baa0991867c085ca8ab2f36026 Mon Sep 17 00:00:00 2001 From: Joshua Ji Date: Thu, 27 Mar 2025 17:18:01 +0000 Subject: [PATCH 1/7] init gel-cli --- src/gel-cli/NOTES.md | 44 +++++++++++++ src/gel-cli/README.md | 76 ++++++++++++++++++++++ src/gel-cli/devcontainer-feature.json | 29 +++++++++ src/gel-cli/install.sh | 92 +++++++++++++++++++++++++++ src/gel-cli/oncreate.sh | 9 +++ 5 files changed, 250 insertions(+) create mode 100644 src/gel-cli/NOTES.md create mode 100644 src/gel-cli/README.md create mode 100644 src/gel-cli/devcontainer-feature.json create mode 100644 src/gel-cli/install.sh create mode 100644 src/gel-cli/oncreate.sh diff --git a/src/gel-cli/NOTES.md b/src/gel-cli/NOTES.md new file mode 100644 index 0000000..3f867f1 --- /dev/null +++ b/src/gel-cli/NOTES.md @@ -0,0 +1,44 @@ +## Usage + +**The Gel database instance should not be in the same container as the CLI.** My experience doing so makes the `gel ui` command start failing once you restart the container. I recommend the following options: + +1. Use a docker-compose template with two services: one for the CLI and one for the Gel database instance. + + You can either use the [javascript-node-edgedb](https://github.com/joshuanianji/devcontainer-templates/blob/main/src/javascript-node-edgedb) or the [rust-edgedb](https://github.com/joshuanianji/devcontainer-templates/blob/main/src/rust-edgedb) templates, or use them as references to make your own. + + Once inside the devcontainer, you can run `gel instance link` to connect the CLI to the instance. Check the templates above for more details. + +2. Connect to a cloud instance [with `gel cloud`](https://docs.edgedb.com/cloud/cli). + +## Notes on Volume Mounts + +This feature mounts the gel config and data folder for persistence. To do so, it makes some assumptions about `gel info`: + +```bash +$ gel info + +Gel uses the following local paths: +┌────────────┬────────────────────────────────────────┐ +│ Cache │ /home//.cache/gel/ │ +│ Config │ /home//.config/gel/ │ +│ CLI Binary │ /home//.local/bin/gel │ +│ Data │ /home//.local/share/gel/data/ │ +│ Service │ /home//.config/systemd/gel/ │ +└────────────┴────────────────────────────────────────┘ +``` + +**These paths may change based on the OS!** This feature is tested on Ubuntu and Debian and the paths match up, but may not work for others. + +## OS and Architecture Support + +Architectures: `amd` and `arm` + +OS: `ubuntu`, `debian` + +Shells: `bash`, `zsh`, `fish` + +## Changelog + +| Version | Notes | +| ------- | ------------------------------------- | +| 1.0.0 | Initial Version (migrate from EdgeDB) | diff --git a/src/gel-cli/README.md b/src/gel-cli/README.md new file mode 100644 index 0000000..6087fa7 --- /dev/null +++ b/src/gel-cli/README.md @@ -0,0 +1,76 @@ + +# EdgeDB (edgedb-cli) + +EdgeDB CLI via the official installation script. Includes the VSCode extension and mounts the config and data folder. + +## Example Usage + +```json +"features": { + "ghcr.io/joshuanianji/devcontainer-features/edgedb-cli:1": {} +} +``` + +## Options + +| Options Id | Description | Type | Default Value | +|-----|-----|-----|-----| + + +## Customizations + +### VS Code Extensions + +- `magicstack.edgedb` + +## Usage + +**The EdgeDB instance should not be in the same container as the CLI.** My experience doing so makes the `edgedb ui` command start failing once you restart the container. I recommend the following options: + +1. Use a docker-compose template with two services: one for the CLI and one for the EdgeDB instance. + + You can either use the [javascript-node-edgedb](https://github.com/joshuanianji/devcontainer-templates/blob/main/src/javascript-node-edgedb) or the [rust-edgedb](https://github.com/joshuanianji/devcontainer-templates/blob/main/src/rust-edgedb) templates, or use them as references to make your own. + + Once inside the devcontainer, you can run `edgedb instance link` to connect the CLI to the instance. Check the templates above for more details. + +2. Connect to a cloud instance [with `edgedb cloud`](https://docs.edgedb.com/cloud/cli). + +## Notes on Volume Mounts + +This feature mounts the edgedb config and data folder for persistence. To do so, it makes some assumptions about `edgedb info`: + +```bash +$ edgedb info + +EdgeDB uses the following local paths: +┌────────────┬────────────────────────────────────────┐ +│ Cache │ /home//.cache/edgedb/ │ +│ Config │ /home//.config/edgedb/ │ +│ CLI Binary │ /home//.local/bin/edgedb │ +│ Data │ /home//.local/share/edgedb/data/ │ +│ Service │ /home//.config/systemd/user/ │ +└────────────┴────────────────────────────────────────┘ +``` + +**These paths may change based on the OS!** This feature is tested on Ubuntu and Debian and the paths match up, but may not work for others. + +## OS and Architecture Support + +Architectures: `amd` and `arm` + +OS: `ubuntu`, `debian` + +Shells: `bash`, `zsh`, `fish` + +## Changelog + +| Version | Notes | +| ------- | -------------------------- | +| 1.0.2 | Cache edgedb config folder | +| 1.0.1 | Fix for non-root users | +| 1.0.0 | Initial Version | + + +--- + +_Note: This file was auto-generated from the [devcontainer-feature.json](https://github.com/joshuanianji/devcontainer-features/blob/main/src/edgedb-cli/devcontainer-feature.json). Add additional notes to a `NOTES.md`._ diff --git a/src/gel-cli/devcontainer-feature.json b/src/gel-cli/devcontainer-feature.json new file mode 100644 index 0000000..de32bc4 --- /dev/null +++ b/src/gel-cli/devcontainer-feature.json @@ -0,0 +1,29 @@ +{ + "name": "EdgeDB", + "id": "edgedb-cli", + "version": "1.0.2", + "documentationURL": "https://github.com/joshuanianji/devcontainer-features/tree/main/src/edgedb-cli", + "description": "EdgeDB CLI via the official installation script. Includes the VSCode extension and mounts the config and data folder.", + "options": {}, + "customizations": { + "vscode": { + "extensions": [ + "magicstack.edgedb" + ] + } + }, + "mounts": [ + { + "source": "${devcontainerId}-edgedb-cli", + "target": "/dc/edgedb-cli", + "type": "volume" + } + ], + "installsAfter": [ + "ghcr.io/devcontainers/features/common-utils", + "ghcr.io/meaningful-ooo/devcontainer-features/fish" + ], + "onCreateCommand": { + "edgedb-cli-setup": "/usr/local/share/edgedb-cli/scripts/oncreate.sh" + } +} \ No newline at end of file diff --git a/src/gel-cli/install.sh b/src/gel-cli/install.sh new file mode 100644 index 0000000..e4fb159 --- /dev/null +++ b/src/gel-cli/install.sh @@ -0,0 +1,92 @@ +#!/bin/sh + +USERNAME=${USERNAME:-${_REMOTE_USER}} + +LIFECYCLE_SCRIPTS_DIR="/usr/local/share/gel-cli/scripts" + +set -e + +# Checks if packages are installed and installs them if not +check_packages() { + if ! dpkg -s "$@" >/dev/null 2>&1; then + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update -y + fi + apt-get -y install --no-install-recommends "$@" + fi +} + +create_cache_dir() { + if [ -d "$1" ]; then + echo "Cache directory $1 already exists. Skip creation..." + else + echo "Create cache directory $1..." + mkdir -p "$1" + fi + + if [ -z "$2" ]; then + echo "No username provided. Skip chown..." + else + echo "Change owner of $1 to $2..." + chown -R "$2:$2" "$1" + fi +} + +create_symlink_dir() { + # local dir is the folder gel will use + # cache_dir is the /dc/gel-cli folder + local local_dir=$1 + local cache_dir=$2 + local username=$3 + + runuser -u "$username" -- mkdir -p "$(dirname "$local_dir")" + runuser -u "$username" -- mkdir -p "$cache_dir" + + # if the folder we want to symlink already exists, the ln -s command will create a folder inside the existing folder + if [ -e "$local_dir" ]; then + echo "Moving existing $local_dir folder to $local_dir-old" + mv "$local_dir" "$local_dir-old" + fi + + echo "Symlink $local_dir to $cache_dir for $username..." + runuser -u "$username" -- ln -s "$cache_dir" "$local_dir" +} + +install_cli() { + local username=$1 + + echo "Installing Gel CLI..." + curl https://www.geldata.com/sh --proto '=https' --tlsv1.2 -sSf -o /tmp/gel-cli.sh + chmod +x /tmp/gel-cli.sh + + # install gel for a specific user if possible + echo "Installing Gel CLI for $username..." + if [ -z "$username" ]; then + /tmp/gel-cli.sh -y + else + runuser -u "$username" -- /tmp/gel-cli.sh -y + fi +} + +export DEBIAN_FRONTEND=noninteractive + +check_packages curl ca-certificates + +# cache data directory +create_cache_dir "/dc/gel-cli/data" "${USERNAME}" +create_symlink_dir "$_REMOTE_USER_HOME/.local/share/gel" "/dc/gel-cli/data" "${USERNAME}" + +# cache config directory +create_cache_dir "/dc/gel-cli/config" "${USERNAME}" +create_symlink_dir "$_REMOTE_USER_HOME/.config/gel" "/dc/gel-cli/config" "${USERNAME}" + +install_cli "${USERNAME}" + +# Set Lifecycle scripts +if [ -f oncreate.sh ]; then + mkdir -p "${LIFECYCLE_SCRIPTS_DIR}" + cp oncreate.sh "${LIFECYCLE_SCRIPTS_DIR}/oncreate.sh" +fi + +echo "Done!" diff --git a/src/gel-cli/oncreate.sh b/src/gel-cli/oncreate.sh new file mode 100644 index 0000000..701795a --- /dev/null +++ b/src/gel-cli/oncreate.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -e + +# if the user is not root, chown /dc/edgedb-cli to the user +if [ "$(id -u)" != "0" ]; then + echo "Running oncreate.sh for user $USER" + sudo chown -R "$USER:$USER" /dc/edgedb-cli +fi From 49ae5d41d71df8312a74b8da2a0f8e3c1bf2d2c9 Mon Sep 17 00:00:00 2001 From: Joshua Ji Date: Thu, 27 Mar 2025 17:20:25 +0000 Subject: [PATCH 2/7] some more fixes --- src/gel-cli/README.md | 76 --------------------------- src/gel-cli/devcontainer-feature.json | 16 +++--- src/gel-cli/oncreate.sh | 2 +- 3 files changed, 9 insertions(+), 85 deletions(-) delete mode 100644 src/gel-cli/README.md diff --git a/src/gel-cli/README.md b/src/gel-cli/README.md deleted file mode 100644 index 6087fa7..0000000 --- a/src/gel-cli/README.md +++ /dev/null @@ -1,76 +0,0 @@ - -# EdgeDB (edgedb-cli) - -EdgeDB CLI via the official installation script. Includes the VSCode extension and mounts the config and data folder. - -## Example Usage - -```json -"features": { - "ghcr.io/joshuanianji/devcontainer-features/edgedb-cli:1": {} -} -``` - -## Options - -| Options Id | Description | Type | Default Value | -|-----|-----|-----|-----| - - -## Customizations - -### VS Code Extensions - -- `magicstack.edgedb` - -## Usage - -**The EdgeDB instance should not be in the same container as the CLI.** My experience doing so makes the `edgedb ui` command start failing once you restart the container. I recommend the following options: - -1. Use a docker-compose template with two services: one for the CLI and one for the EdgeDB instance. - - You can either use the [javascript-node-edgedb](https://github.com/joshuanianji/devcontainer-templates/blob/main/src/javascript-node-edgedb) or the [rust-edgedb](https://github.com/joshuanianji/devcontainer-templates/blob/main/src/rust-edgedb) templates, or use them as references to make your own. - - Once inside the devcontainer, you can run `edgedb instance link` to connect the CLI to the instance. Check the templates above for more details. - -2. Connect to a cloud instance [with `edgedb cloud`](https://docs.edgedb.com/cloud/cli). - -## Notes on Volume Mounts - -This feature mounts the edgedb config and data folder for persistence. To do so, it makes some assumptions about `edgedb info`: - -```bash -$ edgedb info - -EdgeDB uses the following local paths: -┌────────────┬────────────────────────────────────────┐ -│ Cache │ /home//.cache/edgedb/ │ -│ Config │ /home//.config/edgedb/ │ -│ CLI Binary │ /home//.local/bin/edgedb │ -│ Data │ /home//.local/share/edgedb/data/ │ -│ Service │ /home//.config/systemd/user/ │ -└────────────┴────────────────────────────────────────┘ -``` - -**These paths may change based on the OS!** This feature is tested on Ubuntu and Debian and the paths match up, but may not work for others. - -## OS and Architecture Support - -Architectures: `amd` and `arm` - -OS: `ubuntu`, `debian` - -Shells: `bash`, `zsh`, `fish` - -## Changelog - -| Version | Notes | -| ------- | -------------------------- | -| 1.0.2 | Cache edgedb config folder | -| 1.0.1 | Fix for non-root users | -| 1.0.0 | Initial Version | - - ---- - -_Note: This file was auto-generated from the [devcontainer-feature.json](https://github.com/joshuanianji/devcontainer-features/blob/main/src/edgedb-cli/devcontainer-feature.json). Add additional notes to a `NOTES.md`._ diff --git a/src/gel-cli/devcontainer-feature.json b/src/gel-cli/devcontainer-feature.json index de32bc4..5bb7f10 100644 --- a/src/gel-cli/devcontainer-feature.json +++ b/src/gel-cli/devcontainer-feature.json @@ -1,9 +1,9 @@ { - "name": "EdgeDB", - "id": "edgedb-cli", - "version": "1.0.2", - "documentationURL": "https://github.com/joshuanianji/devcontainer-features/tree/main/src/edgedb-cli", - "description": "EdgeDB CLI via the official installation script. Includes the VSCode extension and mounts the config and data folder.", + "name": "Gel CLI", + "id": "gel-cli", + "version": "1.0.0", + "documentationURL": "https://github.com/joshuanianji/devcontainer-features/tree/main/src/gel-cli", + "description": "Gel CLI (previously EdgeDB) via the official installation script. Includes the VSCode extension and mounts the config and data folder.", "options": {}, "customizations": { "vscode": { @@ -14,8 +14,8 @@ }, "mounts": [ { - "source": "${devcontainerId}-edgedb-cli", - "target": "/dc/edgedb-cli", + "source": "${devcontainerId}-gel-cli", + "target": "/dc/gel-cli", "type": "volume" } ], @@ -24,6 +24,6 @@ "ghcr.io/meaningful-ooo/devcontainer-features/fish" ], "onCreateCommand": { - "edgedb-cli-setup": "/usr/local/share/edgedb-cli/scripts/oncreate.sh" + "gel-cli-setup": "/usr/local/share/gel-cli/scripts/oncreate.sh" } } \ No newline at end of file diff --git a/src/gel-cli/oncreate.sh b/src/gel-cli/oncreate.sh index 701795a..869a111 100644 --- a/src/gel-cli/oncreate.sh +++ b/src/gel-cli/oncreate.sh @@ -5,5 +5,5 @@ set -e # if the user is not root, chown /dc/edgedb-cli to the user if [ "$(id -u)" != "0" ]; then echo "Running oncreate.sh for user $USER" - sudo chown -R "$USER:$USER" /dc/edgedb-cli + sudo chown -R "$USER:$USER" /dc/gel-cli fi From ee7988a737bb4f308be270f08fbad4697c7037ff Mon Sep 17 00:00:00 2001 From: Joshua Ji Date: Thu, 27 Mar 2025 17:21:40 +0000 Subject: [PATCH 3/7] deprecation notice --- src/edgedb-cli/NOTES.md | 4 ++++ src/edgedb-cli/devcontainer-feature.json | 1 + 2 files changed, 5 insertions(+) diff --git a/src/edgedb-cli/NOTES.md b/src/edgedb-cli/NOTES.md index c5942f0..1856e45 100644 --- a/src/edgedb-cli/NOTES.md +++ b/src/edgedb-cli/NOTES.md @@ -1,3 +1,7 @@ +## Deprecation Notes + +Please use [joshuanianji/gel-cli](https://github.com/joshuanianji/devcontainer-features/tree/main/src/gel-cli) instead. See: [EdgeDB is now Gel and Postgres is the Future](https://www.geldata.com/blog/edgedb-is-now-gel-and-postgres-is-the-future) + ## Usage **The EdgeDB instance should not be in the same container as the CLI.** My experience doing so makes the `edgedb ui` command start failing once you restart the container. I recommend the following options: diff --git a/src/edgedb-cli/devcontainer-feature.json b/src/edgedb-cli/devcontainer-feature.json index de32bc4..3d4a83c 100644 --- a/src/edgedb-cli/devcontainer-feature.json +++ b/src/edgedb-cli/devcontainer-feature.json @@ -2,6 +2,7 @@ "name": "EdgeDB", "id": "edgedb-cli", "version": "1.0.2", + "deprecated": true, "documentationURL": "https://github.com/joshuanianji/devcontainer-features/tree/main/src/edgedb-cli", "description": "EdgeDB CLI via the official installation script. Includes the VSCode extension and mounts the config and data folder.", "options": {}, From 32a02ff03efaa21f1531d34ad1422689df3ca5b4 Mon Sep 17 00:00:00 2001 From: Joshua Ji Date: Thu, 27 Mar 2025 17:26:07 +0000 Subject: [PATCH 4/7] update root level readme [skip ci] --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 6e039ea..b46efa2 100644 --- a/README.md +++ b/README.md @@ -6,12 +6,12 @@ This repo contains my custom devcontainer features. ## Features -| Feature | Description | -| ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------- | -| [github-cli-persistence](./src/github-cli-persistence) | Avoid extra logins from the Github CLI by preserving the `~/.config/gh` folder across container instances. | -| [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. | -| [gcloud-cli-persistence](./src/gcloud-cli-persistence) | Avoid extra logins from the Google Cloud CLI by preserving the `~/.config/gcloud` 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. | -| [edgedb-cli](./src/edgedb-cli) | EdgeDB CLI via the official installation script. Includes the VSCode extension and mounts ~/.local/share/edgedb for data persistence. | +| Feature | Description | +| ------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ | +| [github-cli-persistence](./src/github-cli-persistence) | Avoid extra logins from the Github CLI by preserving the `~/.config/gh` folder across container instances. | +| [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. | +| [gcloud-cli-persistence](./src/gcloud-cli-persistence) | Avoid extra logins from the Google Cloud CLI by preserving the `~/.config/gcloud` 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. | +| [gel-cli](./src/gel-cli) | Gel CLI (previously EdgeDB) via the official installation script. Includes the VSCode extension as well as a couple mounts for data persistence. | From c85feefb719326159160f0688014f82f2ab1cf39 Mon Sep 17 00:00:00 2001 From: Joshua Ji Date: Thu, 27 Mar 2025 17:52:09 +0000 Subject: [PATCH 5/7] gel cli tests --- test/gel-cli/_default.sh | 38 +++++++++++++++++++++++++++++++++++++ test/gel-cli/scenarios.json | 8 ++++++++ test/gel-cli/test.sh | 12 ++++++++++++ test/gel-cli/with_node.sh | 7 +++++++ 4 files changed, 65 insertions(+) create mode 100644 test/gel-cli/_default.sh create mode 100644 test/gel-cli/scenarios.json create mode 100644 test/gel-cli/test.sh create mode 100644 test/gel-cli/with_node.sh diff --git a/test/gel-cli/_default.sh b/test/gel-cli/_default.sh new file mode 100644 index 0000000..e6b8b46 --- /dev/null +++ b/test/gel-cli/_default.sh @@ -0,0 +1,38 @@ +#!/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 the command is available +check "help" bash -c "gel --help | grep 'Usage'" + +# make sure gel directories match up with our expectations +check "gel cli data dir" bash -c "test \"$(gel info --get data-dir)\" = $HOME/.local/share/gel/data/" +check "gel cli config dir" bash -c "test \"$(gel info --get config-dir)\" = $HOME/.config/gel/" + +# check that data directories exist +check "~/.local/share/gel exists" bash -c "ls -la ~/.local/share | grep 'gel'" +check "/dc/gel-cli/data exists" bash -c "ls -la /dc/gel-cli | grep 'data'" + +# check that config directories exist +check "~/.config/gel exists" bash -c "ls -la ~/.config | grep 'gel'" +check "/dc/gel-cli exists" bash -c "ls -la /dc/gel-cli | grep 'config'" + +# check that the folders are owned by the user +# https://askubuntu.com/a/175060 +# $USER is empty when running as root, so we use $(whoami) +echo "Checking ownership of ~/.local/share/gel/data and /dc/gel-cli/data (ensure it is owned by $(whoami))" + +check "~/.local/share/gel owned by user" bash -c "test \"$(stat -c "%U" ~/.local/share/gel)\" = $(whoami)" +check "/dc/gel-cli/data owned by user" bash -c "test \"$(stat -c "%U" /dc/gel-cli/data)\" = $(whoami)" + +check "~/.config/gel owned by user" bash -c "test \"$(stat -c "%U" ~/.config/gel)\" = $(whoami)" +check "/dc/gel-cli/config owned by user" bash -c "test \"$(stat -c "%U" /dc/gel-cli/config)\" = $(whoami)" + +# Report result +reportResults diff --git a/test/gel-cli/scenarios.json b/test/gel-cli/scenarios.json new file mode 100644 index 0000000..88c5ef6 --- /dev/null +++ b/test/gel-cli/scenarios.json @@ -0,0 +1,8 @@ +{ + "with_node": { + "image": "mcr.microsoft.com/devcontainers/javascript-node:1-18", + "features": { + "gel-cli": {} + } + } +} \ No newline at end of file diff --git a/test/gel-cli/test.sh b/test/gel-cli/test.sh new file mode 100644 index 0000000..62d63ee --- /dev/null +++ b/test/gel-cli/test.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# NOTE: this is an "auto-generated" test, which means it will be +# executed against an auto-generated devcontainer.json that +# includes the feature with no options + +./_default.sh diff --git a/test/gel-cli/with_node.sh b/test/gel-cli/with_node.sh new file mode 100644 index 0000000..1fe2fa4 --- /dev/null +++ b/test/gel-cli/with_node.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 6b8ae9acfc9eb1ec4a987bd337329bb7e699c6c6 Mon Sep 17 00:00:00 2001 From: Joshua Ji Date: Thu, 27 Mar 2025 18:14:23 +0000 Subject: [PATCH 6/7] fix gel cli tests --- src/gel-cli/install.sh | 6 ++++-- test/gel-cli/_default.sh | 12 +++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/gel-cli/install.sh b/src/gel-cli/install.sh index e4fb159..729b697 100644 --- a/src/gel-cli/install.sh +++ b/src/gel-cli/install.sh @@ -73,13 +73,15 @@ export DEBIAN_FRONTEND=noninteractive check_packages curl ca-certificates +# Looks like they kept the config directories the same (edgedb in the paths) + # cache data directory create_cache_dir "/dc/gel-cli/data" "${USERNAME}" -create_symlink_dir "$_REMOTE_USER_HOME/.local/share/gel" "/dc/gel-cli/data" "${USERNAME}" +create_symlink_dir "$_REMOTE_USER_HOME/.local/share/edgedb" "/dc/gel-cli/data" "${USERNAME}" # cache config directory create_cache_dir "/dc/gel-cli/config" "${USERNAME}" -create_symlink_dir "$_REMOTE_USER_HOME/.config/gel" "/dc/gel-cli/config" "${USERNAME}" +create_symlink_dir "$_REMOTE_USER_HOME/.config/edgedb" "/dc/gel-cli/config" "${USERNAME}" install_cli "${USERNAME}" diff --git a/test/gel-cli/_default.sh b/test/gel-cli/_default.sh index e6b8b46..a3336e6 100644 --- a/test/gel-cli/_default.sh +++ b/test/gel-cli/_default.sh @@ -11,9 +11,11 @@ source dev-container-features-test-lib # check that the command is available check "help" bash -c "gel --help | grep 'Usage'" +gel info + # make sure gel directories match up with our expectations -check "gel cli data dir" bash -c "test \"$(gel info --get data-dir)\" = $HOME/.local/share/gel/data/" -check "gel cli config dir" bash -c "test \"$(gel info --get config-dir)\" = $HOME/.config/gel/" +check "gel info data dir" bash -c "test \"$(gel info --get data-dir)\" = $HOME/.local/share/edgedb/data/" +check "gel info config dir" bash -c "test \"$(gel info --get config-dir)\" = $HOME/.config/edgedb/" # check that data directories exist check "~/.local/share/gel exists" bash -c "ls -la ~/.local/share | grep 'gel'" @@ -26,12 +28,12 @@ check "/dc/gel-cli exists" bash -c "ls -la /dc/gel-cli | grep 'config'" # check that the folders are owned by the user # https://askubuntu.com/a/175060 # $USER is empty when running as root, so we use $(whoami) -echo "Checking ownership of ~/.local/share/gel/data and /dc/gel-cli/data (ensure it is owned by $(whoami))" +echo "Checking ownership of ~/.local/share/edgedb/data and /dc/gel-cli/data (ensure it is owned by $(whoami))" -check "~/.local/share/gel owned by user" bash -c "test \"$(stat -c "%U" ~/.local/share/gel)\" = $(whoami)" +check "~/.local/share/edgedb owned by user" bash -c "test \"$(stat -c "%U" ~/.local/share/edgedb)\" = $(whoami)" check "/dc/gel-cli/data owned by user" bash -c "test \"$(stat -c "%U" /dc/gel-cli/data)\" = $(whoami)" -check "~/.config/gel owned by user" bash -c "test \"$(stat -c "%U" ~/.config/gel)\" = $(whoami)" +check "~/.config/edgedb owned by user" bash -c "test \"$(stat -c "%U" ~/.config/edgedb)\" = $(whoami)" check "/dc/gel-cli/config owned by user" bash -c "test \"$(stat -c "%U" /dc/gel-cli/config)\" = $(whoami)" # Report result From 424403d4b60611f9f5290f11a6296a91fd5d38af Mon Sep 17 00:00:00 2001 From: Joshua Ji Date: Thu, 27 Mar 2025 18:17:50 +0000 Subject: [PATCH 7/7] improve echo statements [skip ci] --- test/gel-cli/_default.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/gel-cli/_default.sh b/test/gel-cli/_default.sh index a3336e6..859e88d 100644 --- a/test/gel-cli/_default.sh +++ b/test/gel-cli/_default.sh @@ -28,7 +28,7 @@ check "/dc/gel-cli exists" bash -c "ls -la /dc/gel-cli | grep 'config'" # check that the folders are owned by the user # https://askubuntu.com/a/175060 # $USER is empty when running as root, so we use $(whoami) -echo "Checking ownership of ~/.local/share/edgedb/data and /dc/gel-cli/data (ensure it is owned by $(whoami))" +echo "Checking ownership of data installation paths and mounts (ensure it is owned by $(whoami))" check "~/.local/share/edgedb owned by user" bash -c "test \"$(stat -c "%U" ~/.local/share/edgedb)\" = $(whoami)" check "/dc/gel-cli/data owned by user" bash -c "test \"$(stat -c "%U" /dc/gel-cli/data)\" = $(whoami)"