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
55 changes: 55 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
name: "Test Kitchen"

"on":
push:
branches: [main]
pull_request:
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
kitchen:
name: "kitchen verify on Ruby ${{ matrix.ruby }}"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# The ends of the supported range. The unit and feature suites already
# cover everything in between; this job is about the Test Kitchen
# integration, not Ruby compatibility.
ruby: ["3.2", "4.0"]
env:
# Outside the checkout on purpose. The runners require "bundler/setup",
# which walks up from the suite looking for a Gemfile -- so a Busser root
# inside the workspace finds this project's Gemfile and tries to
# materialize that bundle inside the isolated gem home, which fails. A
# real Busser root is /opt/busser, never inside the project.
BUSSER_ROOT: /tmp/busser-kitchen
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

# Deliberately no bundler-cache, and nothing below runs under `bundle
# exec`. The verifier shells out to `gem list` to decide what to install,
# and bundler in the environment makes that report the bundle's gems
# rather than the Busser root's -- so it skips installing busser and the
# run dies on a path that was never created. Test Kitchen is not run from
# inside a project's bundle in real use either.
- uses: ruby/setup-ruby@95ef2b042f9d7a56d8268cba8559e2842e2ad01b # v1.321.0
with:
ruby-version: ${{ matrix.ruby }}

- name: Install Test Kitchen
run: gem install test-kitchen --no-document --version "~> 4.1"

- name: Install this working tree into the Busser root
run: ./kitchen-preinstall.sh

- name: kitchen verify
run: kitchen verify
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ spec/reports
test/tmp
test/version_tmp
tmp
.kitchen/
55 changes: 55 additions & 0 deletions kitchen-preinstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env bash
# Installs this working tree into the Busser root the Test Kitchen verifier
# will use, so `kitchen verify` exercises the code on this branch rather than
# the last release from RubyGems.
#
# The verifier's install script skips its own install when `gem list` already
# shows what it wants, so putting things in place first is all that is needed.
# Two consequences to handle:
#
# * It also has to install busser itself. That check is `grep "^busser"` with
# no anchor at the end, so a plugin named busser-* satisfies it and busser
# would otherwise never be installed at all.
# * Skipping `busser plugin install` also skips the plugin's postinstall,
# which is where a plugin installs the test framework it drives. So run the
# postinstall here, which is what the verifier would have done.
set -euo pipefail

BUSSER_ROOT="${BUSSER_ROOT:-/tmp/busser-kitchen}"
gemspec="$(ls ./*.gemspec)"
gem_name="$(basename "${gemspec}" .gemspec)"

install_opts=(
--install-dir "${BUSSER_ROOT}/gems"
--bindir "${BUSSER_ROOT}/bin"
--no-document
)

mkdir -p "${BUSSER_ROOT}/gems"

gem build "${gemspec}" --output "${BUSSER_ROOT}/${gem_name}.gem" >/dev/null

if [ "${gem_name}" = "busser" ]; then
# No --local: a plugin's runtime dependencies are things its runner needs on
# the machine under test, and they have to be fetched into the Busser root
# like everything else.
gem install "${BUSSER_ROOT}/${gem_name}.gem" "${install_opts[@]}" >/dev/null
else
gem install busser "${install_opts[@]}" >/dev/null
# Not --ignore-dependencies: a plugin's runtime dependencies are things its
# runner needs on the machine under test, and they have to be in the Busser
# root like everything else.
# No --local: a plugin's runtime dependencies are things its runner needs on
# the machine under test, and they have to be fetched into the Busser root
# like everything else.
gem install "${BUSSER_ROOT}/${gem_name}.gem" "${install_opts[@]}" >/dev/null

# The same environment the verifier exports, so the framework this plugin
# installs lands in the Busser root rather than the ambient gem home.
BUSSER_ROOT="${BUSSER_ROOT}" \
GEM_HOME="${BUSSER_ROOT}/gems" \
GEM_PATH="${BUSSER_ROOT}/gems" \
"${BUSSER_ROOT}/bin/busser" plugin install "${gem_name}" --force-postinstall
fi

echo "pre-installed ${gem_name} from the working tree into ${BUSSER_ROOT}"
23 changes: 23 additions & 0 deletions kitchen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
# Runs the bash runner the way Test Kitchen actually runs it -- real verifier,
# real busser, real suite transfer -- but against the machine running the tests
# rather than a VM or container, so it works unchanged in CI.
driver:
name: exec

provisioner:
name: dummy

verifier:
name: busser
# The verifier defaults to Chef's omnibus Ruby, which is not what is running
# here, and to sudo, which is not needed for a path under the workspace.
ruby_bindir: <%= RbConfig::CONFIG["bindir"] %>
sudo: false
root_path: <%= ENV.fetch("BUSSER_ROOT", "/tmp/busser-kitchen") %>

platforms:
- name: local

suites:
- name: default
5 changes: 5 additions & 0 deletions test/integration/default/bash/helper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
# Not named *_test.sh or *_spec.sh, so busser-bash must never run it. If the
# glob ever widens, this fails the suite loudly.
echo "helper.sh should not have been executed"
exit 1
6 changes: 6 additions & 0 deletions test/integration/default/bash/smoke_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
# Runs on the machine under test through busser-bash. Exit status is the verdict.
set -euo pipefail

test -n "$(command -v bash)"
echo "busser-bash ran this script"
Loading