Skip to content

Commit 42ffa29

Browse files
committed
chore: Rework test suites to use kitchen.yml
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 <rulerof@gmail.com>
1 parent 5c61930 commit 42ffa29

File tree

1 file changed

+50
-48
lines changed

1 file changed

+50
-48
lines changed

.github/workflows/lint.yml

+50-48
Original file line numberDiff line numberDiff line change
@@ -8,79 +8,81 @@ jobs:
88
lint-unit:
99
uses: test-kitchen/.github/.github/workflows/lint-unit.yml@main
1010

11-
integration-windows:
12-
name: Windows ${{matrix.suite}} ${{matrix.os}}
13-
runs-on: windows-latest
11+
build-matrix:
12+
name: Build test matrix from test-kitchen config
13+
runs-on: ubuntu-latest
1414
needs: lint-unit
15-
strategy:
16-
fail-fast: false
17-
matrix:
18-
suite: [default]
19-
os: [ubuntu-24.04]
20-
ruby: ["3.3"]
2115
steps:
2216
- uses: actions/checkout@v4
23-
- uses: ruby/setup-ruby@v1
17+
- name: Set up Ruby
18+
uses: ruby/setup-ruby@v1
2419
with:
25-
ruby-version: ${{ matrix.ruby }}
20+
ruby-version: "3.3"
2621
bundler-cache: true
27-
- name: Set up Docker Buildx
28-
uses: docker/setup-buildx-action@v3
29-
- run: bundle exec kitchen test ${{ matrix.suite }}-${{ matrix.os }} -l debug
22+
- name: Discover Windows suites
23+
id: windows
24+
run: |
25+
cat << "EORUBY" | bundle exec ruby >> "$GITHUB_OUTPUT"
26+
require 'inspec'
27+
require 'kitchen'
3028
31-
integration-linux:
32-
name: Linux ${{matrix.suite}} ${{matrix.os}}
33-
runs-on: ubuntu-latest
34-
needs: lint-unit
29+
windows_loader = Kitchen::Loader::YAML.new(project_config: './kitchen.windows.yml')
30+
windows_suites = Kitchen::Config.new(loader: windows_loader).instances.map { |instance| instance.name }
31+
32+
puts "suites=#{windows_suites.to_json}"
33+
EORUBY
34+
- name: Discover Linux suites
35+
id: linux
36+
run: |
37+
cat << "EORUBY" | bundle exec ruby >> "$GITHUB_OUTPUT"
38+
require 'inspec'
39+
require 'kitchen'
40+
41+
linux_loader = Kitchen::Loader::YAML.new(project_config: './kitchen.yml')
42+
linux_suites = Kitchen::Config.new(loader: linux_loader).instances.map { |instance| instance.name }
43+
44+
puts "suites=#{linux_suites.to_json}"
45+
EORUBY
46+
outputs:
47+
windows-suites: ${{ steps.windows.outputs.suites }}
48+
linux-suites: ${{ steps.linux.outputs.suites }}
49+
50+
integration-windows:
51+
name: Windows ${{matrix.suite}}
52+
runs-on: windows-latest
53+
needs:
54+
- build-matrix
3555
strategy:
3656
fail-fast: false
3757
matrix:
38-
suite:
39-
- default
40-
- no-build-context
41-
- arm64
42-
- amd64
43-
- inspec
44-
os:
45-
- amazonlinux-2023
46-
- ubuntu-2204
47-
- ubuntu-2404
48-
- fedora-latest
49-
- almalinux-9
50-
- rockylinux-9
51-
- debian-12
52-
- opensuse-15
53-
- dockerfile
54-
ruby: ["3.3"]
58+
suite: ${{ fromJson(needs.build-matrix.outputs.windows-suites) }}
5559
steps:
5660
- uses: actions/checkout@v4
5761
- uses: ruby/setup-ruby@v1
5862
with:
59-
ruby-version: ${{ matrix.ruby }}
63+
ruby-version: "3.3"
6064
bundler-cache: true
61-
- name: Set up QEMU
62-
uses: docker/setup-qemu-action@v3
6365
- name: Set up Docker Buildx
6466
uses: docker/setup-buildx-action@v3
65-
- run: bundle exec kitchen test ${{ matrix.suite }}-${{ matrix.os }} -l debug
67+
- run: bundle exec kitchen test ${{ matrix.suite }} -l debug
6668

67-
integration-capabilities:
68-
name: Linux ${{matrix.suite}} ${{matrix.os}}
69+
integration-linux:
70+
name: Linux ${{matrix.suite}}
6971
runs-on: ubuntu-latest
70-
needs: lint-unit
72+
needs:
73+
- build-matrix
7174
strategy:
7275
fail-fast: false
7376
matrix:
74-
suite:
75-
- capabilities
76-
os: [debian-12, ubuntu-2204, ubuntu-2404]
77-
ruby: ["3.3"]
77+
suite: ${{ fromJson(needs.build-matrix.outputs.linux-suites) }}
7878
steps:
7979
- uses: actions/checkout@v4
8080
- uses: ruby/setup-ruby@v1
8181
with:
82-
ruby-version: ${{ matrix.ruby }}
82+
ruby-version: "3.3"
8383
bundler-cache: true
84+
- name: Set up QEMU
85+
uses: docker/setup-qemu-action@v3
8486
- name: Set up Docker Buildx
8587
uses: docker/setup-buildx-action@v3
86-
- run: bundle exec kitchen test ${{ matrix.suite }}-${{ matrix.os }} -l debug
88+
- run: bundle exec kitchen test ${{ matrix.suite }} -l debug

0 commit comments

Comments
 (0)