Skip to content

Commit

Permalink
chore: Rework test suites to use kitchen.yml
Browse files Browse the repository at this point in the history
Add a step to the github action that uses an embedded ruby script to discover the list of suites directly from the kitchen config.

Signed-off-by: Andrew Bobulsky <[email protected]>
  • Loading branch information
RulerOf committed Jul 3, 2024
1 parent 5c61930 commit 838a72b
Showing 1 changed file with 51 additions and 49 deletions.
100 changes: 51 additions & 49 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,79 +8,81 @@ jobs:
lint-unit:
uses: test-kitchen/.github/.github/workflows/lint-unit.yml@main

integration-windows:
name: Windows ${{matrix.suite}} ${{matrix.os}}
runs-on: windows-latest
build-matrix:
name: Build test matrix from test-kitchen config
runs-on: ubuntu-latest
needs: lint-unit
strategy:
fail-fast: false
matrix:
suite: [default]
os: [ubuntu-24.04]
ruby: ["3.3"]
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
ruby-version: "3.3"
bundler-cache: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- run: bundle exec kitchen test ${{ matrix.suite }}-${{ matrix.os }} -l debug
- name: Discover Windows suites
id: windows
run: |
cat << "EORUBY" | bundle exec ruby >> "$GITHUB_OUTPUT"
require 'inspec'
require 'kitchen'
integration-linux:
name: Linux ${{matrix.suite}} ${{matrix.os}}
runs-on: ubuntu-latest
needs: lint-unit
windows_loader = Kitchen::Loader::YAML.new(project_config: './kitchen.windows.yml')
windows_suites = Kitchen::Config.new(loader: windows_loader).instances.map { |instance| instance.name }
puts "suites=#{windows_suites.to_json}"
EORUBY
- name: Discover Linux suites
id: linux
run: |
cat << "EORUBY" | bundle exec ruby >> "$GITHUB_OUTPUT"
require 'inspec'
require 'kitchen'
linux_loader = Kitchen::Loader::YAML.new(project_config: './kitchen.yml')
linux_suites = Kitchen::Config.new(loader: linux_loader).instances.map { |instance| instance.name }
puts "suites=#{linux_suites.to_json}"
EORUBY
outputs:
windows-suites: ${{ steps.windows.outputs.suites }}
linux-suites: ${{ steps.linux.outputs.suites }}

integration-windows:
name: Windows ${{matrix.suite}}
runs-on: windows-latest
needs:

Check failure on line 53 in .github/workflows/lint.yml

View workflow job for this annotation

GitHub Actions / lint-unit / yamllint

53:11 [trailing-spaces] trailing spaces
- build-matrix
strategy:
fail-fast: false
matrix:
suite:
- default
- no-build-context
- arm64
- amd64
- inspec
os:
- amazonlinux-2023
- ubuntu-2204
- ubuntu-2404
- fedora-latest
- almalinux-9
- rockylinux-9
- debian-12
- opensuse-15
- dockerfile
ruby: ["3.3"]
matrix:

Check failure on line 57 in .github/workflows/lint.yml

View workflow job for this annotation

GitHub Actions / lint-unit / yamllint

57:14 [trailing-spaces] trailing spaces
suite: ${{ fromJson(needs.build-matrix.outputs.windows-suites) }}
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
ruby-version: "3.3"
bundler-cache: true
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- run: bundle exec kitchen test ${{ matrix.suite }}-${{ matrix.os }} -l debug
- run: bundle exec kitchen test ${{ matrix.suite }} -l debug

integration-capabilities:
name: Linux ${{matrix.suite}} ${{matrix.os}}
integration-linux:
name: Linux ${{matrix.suite}}
runs-on: ubuntu-latest
needs: lint-unit
needs:

Check failure on line 72 in .github/workflows/lint.yml

View workflow job for this annotation

GitHub Actions / lint-unit / yamllint

72:11 [trailing-spaces] trailing spaces
- build-matrix
strategy:
fail-fast: false
matrix:
suite:
- capabilities
os: [debian-12, ubuntu-2204, ubuntu-2404]
ruby: ["3.3"]
suite: ${{ fromJson(needs.build-matrix.outputs.linux-suites) }}
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
ruby-version: "3.3"
bundler-cache: true
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- run: bundle exec kitchen test ${{ matrix.suite }}-${{ matrix.os }} -l debug
- run: bundle exec kitchen test ${{ matrix.suite }} -l debug

0 comments on commit 838a72b

Please sign in to comment.