From 0724039f12181eb9ce615ce04e1e8e0b96ada87c Mon Sep 17 00:00:00 2001 From: Jeffrey Clark Date: Mon, 6 May 2024 23:29:08 -0500 Subject: [PATCH] (maint) specify supported runner in matrix --- exe/matrix.json | 5 ++++ exe/matrix_from_metadata_v3 | 10 ++++++- spec/exe/matrix_from_metadata_v3_spec.rb | 34 ++++++++++++++---------- 3 files changed, 34 insertions(+), 15 deletions(-) diff --git a/exe/matrix.json b/exe/matrix.json index 7180ac5..4038eeb 100644 --- a/exe/matrix.json +++ b/exe/matrix.json @@ -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" + } } } diff --git a/exe/matrix_from_metadata_v3 b/exe/matrix_from_metadata_v3 index ff55db0..83f3442 100755 --- a/exe/matrix_from_metadata_v3 +++ b/exe/matrix_from_metadata_v3 @@ -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' @@ -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 } @@ -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 diff --git a/spec/exe/matrix_from_metadata_v3_spec.rb b/spec/exe/matrix_from_metadata_v3_spec.rb index a18c8b0..690af7a 100644 --- a/spec/exe/matrix_from_metadata_v3_spec.rb +++ b/spec/exe/matrix_from_metadata_v3_spec.rb @@ -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"', @@ -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"', @@ -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"', @@ -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={',