diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index dabe728..dfe9c4a 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,6 +16,7 @@ jobs: features: - bitwarden-cli - bitwarden-secrets-manager + - mise - vault baseImage: - debian:latest @@ -59,8 +60,9 @@ jobs: features: - bitwarden-cli - bitwarden-secrets-manager - - vault - kamal + - mise + - vault steps: - uses: actions/checkout@v4 diff --git a/bin/test b/bin/test new file mode 100755 index 0000000..a224345 --- /dev/null +++ b/bin/test @@ -0,0 +1,37 @@ +#!/bin/bash + +set -o errexit +set -o pipefail +set -o nounset + +SCRIPT_PATH=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +BASE_PATH=$( cd -- "$( dirname -- "${SCRIPT_PATH}" )" &> /dev/null && pwd ) + +BASE_IMAGE_DEFAULT="mcr.microsoft.com/devcontainers/base:ubuntu" +BASE_IMAGES='{ + "kamal": "mcr.microsoft.com/devcontainers/ruby:latest" +}' + +error() { + echo "ERROR: $@" + echo "USAGE: $0 " + exit 1 +} + +if [ $# -eq 0 ]; then + error "missing feature name" +elif [ $# -gt 1 ]; then + error "you can only test one feature at a time" +elif [[ $1 == +([0-9]) ]]; then + error "a number can't be a features name" +fi + +FEATURE="$1" +BASE_IMAGE="${BASE_IMAGE:-$(echo $BASE_IMAGES | jq --raw-output ".$FEATURE // empty")}" +BASE_IMAGE="${BASE_IMAGE:-$BASE_IMAGE_DEFAULT}" + +cd $BASE_PATH + +echo $BASE_IMAGE + +devcontainer features test --skip-duplicated --features $FEATURE --base-image $BASE_IMAGE --project-folder $BASE_PATH diff --git a/bin/test_scenarios b/bin/test_scenarios index 88b9cbe..9dae56e 100755 --- a/bin/test_scenarios +++ b/bin/test_scenarios @@ -17,4 +17,4 @@ fi cd $BASE_PATH -devcontainer features test --skip-autogenerated --skip-duplicated $PARAM_FEATURES . +devcontainer features test --skip-autogenerated --skip-duplicated $PARAM_FEATURES --project-folder $BASE_PATH diff --git a/src/mise/README.md b/src/mise/README.md new file mode 100644 index 0000000..0556adc --- /dev/null +++ b/src/mise/README.md @@ -0,0 +1,25 @@ + +# mise-en-place version manager (mise) + +Installs mise-en-place version manager. + +## Example Usage + +```json +"features": { + "ghcr.io/RouL/devcontainer-features/mise:1": {} +} +``` + +## Options + +| Options Id | Description | Type | Default Value | +|-----|-----|-----|-----| +| no_ruby_dependencies | If set to true, the dependencies for building ruby won't be installed. | boolean | false | +| no_python_dependencies | If set to true, the dependencies for building python won't be installed. | boolean | false | + + + +--- + +_Note: This file was auto-generated from the [devcontainer-feature.json](https://github.com/RouL/devcontainer-features/blob/main/src/mise/devcontainer-feature.json). Add additional notes to a `NOTES.md`._ diff --git a/src/mise/devcontainer-feature.json b/src/mise/devcontainer-feature.json new file mode 100644 index 0000000..a3c7996 --- /dev/null +++ b/src/mise/devcontainer-feature.json @@ -0,0 +1,18 @@ +{ + "id": "mise", + "version": "1.0.0", + "name": "mise-en-place version manager", + "description": "Installs mise-en-place version manager.", + "options": { + "no_ruby_dependencies": { + "description": "If set to true, the dependencies for building ruby won't be installed.", + "type": "boolean", + "default": false + }, + "no_python_dependencies": { + "description": "If set to true, the dependencies for building python won't be installed.", + "type": "boolean", + "default": false + } + } +} diff --git a/src/mise/install.sh b/src/mise/install.sh new file mode 100755 index 0000000..53cd3d6 --- /dev/null +++ b/src/mise/install.sh @@ -0,0 +1,59 @@ +#!/usr/bin/bash +set -e + +USERNAME="${USERNAME:-"${_REMOTE_USER:-"automatic"}"}" + +REQUIRED_PACKAGES="curl sudo ca-certificates build-essential" +RUBY_BUILD_DEPENDENCIES="autoconf patch build-essential rustc libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libgmp-dev libncurses5-dev libffi-dev libgdbm6 libgdbm-dev libdb-dev uuid-dev libffi-dev" +PYTHON_BUILD_DEPENDENCIES="libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev curl git libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev" + +apt_get_update() +{ + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update -y + fi +} + +check_packages() { + if ! dpkg -s "$@" > /dev/null 2>&1; then + apt_get_update + apt-get -y install --no-install-recommends "$@" + fi +} + +export DEBIAN_FRONTEND=noninteractive + +INSTALL_PACKAGES="$REQUIRED_PACKAGES" + +if [ "$NO_RUBY_DEPENDENCIES" != "true" ]; then + INSTALL_PACKAGES="$INSTALL_PACKAGES $RUBY_BUILD_DEPENDENCIES" +fi + +if [ "$NO_PYTHON_DEPENDENCIES" != "true" ]; then + INSTALL_PACKAGES="$INSTALL_PACKAGES $PYTHON_BUILD_DEPENDENCIES" +fi + +check_packages $INSTALL_PACKAGES + +install() { + curl https://mise.run | MISE_INSTALL_PATH=/usr/local/bin/mise sh + eval "$(mise activate bash)" + mise doctor + cat > /etc/profile.d/mise.sh << EOF +if [ -n "\$ZSH_VERSION" ]; then + eval "\$(mise activate zsh)" +elif [ -n "\$BASH_VERSION" ]; then + eval "\$(mise activate bash)" +fi +EOF +} + +echo "(*) Installing mise-on-place..." + +install + +# Clean up +rm -rf /var/lib/apt/lists/* + +echo "Done!" diff --git a/test/mise/go_latest.sh b/test/mise/go_latest.sh new file mode 100644 index 0000000..bb732d4 --- /dev/null +++ b/test/mise/go_latest.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -e + +source dev-container-features-test-lib + +check "install go@latest" bash -c "mise install go@latest" +check "check go@latest" bash -c "mise exec go@latest -- go version | grep -E '^go version go[1-9][0-9]*\\.([0-9]|[1-9][0-9]+)\\.([0-9]|[1-9][0-9]+) '" + +reportResults diff --git a/test/mise/node_latest.sh b/test/mise/node_latest.sh new file mode 100644 index 0000000..c179127 --- /dev/null +++ b/test/mise/node_latest.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -e + +source dev-container-features-test-lib + +check "install node@latest" bash -c "mise install node@latest" +check "check node@latest" bash -c "mise exec node@latest -- node --version | grep -E '^v[1-9][0-9]*\\.([0-9]|[1-9][0-9]+)\\.([0-9]|[1-9][0-9]+)\$'" + +reportResults diff --git a/test/mise/python_latest.sh b/test/mise/python_latest.sh new file mode 100644 index 0000000..3a14060 --- /dev/null +++ b/test/mise/python_latest.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -e + +source dev-container-features-test-lib + +check "install python@latest" bash -c "mise install python@latest" +check "check python@latest" bash -c "mise exec python@latest -- python --version | grep -E '^Python 3\\.'" + +reportResults diff --git a/test/mise/scenarios.json b/test/mise/scenarios.json new file mode 100644 index 0000000..892f3ef --- /dev/null +++ b/test/mise/scenarios.json @@ -0,0 +1,28 @@ +{ + "go_latest": { + "image": "mcr.microsoft.com/devcontainers/base:ubuntu", + "features": { + "mise": { + "no_python_dependencies": "true", + "no_ruby_dependencies": "true" + } + } + }, + "python_latest": { + "image": "mcr.microsoft.com/devcontainers/base:ubuntu", + "features": { + "mise": { + "no_ruby_dependencies": "true" + } + } + }, + "node_latest": { + "image": "mcr.microsoft.com/devcontainers/base:ubuntu", + "features": { + "mise": { + "no_python_dependencies": "true", + "no_ruby_dependencies": "true" + } + } + } +} diff --git a/test/mise/test.sh b/test/mise/test.sh new file mode 100644 index 0000000..2b8d770 --- /dev/null +++ b/test/mise/test.sh @@ -0,0 +1,15 @@ +#!/bin/bash +set -e + +sudo apt-get update -y > /dev/null +sudo apt-get install -y curl jq ca-certificates > /dev/null + +CURRENT_VERSION="$(curl -L --no-progress-meter https://api.github.com/repos/jdx/mise/releases/latest | jq --raw-output '.tag_name')" +CURRENT_VERSION="${CURRENT_VERSION#v}" + +source dev-container-features-test-lib + +check "mise --version == $CURRENT_VERSION" bash -c "mise --version | grep -E '^${CURRENT_VERSION//\./\\.} '" +check "mise doctor" bash -c "mise doctor" + +reportResults