Skip to content

Commit 0c2aef8

Browse files
authored
Merge pull request #6 from RouL/feature_mise
[CHANGE] New feature mise
2 parents b5b4111 + bdd6878 commit 0c2aef8

File tree

11 files changed

+213
-2
lines changed

11 files changed

+213
-2
lines changed

.github/workflows/test.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
features:
1717
- bitwarden-cli
1818
- bitwarden-secrets-manager
19+
- mise
1920
- vault
2021
baseImage:
2122
- debian:latest
@@ -59,8 +60,9 @@ jobs:
5960
features:
6061
- bitwarden-cli
6162
- bitwarden-secrets-manager
62-
- vault
6363
- kamal
64+
- mise
65+
- vault
6466
steps:
6567
- uses: actions/checkout@v4
6668

bin/test

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
3+
set -o errexit
4+
set -o pipefail
5+
set -o nounset
6+
7+
SCRIPT_PATH=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
8+
BASE_PATH=$( cd -- "$( dirname -- "${SCRIPT_PATH}" )" &> /dev/null && pwd )
9+
10+
BASE_IMAGE_DEFAULT="mcr.microsoft.com/devcontainers/base:ubuntu"
11+
BASE_IMAGES='{
12+
"kamal": "mcr.microsoft.com/devcontainers/ruby:latest"
13+
}'
14+
15+
error() {
16+
echo "ERROR: $@"
17+
echo "USAGE: $0 <feature>"
18+
exit 1
19+
}
20+
21+
if [ $# -eq 0 ]; then
22+
error "missing feature name"
23+
elif [ $# -gt 1 ]; then
24+
error "you can only test one feature at a time"
25+
elif [[ $1 == +([0-9]) ]]; then
26+
error "a number can't be a features name"
27+
fi
28+
29+
FEATURE="$1"
30+
BASE_IMAGE="${BASE_IMAGE:-$(echo $BASE_IMAGES | jq --raw-output ".$FEATURE // empty")}"
31+
BASE_IMAGE="${BASE_IMAGE:-$BASE_IMAGE_DEFAULT}"
32+
33+
cd $BASE_PATH
34+
35+
echo $BASE_IMAGE
36+
37+
devcontainer features test --skip-duplicated --features $FEATURE --base-image $BASE_IMAGE --project-folder $BASE_PATH

bin/test_scenarios

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ fi
1717

1818
cd $BASE_PATH
1919

20-
devcontainer features test --skip-autogenerated --skip-duplicated $PARAM_FEATURES .
20+
devcontainer features test --skip-autogenerated --skip-duplicated $PARAM_FEATURES --project-folder $BASE_PATH

src/mise/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
# mise-en-place version manager (mise)
3+
4+
Installs mise-en-place version manager.
5+
6+
## Example Usage
7+
8+
```json
9+
"features": {
10+
"ghcr.io/RouL/devcontainer-features/mise:1": {}
11+
}
12+
```
13+
14+
## Options
15+
16+
| Options Id | Description | Type | Default Value |
17+
|-----|-----|-----|-----|
18+
| no_ruby_dependencies | If set to true, the dependencies for building ruby won't be installed. | boolean | false |
19+
| no_python_dependencies | If set to true, the dependencies for building python won't be installed. | boolean | false |
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/devcontainer-feature.json). Add additional notes to a `NOTES.md`._

src/mise/devcontainer-feature.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"id": "mise",
3+
"version": "1.0.0",
4+
"name": "mise-en-place version manager",
5+
"description": "Installs mise-en-place version manager.",
6+
"options": {
7+
"no_ruby_dependencies": {
8+
"description": "If set to true, the dependencies for building ruby won't be installed.",
9+
"type": "boolean",
10+
"default": false
11+
},
12+
"no_python_dependencies": {
13+
"description": "If set to true, the dependencies for building python won't be installed.",
14+
"type": "boolean",
15+
"default": false
16+
}
17+
}
18+
}

src/mise/install.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/bash
2+
set -e
3+
4+
USERNAME="${USERNAME:-"${_REMOTE_USER:-"automatic"}"}"
5+
6+
REQUIRED_PACKAGES="curl sudo ca-certificates build-essential"
7+
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"
8+
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"
9+
10+
apt_get_update()
11+
{
12+
if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then
13+
echo "Running apt-get update..."
14+
apt-get update -y
15+
fi
16+
}
17+
18+
check_packages() {
19+
if ! dpkg -s "$@" > /dev/null 2>&1; then
20+
apt_get_update
21+
apt-get -y install --no-install-recommends "$@"
22+
fi
23+
}
24+
25+
export DEBIAN_FRONTEND=noninteractive
26+
27+
INSTALL_PACKAGES="$REQUIRED_PACKAGES"
28+
29+
if [ "$NO_RUBY_DEPENDENCIES" != "true" ]; then
30+
INSTALL_PACKAGES="$INSTALL_PACKAGES $RUBY_BUILD_DEPENDENCIES"
31+
fi
32+
33+
if [ "$NO_PYTHON_DEPENDENCIES" != "true" ]; then
34+
INSTALL_PACKAGES="$INSTALL_PACKAGES $PYTHON_BUILD_DEPENDENCIES"
35+
fi
36+
37+
check_packages $INSTALL_PACKAGES
38+
39+
install() {
40+
curl https://mise.run | MISE_INSTALL_PATH=/usr/local/bin/mise sh
41+
eval "$(mise activate bash)"
42+
mise doctor
43+
cat > /etc/profile.d/mise.sh << EOF
44+
if [ -n "\$ZSH_VERSION" ]; then
45+
eval "\$(mise activate zsh)"
46+
elif [ -n "\$BASH_VERSION" ]; then
47+
eval "\$(mise activate bash)"
48+
fi
49+
EOF
50+
}
51+
52+
echo "(*) Installing mise-on-place..."
53+
54+
install
55+
56+
# Clean up
57+
rm -rf /var/lib/apt/lists/*
58+
59+
echo "Done!"

test/mise/go_latest.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
set -e
3+
4+
source dev-container-features-test-lib
5+
6+
check "install go@latest" bash -c "mise install go@latest"
7+
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]+) '"
8+
9+
reportResults

test/mise/node_latest.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
set -e
3+
4+
source dev-container-features-test-lib
5+
6+
check "install node@latest" bash -c "mise install node@latest"
7+
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]+)\$'"
8+
9+
reportResults

test/mise/python_latest.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
set -e
3+
4+
source dev-container-features-test-lib
5+
6+
check "install python@latest" bash -c "mise install python@latest"
7+
check "check python@latest" bash -c "mise exec python@latest -- python --version | grep -E '^Python 3\\.'"
8+
9+
reportResults

test/mise/scenarios.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"go_latest": {
3+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
4+
"features": {
5+
"mise": {
6+
"no_python_dependencies": "true",
7+
"no_ruby_dependencies": "true"
8+
}
9+
}
10+
},
11+
"python_latest": {
12+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
13+
"features": {
14+
"mise": {
15+
"no_ruby_dependencies": "true"
16+
}
17+
}
18+
},
19+
"node_latest": {
20+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
21+
"features": {
22+
"mise": {
23+
"no_python_dependencies": "true",
24+
"no_ruby_dependencies": "true"
25+
}
26+
}
27+
}
28+
}

test/mise/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/jdx/mise/releases/latest | jq --raw-output '.tag_name')"
8+
CURRENT_VERSION="${CURRENT_VERSION#v}"
9+
10+
source dev-container-features-test-lib
11+
12+
check "mise --version == $CURRENT_VERSION" bash -c "mise --version | grep -E '^${CURRENT_VERSION//\./\\.} '"
13+
check "mise doctor" bash -c "mise doctor"
14+
15+
reportResults

0 commit comments

Comments
 (0)