Skip to content

[CHANGE] New feature "mise-ruby" #14

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
2 changes: 2 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
- mise-golang
- mise-node
- mise-python
- mise-ruby
- mise-rust
- vault
baseImage:
Expand Down Expand Up @@ -71,6 +72,7 @@ jobs:
- mise-golang
- mise-node
- mise-python
- mise-ruby
- mise-rust
- vault
steps:
Expand Down
25 changes: 25 additions & 0 deletions src/mise-ruby/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

# Ruby (mise) (mise-ruby)

Installs Ruby via mise-en-place version manager.

## Example Usage

```json
"features": {
"ghcr.io/RouL/devcontainer-features/mise-ruby:1": {}
}
```

## Options

| Options Id | Description | Type | Default Value |
|-----|-----|-----|-----|
| version | Version to be installed as default. | string | latest |
| extra_versions | Additional versions to be installed. (space separated) | string | - |



---

_Note: This file was auto-generated from the [devcontainer-feature.json](https://github.com/RouL/devcontainer-features/blob/main/src/mise-ruby/devcontainer-feature.json). Add additional notes to a `NOTES.md`._
21 changes: 21 additions & 0 deletions src/mise-ruby/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"id": "mise-ruby",
"version": "1.0.0",
"name": "Ruby (mise)",
"description": "Installs Ruby via mise-en-place version manager.",
"dependsOn": {
"ghcr.io/RouL/devcontainer-features/mise:latest": {}
},
"options": {
"version": {
"description": "Version to be installed as default.",
"type": "string",
"default": "latest"
},
"extra_versions": {
"description": "Additional versions to be installed. (space separated)",
"type": "string",
"default": ""
}
}
}
45 changes: 45 additions & 0 deletions src/mise-ruby/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/bash
set -e

USERNAME="${USERNAME:-"${_REMOTE_USER:-"automatic"}"}"
VERSION="${VERSION:-latest}"

REQUIRED_PACKAGES="build-essential git ca-certificates autoconf patch libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libgmp-dev libncurses5-dev libffi-dev libgdbm6 libgdbm-dev libdb-dev uuid-dev libffi-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

check_packages $REQUIRED_PACKAGES

install() {
su ${USERNAME} -c "mise use --global ruby@${VERSION}"
}

echo "(*) Installing Ruby (${VERSION}) via mise as default..."

install

for extraVersion in $EXTRA_VERSIONS
do
echo "(*) Installung Ruby (${extraVersion}) via mise"
su ${USERNAME} -c "mise install ruby@${extraVersion}"
done

# Clean up
rm -rf /var/lib/apt/lists/*

echo "Done!"
2 changes: 1 addition & 1 deletion test/mise-bun/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ CURRENT_VERSION="${CURRENT_VERSION#bun-v}"

source dev-container-features-test-lib

check "check default bun == latest ($CURRENT_VERSION)" bash -c "bun --version | grep -E '^${CURRENT_VERSION//\./\\.}$'"
check "check default bun == latest ($CURRENT_VERSION)" bash -c "bun --version | grep -E '^${CURRENT_VERSION//\./\\.}\$'"

reportResults
8 changes: 8 additions & 0 deletions test/mise-ruby/ruby3.3.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -e

source dev-container-features-test-lib

check "check default ruby == 3.3.*" bash -c "ruby --version | grep -E '^ruby 3\\.3\\.'"

reportResults
10 changes: 10 additions & 0 deletions test/mise-ruby/ruby3.4_ruby3.3_ruby3.2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -e

source dev-container-features-test-lib

check "check default ruby == 3.4.*" bash -c "ruby --version | grep -E '^ruby 3\\.4\\.'"
check "check ruby 3.3.*" bash -c "mise exec ruby@3.3 -- ruby --version | grep -E '^ruby 3\\.3\\.'"
check "check ruby 3.2.*" bash -c "mise exec ruby@3.2 -- ruby --version | grep -E '^ruby 3\\.2\\.'"

reportResults
19 changes: 19 additions & 0 deletions test/mise-ruby/scenarios.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"ruby3.3": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"mise-ruby": {
"version": "3.3"
}
}
},
"ruby3.4_ruby3.3_ruby3.2": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"mise-ruby": {
"version": "3.4",
"extra_versions": "3.3 3.2"
}
}
}
}
15 changes: 15 additions & 0 deletions test/mise-ruby/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/ruby/ruby/releases/latest | jq --raw-output '.tag_name')"
CURRENT_VERSION="${CURRENT_VERSION//_/.}"
CURRENT_VERSION="${CURRENT_VERSION#v}"

source dev-container-features-test-lib

check "check default ruby == latest ($CURRENT_VERSION)" bash -c "ruby --version | grep -E '^ruby ${CURRENT_VERSION//\./\\.} '"

reportResults