Skip to content

Commit 24acff2

Browse files
committed
Nest each matrix dimension
1 parent 8cd3fe2 commit 24acff2

File tree

6 files changed

+167
-63
lines changed

6 files changed

+167
-63
lines changed

.github/workflows/test.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.
Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,36 @@
1-
name: Unit Test Call
1+
name: Appraisal
22

33
on:
44
workflow_call:
55
inputs:
6+
spec:
7+
required: true
8+
type: string
69
engine_name:
710
required: true
811
type: string
912
engine_version:
1013
required: true
1114
type: string
15+
appraisal:
16+
required: true
17+
type: string
1218

1319
jobs:
14-
matrix:
15-
runs-on: ubuntu-latest
16-
container:
17-
image: "ruby:3.3"
18-
name: Prepare matrix
19-
outputs:
20-
matrix: ${{ steps.matrix.outputs.matrix }}
21-
steps:
22-
- uses: actions/checkout@v4
23-
- name: Compute matrix
24-
id: matrix
25-
run: |
26-
matrix="$(ruby matrix.rb engine.name:${{ inputs.engine_name }} engine.version:${{ inputs.engine_version }})"
27-
echo "${matrix}"
28-
echo "${matrix}" | ruby -rjson -0777 -ne 'pp JSON.parse($_)'
29-
echo "matrix=${matrix}" >> $GITHUB_OUTPUT
30-
3120
test:
3221
runs-on: ubuntu-latest
33-
name: Test ${{ matrix.spec.task }} ${{ matrix.spec.appraisal }} (${{ inputs.engine_name }} ${{ inputs.engine_version }})
22+
name: "Test ${{ matrix.appraisal }} (${{ matrix.engine.name }}:${{ matrix.engine.version }} ${{ matrix.spec }})"
3423
needs: matrix
3524
strategy:
3625
fail-fast: false
37-
matrix: ${{ fromJSON(needs.matrix.outputs.matrix) }}
26+
matrix:
27+
spec:
28+
- ${{ inputs.spec }}
29+
engine:
30+
- name: $${ inputs.engine_name }}
31+
version: $${ inputs.engine_version }}
32+
appraisal:
33+
- ${{ inputs.appraisal }}
3834
env:
3935
SKIP_SIMPLECOV: 1
4036
DD_INSTRUMENTATION_TELEMETRY_ENABLED: false
@@ -60,4 +56,3 @@ jobs:
6056
export BUNDLE_GEMFILE
6157
fi
6258
bundle exec rake spec:${{ matrix.spec.task }}
63-
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Engine
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
engine_name:
7+
required: true
8+
type: string
9+
engine_version:
10+
required: true
11+
type: string
12+
spec:
13+
required: true
14+
type: string
15+
16+
jobs:
17+
matrix:
18+
runs-on: ubuntu-latest
19+
container:
20+
image: "ruby:3.3"
21+
name: Prepare matrix
22+
outputs:
23+
matrix: ${{ steps.matrix.outputs.matrix }}
24+
steps:
25+
- uses: actions/checkout@v4
26+
- name: Compute matrix
27+
id: matrix
28+
run: |
29+
matrix="$(ruby matrix.rb --json appraisals spec:#{{ inputs.spec }} engine.name:${{ inputs.engine_name }} engine.version:${{ inputs.engine_version }})"
30+
echo "${matrix}" | ruby -rjson -0777 -ne 'puts JSON.pretty_generate JSON.parse($_)'
31+
echo "matrix=${matrix}" >> $GITHUB_OUTPUT
32+
33+
test:
34+
runs-on: ubuntu-latest
35+
name: "${{ matrix.appraisal }} (${{ matrix.engine.name }}:${{ matrix.engine.version }} ${{ matrix.spec }})"
36+
needs: matrix
37+
strategy:
38+
fail-fast: false
39+
matrix:
40+
spec:
41+
- ${{ inputs.spec }}
42+
engine:
43+
- name: $${ inputs.engine_name }}
44+
version: $${ inputs.engine_version }}
45+
appraisal: ${{ fromJSON(needs.matrix.outputs.matrix) }}
46+
uses: ./.github/workflows/unit-test/appraisal.yml
47+
with:
48+
spec: ${{ matrix.spec }}
49+
engine_name: ${{ matrix.engine.name }}
50+
engine_version: ${{ matrix.engine.version }}
51+
appraisal: ${{ matrix.appraisal }}
52+

.github/workflows/unit-test/spec.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Spec
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
spec:
7+
required: true
8+
type: string
9+
10+
jobs:
11+
matrix:
12+
runs-on: ubuntu-latest
13+
container:
14+
image: "ruby:3.3"
15+
name: Prepare matrix
16+
outputs:
17+
matrix: ${{ steps.matrix.outputs.matrix }}
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: Compute matrix
21+
id: matrix
22+
run: |
23+
matrix="$(ruby matrix.rb --json engines spec:${{ inputs.spec }})"
24+
echo "${matrix}" | ruby -rjson -0777 -ne 'puts JSON.pretty_generate JSON.parse($_)'
25+
echo "matrix=${matrix}" >> $GITHUB_OUTPUT
26+
27+
test:
28+
runs-on: ubuntu-latest
29+
name: "${{ matrix.engine.name }}:${{ matrix.engine.version }} (${{ matrix.spec }})"
30+
needs: matrix
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
spec:
35+
- ${{ inputs.spec }}
36+
engine: ${{ fromJSON(needs.matrix.outputs.matrix) }}
37+
uses: ./.github/workflows/unit-test/engine.yml
38+
with:
39+
spec: ${{ matrix.spec }}
40+
engine_name: ${{ matrix.engine.name }}
41+
engine_version: ${{ matrix.engine.version }}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Unit Test
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
matrix:
8+
runs-on: ubuntu-latest
9+
container:
10+
image: "ruby:3.3"
11+
name: Prepare matrix
12+
outputs:
13+
matrix: ${{ steps.matrix.outputs.matrix }}
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Compute matrix
17+
id: matrix
18+
run: |
19+
matrix="$(ruby matrix.rb --json specs)"
20+
echo "${matrix}" | ruby -rjson -0777 -ne 'puts JSON.pretty_generate JSON.parse($_)'
21+
echo "matrix=${matrix}" >> $GITHUB_OUTPUT
22+
test:
23+
name: "${{ matrix.spec }}"
24+
needs: matrix
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
spec: ${{ needs.matrix.outputs.matrix }}
29+
uses: ./.github/workflows/unit-test/spec.yml
30+
with:
31+
spec: ${{ matrix.spec }}
32+

matrix.rb

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
require 'json'
33

44
map = eval(File.open('Matrixfile', 'r:UTF-8').read)
5+
56
ruby_to_jruby = {
67
'2.5' => ['9.2'],
78
'2.6' => ['9.3'],
@@ -50,12 +51,18 @@
5051
selected_engine_version = nil
5152
selected_spec_task = nil
5253
selected_spec_appraisal = nil
54+
output = nil
55+
format = nil
5356
ARGV.each do |arg|
5457
case arg
5558
when /^engine.name:(\S+)/ then selected_engine_name = $1
5659
when /^engine.version:(\S+)/ then selected_engine_version = $1
57-
when /^spec.task:(\S+)/ then selected_spec_task = $1
58-
when /^spec.appraisal:(\S+)/ then selected_spec_appraisal = $1
60+
when /^spec:(\S+)/ then selected_spec_task = $1
61+
when /^appraisal:(\S*)/ then selected_spec_appraisal = $1
62+
when 'engines' then output = 'engines'
63+
when 'specs' then output = 'specs'
64+
when 'appraisals' then output = 'appraisals'
65+
when '--json' then format = 'json'
5966
end
6067
end
6168

@@ -75,4 +82,20 @@
7582
matrix.select! { |e| e[:spec][:appraisal] == selected_spec_appraisal }
7683
end
7784

78-
puts(JSON.dump({ include: matrix }))
85+
out = case output
86+
when 'engines'
87+
matrix.each_with_object([]) { |e, a| a << e[:engine] }.uniq
88+
when 'specs'
89+
matrix.each_with_object([]) { |e, a| a << e[:spec][:task] }.uniq
90+
when 'appraisals'
91+
matrix.each_with_object([]) { |e, a| a << e[:spec][:appraisal] }.uniq
92+
else
93+
{ include: matrix }
94+
end
95+
96+
case format
97+
when 'json'
98+
puts(JSON.dump(out))
99+
else
100+
out.each { |e| puts e }
101+
end

0 commit comments

Comments
 (0)