Skip to content

Commit

Permalink
(maint) specify supported runner in matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
h0tw1r3 committed May 30, 2024
1 parent efd2ee0 commit 0724039
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 15 deletions.
5 changes: 5 additions & 0 deletions exe/matrix.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,10 @@
"22.04": { "x86_64": "litmusimage/ubuntu:22.04" }
}
}
},
"github_runner": {
"docker": {
"^(AmazonLinux-2|(CentOS|OracleLinux|Scientific)-7|Ubuntu-18|Debian-10)": "ubuntu-20.04"
}
}
}
10 changes: 9 additions & 1 deletion exe/matrix_from_metadata_v3
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ options = OpenStruct.new(

default_options = {
'provision-prefer': 'docker',
runner: 'ubuntu-latest',
output: 'auto',
matrix: File.join(File.dirname(__FILE__), 'matrix.json'),
metadata: 'metadata.json'
Expand Down Expand Up @@ -143,6 +144,8 @@ begin
opt.on('--quiet', TrueClass, 'Disable notice messages') { |o| options.quiet = o }
opt.on('--output TYPE', OutputType, "Type of output to generate; auto, github or stdout (default: #{default_options[:output]})\n\n") { |o| options.output = o }

opt.on('--runner NAME', String, "Default Github action runner (default: #{default_options[:runner]})") { |o| options.runner = o }

opt.on('--puppet-include MAJOR', Integer, 'Select puppet major version') { |o| options.puppet_include << o }
opt.on('--puppet-exclude MAJOR', Integer, 'Filter puppet major version') { |o| options.puppet_exclude << o }

Expand Down Expand Up @@ -277,11 +280,16 @@ options[:metadata]['operatingsystem_support'].each do |os_sup|
label = (arch.eql?('x86_64') ? platform_key : platform_key + [arch]).join('-')
next if os_ver_platforms.any? { |h| h[:label] == label }

runner = options[:matrix]['github_runner'][provisioner]&.reduce(options[:runner]) do |memo, (reg, run)|
label.match?(/#{reg}/i) ? run : memo
end

os_ver_platforms << {
label: label,
provider: provisioner,
arch: arch,
image: image
image: image,
runner: runner.nil? ? options[:runner] : runner
}
end
end
Expand Down
34 changes: 20 additions & 14 deletions spec/exe/matrix_from_metadata_v3_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
matrix = [
'matrix={',
'"platforms":[',
'{"label":"Ubuntu-18.04","provider":"docker","arch":"x86_64","image":"litmusimage/ubuntu:18.04"},',
'{"label":"Ubuntu-22.04","provider":"docker","arch":"x86_64","image":"litmusimage/ubuntu:22.04"}',
'{"label":"AmazonLinux-2","provider":"docker","arch":"x86_64","image":"litmusimage/amazonlinux:2","runner":"ubuntu-20.04"},',
'{"label":"AmazonLinux-2023","provider":"docker","arch":"x86_64","image":"litmusimage/amazonlinux:2023","runner":"ubuntu-20.04"},',
'{"label":"Ubuntu-18.04","provider":"docker","arch":"x86_64","image":"litmusimage/ubuntu:18.04","runner":"ubuntu-20.04"},',
'{"label":"Ubuntu-22.04","provider":"docker","arch":"x86_64","image":"litmusimage/ubuntu:22.04","runner":"ubuntu-latest"}',
'],',
'"collection":[',
'"puppet7-nightly","puppet8-nightly"',
Expand Down Expand Up @@ -91,12 +93,14 @@
[
'matrix={',
'"platforms":[',
'{"label":"RedHat-8","provider":"provision_service","arch":"x86_64","image":"rhel-8"},',
'{"label":"RedHat-9","provider":"provision_service","arch":"x86_64","image":"rhel-9"},',
'{"label":"RedHat-9-arm","provider":"provision_service","arch":"arm","image":"rhel-9-arm64"},',
'{"label":"Ubuntu-18.04","provider":"docker","arch":"x86_64","image":"litmusimage/ubuntu:18.04"},',
'{"label":"Ubuntu-22.04","provider":"docker","arch":"x86_64","image":"litmusimage/ubuntu:22.04"},',
'{"label":"Ubuntu-22.04-arm","provider":"provision_service","arch":"arm","image":"ubuntu-2204-lts-arm64"}',
'{"label":"AmazonLinux-2","provider":"docker","arch":"x86_64","image":"litmusimage/amazonlinux:2","runner":"ubuntu-20.04"},',
'{"label":"AmazonLinux-2023","provider":"docker","arch":"x86_64","image":"litmusimage/amazonlinux:2023","runner":"ubuntu-20.04"},',
'{"label":"RedHat-8","provider":"provision_service","arch":"x86_64","image":"rhel-8","runner":"ubuntu-latest"},',
'{"label":"RedHat-9","provider":"provision_service","arch":"x86_64","image":"rhel-9","runner":"ubuntu-latest"},',
'{"label":"RedHat-9-arm","provider":"provision_service","arch":"arm","image":"rhel-9-arm64","runner":"ubuntu-latest"},',
'{"label":"Ubuntu-18.04","provider":"docker","arch":"x86_64","image":"litmusimage/ubuntu:18.04","runner":"ubuntu-20.04"},',
'{"label":"Ubuntu-22.04","provider":"docker","arch":"x86_64","image":"litmusimage/ubuntu:22.04","runner":"ubuntu-latest"},',
'{"label":"Ubuntu-22.04-arm","provider":"provision_service","arch":"arm","image":"ubuntu-2204-lts-arm64","runner":"ubuntu-latest"}',
'],',
'"collection":[',
'"puppet7-nightly","puppet8-nightly"',
Expand Down Expand Up @@ -129,11 +133,13 @@
[
'matrix={',
'"platforms":[',
'{"label":"RedHat-8","provider":"provision_service","arch":"x86_64","image":"rhel-8"},',
'{"label":"RedHat-9","provider":"provision_service","arch":"x86_64","image":"rhel-9"},',
'{"label":"RedHat-9-arm","provider":"provision_service","arch":"arm","image":"rhel-9-arm64"},',
'{"label":"Ubuntu-22.04","provider":"docker","arch":"x86_64","image":"litmusimage/ubuntu:22.04"},',
'{"label":"Ubuntu-22.04-arm","provider":"provision_service","arch":"arm","image":"ubuntu-2204-lts-arm64"}',
'{"label":"AmazonLinux-2","provider":"docker","arch":"x86_64","image":"litmusimage/amazonlinux:2","runner":"ubuntu-20.04"},',
'{"label":"AmazonLinux-2023","provider":"docker","arch":"x86_64","image":"litmusimage/amazonlinux:2023","runner":"ubuntu-20.04"},',
'{"label":"RedHat-8","provider":"provision_service","arch":"x86_64","image":"rhel-8","runner":"ubuntu-latest"},',
'{"label":"RedHat-9","provider":"provision_service","arch":"x86_64","image":"rhel-9","runner":"ubuntu-latest"},',
'{"label":"RedHat-9-arm","provider":"provision_service","arch":"arm","image":"rhel-9-arm64","runner":"ubuntu-latest"},',
'{"label":"Ubuntu-22.04","provider":"docker","arch":"x86_64","image":"litmusimage/ubuntu:22.04","runner":"ubuntu-latest"},',
'{"label":"Ubuntu-22.04-arm","provider":"provision_service","arch":"arm","image":"ubuntu-2204-lts-arm64","runner":"ubuntu-latest"}',
'],',
'"collection":[',
'"puppet7-nightly","puppet8-nightly"',
Expand Down Expand Up @@ -162,7 +168,7 @@
end

context 'with --platform-exclude "ubuntu-(18.04|22.04)" --platform-exclude "redhat-[89]"' do
let(:result) { run_matrix_from_metadata_v3(['--puppetlabs', '--platform-exclude', 'ubuntu-(18.04|22.04)', '--platform-exclude', 'redhat-[89]']) }
let(:result) { run_matrix_from_metadata_v3(['--puppetlabs', '--platform-exclude', '(amazonlinux|ubuntu)-(2|18.04|22.04|2023)', '--platform-exclude', 'redhat-[89]']) }
let(:matrix) do
[
'matrix={',
Expand Down

0 comments on commit 0724039

Please sign in to comment.