Skip to content

Commit 13eceed

Browse files
authored
Merge pull request #14 from RouL/feature_mise-ruby
[CHANGE] New feature "mise-ruby"
2 parents e60a6e4 + e288762 commit 13eceed

File tree

9 files changed

+146
-1
lines changed

9 files changed

+146
-1
lines changed

.github/workflows/test.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
- mise-golang
2222
- mise-node
2323
- mise-python
24+
- mise-ruby
2425
- mise-rust
2526
- vault
2627
baseImage:
@@ -71,6 +72,7 @@ jobs:
7172
- mise-golang
7273
- mise-node
7374
- mise-python
75+
- mise-ruby
7476
- mise-rust
7577
- vault
7678
steps:

src/mise-ruby/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
# Ruby (mise) (mise-ruby)
3+
4+
Installs Ruby via mise-en-place version manager.
5+
6+
## Example Usage
7+
8+
```json
9+
"features": {
10+
"ghcr.io/RouL/devcontainer-features/mise-ruby:1": {}
11+
}
12+
```
13+
14+
## Options
15+
16+
| Options Id | Description | Type | Default Value |
17+
|-----|-----|-----|-----|
18+
| version | Version to be installed as default. | string | latest |
19+
| extra_versions | Additional versions to be installed. (space separated) | string | - |
20+
21+
22+
23+
---
24+
25+
_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`._
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"id": "mise-ruby",
3+
"version": "1.0.0",
4+
"name": "Ruby (mise)",
5+
"description": "Installs Ruby via mise-en-place version manager.",
6+
"dependsOn": {
7+
"ghcr.io/RouL/devcontainer-features/mise:latest": {}
8+
},
9+
"options": {
10+
"version": {
11+
"description": "Version to be installed as default.",
12+
"type": "string",
13+
"default": "latest"
14+
},
15+
"extra_versions": {
16+
"description": "Additional versions to be installed. (space separated)",
17+
"type": "string",
18+
"default": ""
19+
}
20+
}
21+
}

src/mise-ruby/install.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/bash
2+
set -e
3+
4+
USERNAME="${USERNAME:-"${_REMOTE_USER:-"automatic"}"}"
5+
VERSION="${VERSION:-latest}"
6+
7+
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"
8+
9+
apt_get_update()
10+
{
11+
if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then
12+
echo "Running apt-get update..."
13+
apt-get update -y
14+
fi
15+
}
16+
17+
check_packages() {
18+
if ! dpkg -s "$@" > /dev/null 2>&1; then
19+
apt_get_update
20+
apt-get -y install --no-install-recommends "$@"
21+
fi
22+
}
23+
24+
export DEBIAN_FRONTEND=noninteractive
25+
26+
check_packages $REQUIRED_PACKAGES
27+
28+
install() {
29+
su ${USERNAME} -c "mise use --global ruby@${VERSION}"
30+
}
31+
32+
echo "(*) Installing Ruby (${VERSION}) via mise as default..."
33+
34+
install
35+
36+
for extraVersion in $EXTRA_VERSIONS
37+
do
38+
echo "(*) Installung Ruby (${extraVersion}) via mise"
39+
su ${USERNAME} -c "mise install ruby@${extraVersion}"
40+
done
41+
42+
# Clean up
43+
rm -rf /var/lib/apt/lists/*
44+
45+
echo "Done!"

test/mise-bun/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ CURRENT_VERSION="${CURRENT_VERSION#bun-v}"
99

1010
source dev-container-features-test-lib
1111

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

1414
reportResults

test/mise-ruby/ruby3.3.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
set -e
3+
4+
source dev-container-features-test-lib
5+
6+
check "check default ruby == 3.3.*" bash -c "ruby --version | grep -E '^ruby 3\\.3\\.'"
7+
8+
reportResults
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
set -e
3+
4+
source dev-container-features-test-lib
5+
6+
check "check default ruby == 3.4.*" bash -c "ruby --version | grep -E '^ruby 3\\.4\\.'"
7+
check "check ruby 3.3.*" bash -c "mise exec [email protected] -- ruby --version | grep -E '^ruby 3\\.3\\.'"
8+
check "check ruby 3.2.*" bash -c "mise exec [email protected] -- ruby --version | grep -E '^ruby 3\\.2\\.'"
9+
10+
reportResults

test/mise-ruby/scenarios.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"ruby3.3": {
3+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
4+
"features": {
5+
"mise-ruby": {
6+
"version": "3.3"
7+
}
8+
}
9+
},
10+
"ruby3.4_ruby3.3_ruby3.2": {
11+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
12+
"features": {
13+
"mise-ruby": {
14+
"version": "3.4",
15+
"extra_versions": "3.3 3.2"
16+
}
17+
}
18+
}
19+
}

test/mise-ruby/test.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
set -e
3+
4+
sudo apt-get update -y > /dev/null
5+
sudo apt-get install -y curl jq ca-certificates > /dev/null
6+
7+
CURRENT_VERSION="$(curl -L --no-progress-meter https://api.github.com/repos/ruby/ruby/releases/latest | jq --raw-output '.tag_name')"
8+
CURRENT_VERSION="${CURRENT_VERSION//_/.}"
9+
CURRENT_VERSION="${CURRENT_VERSION#v}"
10+
11+
source dev-container-features-test-lib
12+
13+
check "check default ruby == latest ($CURRENT_VERSION)" bash -c "ruby --version | grep -E '^ruby ${CURRENT_VERSION//\./\\.} '"
14+
15+
reportResults

0 commit comments

Comments
 (0)