Skip to content

Commit

Permalink
Generate the expected matrix for GHA
Browse files Browse the repository at this point in the history
  • Loading branch information
lloeki committed Jun 26, 2024
1 parent d92ac09 commit a6aa47f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-callable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Compute matrix
id: matrix
run: |
echo "matrix=$(ruby matrix.rb)" >> $GITHUB_OUTPUT
echo "matrix=$(ruby matrix.rb ${{ inputs.engine_name }} ${{ inputs.engine_version }})" >> $GITHUB_OUTPUT
test:
runs-on: ubuntu-latest
Expand Down
29 changes: 26 additions & 3 deletions matrix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
'3.1' => ['9.4'],
}

matrix = map.each_with_object({}) do |(spec, appraisals), h|
definitions = map.each_with_object({}) do |(spec, appraisals), h|
h[spec] = appraisals.each_with_object({}) do |(group, rubies), h2|
ruby = rubies.scan(/✅ (\S+)/).flatten

Expand All @@ -25,6 +25,29 @@
end

# Rails 4.x is not supported on JRuby 9.2 (which is RUBY_VERSION 2.5)
matrix.each { |_, appraisals| appraisals.each { |appraisal, engines| appraisal =~ /^rails4/ && engines.key?('jruby') && engines['jruby'].delete('9.2') } }
definitions.each { |_, appraisals| appraisals.each { |appraisal, engines| appraisal =~ /^rails4/ && engines.key?('jruby') && engines['jruby'].delete('9.2') } }

matrix = definitions.each_with_object([]) do |(spec, appraisals), a|
appraisals.each do |appraisal, engines|
engines.each do |engine, versions|
versions.each do |version|
a << {
spec: {
task: spec,
appraisal: appraisal,
},
engine: {
name: engine,
version: version
}
}
end
end
end
end

if (for_engine = ARGV[0]) && (for_version = ARGV[1])
matrix.select! { |e| e[:engine][:name] == for_engine && e[:engine][:version] == for_version }
end

puts(JSON.dump(matrix))
puts(JSON.dump({ include: matrix }))

0 comments on commit a6aa47f

Please sign in to comment.