Skip to content

[CHANGE] New feature "kamal" #5

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 15, 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
24 changes: 24 additions & 0 deletions .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
- vault
baseImage:
- debian:latest
- ubuntu:latest
Expand All @@ -29,6 +30,27 @@ jobs:
- name: "Generating tests for '${{ matrix.features }}' against '${{ matrix.baseImage }}'"
run: devcontainer features test --skip-scenarios -f ${{ matrix.features }} -i ${{ matrix.baseImage }} .

test-autogenerated-ruby:
runs-on: ubuntu-latest
continue-on-error: false
strategy:
fail-fast: false
matrix:
features:
- kamal
baseImage:
- mcr.microsoft.com/devcontainers/ruby:latest
- ghcr.io/rails/devcontainer/images/ruby:3.4.2
steps:
- uses: actions/checkout@v4

- name: "Install latest devcontainer CLI"
run: npm install -g @devcontainers/cli

- name: "Generating tests for '${{ matrix.features }}' against '${{ matrix.baseImage }}'"
run: devcontainer features test --skip-scenarios -f ${{ matrix.features }} -i ${{ matrix.baseImage }} .


test-scenarios:
runs-on: ubuntu-latest
continue-on-error: false
Expand All @@ -37,6 +59,8 @@ jobs:
features:
- bitwarden-cli
- bitwarden-secrets-manager
- vault
- kamal
steps:
- uses: actions/checkout@v4

Expand Down
27 changes: 22 additions & 5 deletions bin/test_autogenerated
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,31 @@ set -o nounset
SCRIPT_PATH=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
BASE_PATH=$( cd -- "$( dirname -- "${SCRIPT_PATH}" )" &> /dev/null && pwd )

BASE_IMAGE="${BASE_IMAGE:-mcr.microsoft.com/devcontainers/base:ubuntu}"
BASE_IMAGE_DEFAULT="mcr.microsoft.com/devcontainers/base:ubuntu"
BASE_IMAGES='{
"kamal": "mcr.microsoft.com/devcontainers/ruby:latest"
}'

PARAM_FEATURES=
error() {
echo "ERROR: $@"
echo "USAGE: $0 <feature>"
exit 1
}

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

devcontainer features test --skip-scenarios --skip-duplicated $PARAM_FEATURES --base-image $BASE_IMAGE .
echo $BASE_IMAGE

devcontainer features test --skip-scenarios --skip-duplicated --features $FEATURE --base-image $BASE_IMAGE --project-folder $BASE_PATH
24 changes: 24 additions & 0 deletions src/kamal/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

# Kamal Deploy (kamal)

Installs Kamal Deploy directly via rubygems.

## Example Usage

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

## Options

| Options Id | Description | Type | Default Value |
|-----|-----|-----|-----|
| version | Provides the version to be installed. Defaults to newest available version. | string | - |



---

_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`._
17 changes: 17 additions & 0 deletions src/kamal/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"id": "kamal",
"version": "1.0.0",
"name": "Kamal Deploy",
"description": "Installs Kamal Deploy directly via rubygems.",
"installsAfter": [
"ghcr.io/devcontainers/features/ruby",
"ghcr.io/devcontainers-extra/features/ruby-asdf"
],
"options": {
"version": {
"description": "Provides the version to be installed. Defaults to newest available version.",
"type": "string",
"default": ""
}
}
}
55 changes: 55 additions & 0 deletions src/kamal/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/sh
set -e

GEM_NAME="kamal"
VERSION="${VERSION}"
USERNAME="${USERNAME:-"${_REMOTE_USER:-"automatic"}"}"

error() {
echo "$1" >&2
echo "Exiting..." >&2
exit 1
}

check_ruby_env() {
if command -v ruby > /dev/null; then
export RUBY_ENV="ruby"
elif command -v rbenv > /dev/null; then
export RUBY_ENV="rbenv"
else
error "ERROR: Couldn't find ruby"
fi
}

gem_install() {
PARAMS="$@"

case $RUBY_ENV in
ruby)
su $USERNAME -c "gem install $PARAMS"
;;
rbenv)
su $USERNAME -c "rbenv exec gem install $PARAMS"
;;
esac
}

install() {
VERSION_PARAM=
if [ "$VERSION" != "" ]; then
VERSION_PARAM="--version $VERSION"
fi

gem_install --no-document $VERSION_PARAM $GEM_NAME
}

check_ruby_env

echo "(*) Installing Kamal Deploy ($RUBY_ENV)..."

install

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

echo "Done!"
7 changes: 7 additions & 0 deletions test/kamal/functions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
set -e

check_kamal_version() {
VERSION="$1"

check "kamal version == $VERSION" bash -c "kamal version | grep -E '^${VERSION//\./\\.}\$' > /dev/null"
}
9 changes: 9 additions & 0 deletions test/kamal/mcr-ruby3.3-kamal1.9.2.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
source functions.sh

check_kamal_version "1.9.2"

reportResults
9 changes: 9 additions & 0 deletions test/kamal/mcr-ruby3.3-kamal2.4.0.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
source functions.sh

check_kamal_version "2.4.0"

reportResults
9 changes: 9 additions & 0 deletions test/kamal/mcr-ruby3.3-kamal2.5.0.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
source functions.sh

check_kamal_version "2.5.0"

reportResults
9 changes: 9 additions & 0 deletions test/kamal/rails-ruby3.3.7-kamal2.5.0.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
source functions.sh

check_kamal_version "2.5.0"

reportResults
9 changes: 9 additions & 0 deletions test/kamal/rails-ruby3.4.2-kamal1.9.2.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
source functions.sh

check_kamal_version "1.9.2"

reportResults
9 changes: 9 additions & 0 deletions test/kamal/rails-ruby3.4.2-kamal2.5.0.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
source functions.sh

check_kamal_version "2.5.0"

reportResults
50 changes: 50 additions & 0 deletions test/kamal/scenarios.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"mcr-ruby3.3-kamal2.5.0": {
"image": "mcr.microsoft.com/devcontainers/ruby:3.3",
"features": {
"kamal": {
"version": "2.5.0"
}
}
},
"mcr-ruby3.3-kamal2.4.0": {
"image": "mcr.microsoft.com/devcontainers/ruby:3.3",
"features": {
"kamal": {
"version": "2.4.0"
}
}
},
"mcr-ruby3.3-kamal1.9.2": {
"image": "mcr.microsoft.com/devcontainers/ruby:3.3",
"features": {
"kamal": {
"version": "1.9.2"
}
}
},
"rails-ruby3.4.2-kamal2.5.0": {
"image": "ghcr.io/rails/devcontainer/images/ruby:3.4.2",
"features": {
"kamal": {
"version": "2.5.0"
}
}
},
"rails-ruby3.4.2-kamal1.9.2": {
"image": "ghcr.io/rails/devcontainer/images/ruby:3.4.2",
"features": {
"kamal": {
"version": "1.9.2"
}
}
},
"rails-ruby3.3.7-kamal2.5.0": {
"image": "ghcr.io/rails/devcontainer/images/ruby:3.3.7",
"features": {
"kamal": {
"version": "2.5.0"
}
}
}
}
14 changes: 14 additions & 0 deletions test/kamal/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/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://rubygems.org/api/v1/gems/kamal.json | jq --raw-output '.version')"

source dev-container-features-test-lib
source functions.sh

check_kamal_version "$CURRENT_VERSION"

reportResults
Loading