Skip to content

Commit 77184b2

Browse files
authored
Merge pull request #5 from RouL/feature-kamal
[CHANGE] New feature "kamal"
2 parents e988cc4 + 2485a68 commit 77184b2

14 files changed

+267
-5
lines changed

.github/workflows/test.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
features:
1717
- bitwarden-cli
1818
- bitwarden-secrets-manager
19+
- vault
1920
baseImage:
2021
- debian:latest
2122
- ubuntu:latest
@@ -29,6 +30,27 @@ jobs:
2930
- name: "Generating tests for '${{ matrix.features }}' against '${{ matrix.baseImage }}'"
3031
run: devcontainer features test --skip-scenarios -f ${{ matrix.features }} -i ${{ matrix.baseImage }} .
3132

33+
test-autogenerated-ruby:
34+
runs-on: ubuntu-latest
35+
continue-on-error: false
36+
strategy:
37+
fail-fast: false
38+
matrix:
39+
features:
40+
- kamal
41+
baseImage:
42+
- mcr.microsoft.com/devcontainers/ruby:latest
43+
- ghcr.io/rails/devcontainer/images/ruby:3.4.2
44+
steps:
45+
- uses: actions/checkout@v4
46+
47+
- name: "Install latest devcontainer CLI"
48+
run: npm install -g @devcontainers/cli
49+
50+
- name: "Generating tests for '${{ matrix.features }}' against '${{ matrix.baseImage }}'"
51+
run: devcontainer features test --skip-scenarios -f ${{ matrix.features }} -i ${{ matrix.baseImage }} .
52+
53+
3254
test-scenarios:
3355
runs-on: ubuntu-latest
3456
continue-on-error: false
@@ -37,6 +59,8 @@ jobs:
3759
features:
3860
- bitwarden-cli
3961
- bitwarden-secrets-manager
62+
- vault
63+
- kamal
4064
steps:
4165
- uses: actions/checkout@v4
4266

bin/test_autogenerated

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,31 @@ set -o nounset
77
SCRIPT_PATH=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
88
BASE_PATH=$( cd -- "$( dirname -- "${SCRIPT_PATH}" )" &> /dev/null && pwd )
99

10-
BASE_IMAGE="${BASE_IMAGE:-mcr.microsoft.com/devcontainers/base:ubuntu}"
10+
BASE_IMAGE_DEFAULT="mcr.microsoft.com/devcontainers/base:ubuntu"
11+
BASE_IMAGES='{
12+
"kamal": "mcr.microsoft.com/devcontainers/ruby:latest"
13+
}'
1114

12-
PARAM_FEATURES=
15+
error() {
16+
echo "ERROR: $@"
17+
echo "USAGE: $0 <feature>"
18+
exit 1
19+
}
1320

14-
if [ $# -gt 0 ]; then
15-
PARAM_FEATURES="--features $@"
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"
1627
fi
1728

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+
1833
cd $BASE_PATH
1934

20-
devcontainer features test --skip-scenarios --skip-duplicated $PARAM_FEATURES --base-image $BASE_IMAGE .
35+
echo $BASE_IMAGE
36+
37+
devcontainer features test --skip-scenarios --skip-duplicated --features $FEATURE --base-image $BASE_IMAGE --project-folder $BASE_PATH

src/kamal/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
# Kamal Deploy (kamal)
3+
4+
Installs Kamal Deploy directly via rubygems.
5+
6+
## Example Usage
7+
8+
```json
9+
"features": {
10+
"ghcr.io/RouL/devcontainer-features/kamal:1": {}
11+
}
12+
```
13+
14+
## Options
15+
16+
| Options Id | Description | Type | Default Value |
17+
|-----|-----|-----|-----|
18+
| version | Provides the version to be installed. Defaults to newest available version. | string | - |
19+
20+
21+
22+
---
23+
24+
_Note: This file was auto-generated from the [devcontainer-feature.json](https://github.com/RouL/devcontainer-features/blob/main/src/kamal/devcontainer-feature.json). Add additional notes to a `NOTES.md`._

src/kamal/devcontainer-feature.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"id": "kamal",
3+
"version": "1.0.0",
4+
"name": "Kamal Deploy",
5+
"description": "Installs Kamal Deploy directly via rubygems.",
6+
"installsAfter": [
7+
"ghcr.io/devcontainers/features/ruby",
8+
"ghcr.io/devcontainers-extra/features/ruby-asdf"
9+
],
10+
"options": {
11+
"version": {
12+
"description": "Provides the version to be installed. Defaults to newest available version.",
13+
"type": "string",
14+
"default": ""
15+
}
16+
}
17+
}

src/kamal/install.sh

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/bin/sh
2+
set -e
3+
4+
GEM_NAME="kamal"
5+
VERSION="${VERSION}"
6+
USERNAME="${USERNAME:-"${_REMOTE_USER:-"automatic"}"}"
7+
8+
error() {
9+
echo "$1" >&2
10+
echo "Exiting..." >&2
11+
exit 1
12+
}
13+
14+
check_ruby_env() {
15+
if command -v ruby > /dev/null; then
16+
export RUBY_ENV="ruby"
17+
elif command -v rbenv > /dev/null; then
18+
export RUBY_ENV="rbenv"
19+
else
20+
error "ERROR: Couldn't find ruby"
21+
fi
22+
}
23+
24+
gem_install() {
25+
PARAMS="$@"
26+
27+
case $RUBY_ENV in
28+
ruby)
29+
su $USERNAME -c "gem install $PARAMS"
30+
;;
31+
rbenv)
32+
su $USERNAME -c "rbenv exec gem install $PARAMS"
33+
;;
34+
esac
35+
}
36+
37+
install() {
38+
VERSION_PARAM=
39+
if [ "$VERSION" != "" ]; then
40+
VERSION_PARAM="--version $VERSION"
41+
fi
42+
43+
gem_install --no-document $VERSION_PARAM $GEM_NAME
44+
}
45+
46+
check_ruby_env
47+
48+
echo "(*) Installing Kamal Deploy ($RUBY_ENV)..."
49+
50+
install
51+
52+
# Clean up
53+
rm -rf /var/lib/apt/lists/*
54+
55+
echo "Done!"

test/kamal/functions.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
set -e
2+
3+
check_kamal_version() {
4+
VERSION="$1"
5+
6+
check "kamal version == $VERSION" bash -c "kamal version | grep -E '^${VERSION//\./\\.}\$' > /dev/null"
7+
}

test/kamal/mcr-ruby3.3-kamal1.9.2.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+
source functions.sh
6+
7+
check_kamal_version "1.9.2"
8+
9+
reportResults

test/kamal/mcr-ruby3.3-kamal2.4.0.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+
source functions.sh
6+
7+
check_kamal_version "2.4.0"
8+
9+
reportResults

test/kamal/mcr-ruby3.3-kamal2.5.0.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+
source functions.sh
6+
7+
check_kamal_version "2.5.0"
8+
9+
reportResults
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+
source functions.sh
6+
7+
check_kamal_version "2.5.0"
8+
9+
reportResults
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+
source functions.sh
6+
7+
check_kamal_version "1.9.2"
8+
9+
reportResults
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+
source functions.sh
6+
7+
check_kamal_version "2.5.0"
8+
9+
reportResults

test/kamal/scenarios.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"mcr-ruby3.3-kamal2.5.0": {
3+
"image": "mcr.microsoft.com/devcontainers/ruby:3.3",
4+
"features": {
5+
"kamal": {
6+
"version": "2.5.0"
7+
}
8+
}
9+
},
10+
"mcr-ruby3.3-kamal2.4.0": {
11+
"image": "mcr.microsoft.com/devcontainers/ruby:3.3",
12+
"features": {
13+
"kamal": {
14+
"version": "2.4.0"
15+
}
16+
}
17+
},
18+
"mcr-ruby3.3-kamal1.9.2": {
19+
"image": "mcr.microsoft.com/devcontainers/ruby:3.3",
20+
"features": {
21+
"kamal": {
22+
"version": "1.9.2"
23+
}
24+
}
25+
},
26+
"rails-ruby3.4.2-kamal2.5.0": {
27+
"image": "ghcr.io/rails/devcontainer/images/ruby:3.4.2",
28+
"features": {
29+
"kamal": {
30+
"version": "2.5.0"
31+
}
32+
}
33+
},
34+
"rails-ruby3.4.2-kamal1.9.2": {
35+
"image": "ghcr.io/rails/devcontainer/images/ruby:3.4.2",
36+
"features": {
37+
"kamal": {
38+
"version": "1.9.2"
39+
}
40+
}
41+
},
42+
"rails-ruby3.3.7-kamal2.5.0": {
43+
"image": "ghcr.io/rails/devcontainer/images/ruby:3.3.7",
44+
"features": {
45+
"kamal": {
46+
"version": "2.5.0"
47+
}
48+
}
49+
}
50+
}

test/kamal/test.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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://rubygems.org/api/v1/gems/kamal.json | jq --raw-output '.version')"
8+
9+
source dev-container-features-test-lib
10+
source functions.sh
11+
12+
check_kamal_version "$CURRENT_VERSION"
13+
14+
reportResults

0 commit comments

Comments
 (0)