Skip to content
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
3 changes: 3 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM mcr.microsoft.com/devcontainers/base:1-bookworm

RUN apt-get update && apt-get install -y shellcheck
27 changes: 22 additions & 5 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-in-docker
{
"name": "Docker in Docker",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/javascript-node:0-18",
"build": {
"dockerfile": "Dockerfile"
},

"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {
Expand All @@ -17,11 +18,27 @@
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "npm install -g @devcontainers/cli"
"postCreateCommand": "npm install -g @devcontainers/cli",

// Configure tool-specific properties.
// "customizations": {},
"customizations": {
"vscode": {
"settings": {
"json.schemas": [
{
"fileMatch": [
"*/devcontainer-feature.json"
],
"url": "https://raw.githubusercontent.com/devcontainers/spec/main/schemas/devContainerFeature.schema.json"
}
]
},
"extensions": [
"mads-hartmann.bash-ide-vscode"
]
}
},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
"remoteUser": "node"
}
2 changes: 1 addition & 1 deletion .github/.devcontainer/features
2 changes: 1 addition & 1 deletion .github/workflows/release-features.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
uses: devcontainers/action@v1
with:
publish-features: "true"
base-path-to-features: "./features"
base-path-to-features: "./features/src"
features-namespace: "rails/devcontainer/features"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65 changes: 65 additions & 0 deletions .github/workflows/test-features.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: "CI - Test Features"
on:
push:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
test-autogenerated:
runs-on: ubuntu-latest
continue-on-error: true
strategy:
matrix:
features:
- bun
- mysql-client
- sqlite3
- activestorage
- postgres-client
- ruby
baseImage:
- debian:latest
- ubuntu:latest
- mcr.microsoft.com/devcontainers/base:ubuntu
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 }}'"
working-directory: features
run: devcontainer features test --skip-scenarios -f ${{ matrix.features }} -i ${{ matrix.baseImage }} .

test-scenarios:
runs-on: ubuntu-latest
continue-on-error: true
strategy:
matrix:
features:
- activestorage
- postgres-client
- ruby
steps:
- uses: actions/checkout@v4

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

- name: "Generating tests for '${{ matrix.features }}' scenarios"
working-directory: features
run: devcontainer features test -f ${{ matrix.features }} --skip-autogenerated --skip-duplicated .

shellcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: "Install shellcheck"
run: sudo apt-get update && sudo apt-get install -y shellcheck

- name: "Run shellcheck"
working-directory: features
run: find . -name "*.sh" -type f -exec shellcheck {} +
32 changes: 0 additions & 32 deletions .github/workflows/test-ruby-feature.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions features/bun/install.sh

This file was deleted.

17 changes: 0 additions & 17 deletions features/postgres-client/install.sh

This file was deleted.

33 changes: 0 additions & 33 deletions features/ruby/install.sh

This file was deleted.

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "bun",
"version": "1.0.1",
"version": "1.0.2",
"name": "Bun",
"description": "Installs needed client-side dependencies for Rails apps using Bun"
}
12 changes: 12 additions & 0 deletions features/src/bun/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh
set -e

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

if ! command -v curl > /dev/null 2>&1; then
apt update && apt install -y curl unzip
fi

su "${USERNAME}" -c "curl -fsSL https://bun.sh/install | bash"

rm -rf /var/lib/apt/lists/*
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
#!/bin/sh

# This is a no op
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "postgres-client",
"version": "1.1.2",
"version": "1.1.3",
"name": "Postgres Client",
"description": "Installs needed client-side dependencies for Rails apps using Postgres",
"options": {
Expand Down
21 changes: 21 additions & 0 deletions features/src/postgres-client/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh
set -e

export POSTGRES_CLIENT_VERSION="${VERSION:-"15"}"

apt-get update -qq

apt-get install -y gnupg ca-certificates

client_package="postgresql-client-$POSTGRES_CLIENT_VERSION"

VERSION_EXISTS=$(apt-cache search --names-only "$client_package" | wc -l)

if [ "$VERSION_EXISTS" -ge 1 ]; then
apt-get install --no-install-recommends -y libpq-dev "$client_package"
else
apt-get install --no-install-recommends -y postgresql-common libpq-dev
/usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y && apt-get install --no-install-recommends -y "$client_package"
fi

rm -rf /var/lib/apt/lists/*
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "ruby",
"version": "1.1.1",
"version": "1.1.2",
"name": "Ruby (via rbenv)",
"description": "Installs Ruby, rbenv, ruby-build and libraries needed to build Ruby",
"customizations": {
Expand Down
36 changes: 36 additions & 0 deletions features/src/ruby/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/sh
set -e

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

apt-get update -y
apt-get -y install --no-install-recommends git curl ca-certificates libssl-dev libreadline-dev zlib1g-dev autoconf bison build-essential \
libyaml-dev libncurses5-dev libffi-dev libgdbm-dev libxml2-dev rustc

git clone https://github.com/rbenv/rbenv.git /usr/local/share/rbenv
git clone https://github.com/rbenv/ruby-build.git /usr/local/share/ruby-build

mkdir -p /root/.rbenv/plugins
ln -s /usr/local/share/ruby-build /root/.rbenv/plugins/ruby-build

if [ "${USERNAME}" != "root" ]; then
user_home="/home/${USERNAME}"
mkdir -p "${user_home}/.rbenv/plugins"
ln -s /usr/local/share/ruby-build "${user_home}/.rbenv/plugins/ruby-build"

chown -R "${USERNAME}" "${user_home}/.rbenv/"
chmod -R g+r+w "${user_home}/.rbenv"

# shellcheck disable=SC2016
echo 'eval "$(rbenv init -)"' >> "${user_home}/.bashrc"

if [ -f "${user_home}/.zshrc" ]; then
# shellcheck disable=SC2016
echo 'eval "$(rbenv init -)"' >> "${user_home}/.zshrc"
fi
fi

su "${USERNAME}" -c "/usr/local/share/rbenv/bin/rbenv install $VERSION"
su "${USERNAME}" -c "/usr/local/share/rbenv/bin/rbenv global $VERSION"

rm -rf /var/lib/apt/lists/*
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions features/test/activestorage/image_processor_imagemagick.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
set -e

# shellcheck source=/dev/null
source dev-container-features-test-lib

check "imagemagick is installed" bash -c "convert --version"
check "FFmpeg is installed" bash -c "ffmpeg -version"
check "Poppler is installed" bash -c "pdftoppm -v"

reportResults
10 changes: 10 additions & 0 deletions features/test/activestorage/scenarios.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"image_processor_imagemagick": {
"image": "mcr.microsoft.com/devcontainers/base:1-bookworm",
"features": {
"activestorage": {
"variantProcessor": "mini_magick"
}
}
}
}
12 changes: 12 additions & 0 deletions features/test/activestorage/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
set -e

# shellcheck source=/dev/null
source dev-container-features-test-lib

check "libvips is installed" bash -c "dpkg -l | grep libvips"

check "FFmpeg is installed" bash -c "ffmpeg -version"
check "Poppler is installed" bash -c "pdftoppm -v"

reportResults
10 changes: 10 additions & 0 deletions features/test/bun/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -e

# shellcheck source=/dev/null
source dev-container-features-test-lib

check "Bun is in the PATH" bash -c "which bun"
check "Bun is installed" bash -c "bun --version"

reportResults
11 changes: 11 additions & 0 deletions features/test/mysql-client/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
set -e

# shellcheck source=/dev/null
source dev-container-features-test-lib

check "Mysql client is installed" bash -c "mysql --version"
check "Mysql client is in the PATH" bash -c "which mysql"
check "libmysqlclient-dev is installed" bash -c "dpkg -l | grep libmysqlclient-dev"

reportResults
18 changes: 18 additions & 0 deletions features/test/postgres-client/scenarios.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"version_16": {
"image": "mcr.microsoft.com/devcontainers/base:1-bookworm",
"features": {
"postgres-client": {
"version": "16"
}
}
},
"version_14": {
"image": "mcr.microsoft.com/devcontainers/base:1-bookworm",
"features": {
"postgres-client": {
"version": "14"
}
}
}
}
Loading