Skip to content

[CHANGE] New feature mise #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
features:
- bitwarden-cli
- bitwarden-secrets-manager
- mise
- vault
baseImage:
- debian:latest
Expand Down Expand Up @@ -59,8 +60,9 @@ jobs:
features:
- bitwarden-cli
- bitwarden-secrets-manager
- vault
- kamal
- mise
- vault
steps:
- uses: actions/checkout@v4

Expand Down
37 changes: 37 additions & 0 deletions bin/test
Original file line number Diff line number Diff line change
@@ -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 <feature>"
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
2 changes: 1 addition & 1 deletion bin/test_scenarios
Original file line number Diff line number Diff line change
Expand Up @@ -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
25 changes: 25 additions & 0 deletions src/mise/README.md
Original file line number Diff line number Diff line change
@@ -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`._
18 changes: 18 additions & 0 deletions src/mise/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -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
}
}
}
59 changes: 59 additions & 0 deletions src/mise/install.sh
Original file line number Diff line number Diff line change
@@ -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!"
9 changes: 9 additions & 0 deletions test/mise/go_latest.sh
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions test/mise/node_latest.sh
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions test/mise/python_latest.sh
Original file line number Diff line number Diff line change
@@ -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
28 changes: 28 additions & 0 deletions test/mise/scenarios.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
}
15 changes: 15 additions & 0 deletions test/mise/test.sh
Original file line number Diff line number Diff line change
@@ -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