From 20e47b9d326e2aeccdc77e0b6f53cacdd36bbf51 Mon Sep 17 00:00:00 2001 From: jordanbreen28 Date: Thu, 9 Nov 2023 09:10:34 +0000 Subject: [PATCH 1/3] (CAT-1545) - Add machine type to matrix This commit adds a machine_type field to each object in the matrix platforms. This means that for arm-based architectures, we can return the t2a-standard-2 machine which supports arm. If not arm based, then resort back to default. --- README.md | 2 +- exe/matrix_from_metadata_v2 | 15 ++++++++++++--- spec/exe/fake_metadata.json | 2 +- spec/exe/matrix_from_metadata_v2_spec.rb | 10 ++++++---- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index bd6d9f68..914fc327 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ In order to use this new functionality, run: `$: bundle exec matrix_from_metadata_v2 --custom-matrix matrix.json` -> Note: The file should contain a valid Array of JSON Objects (i.e. `[{"label":"AlmaLinux-8","provider":"provision_service","image":"almalinux-cloud/almalinux-8"}, {..}]`), otherwise it will throw an error. +> Note: The file should contain a valid Array of JSON Objects (i.e. `[{"label":"AlmaLinux-8","provider":"provision_service","image":"almalinux-cloud/almalinux-8","machine_type":"n1-standard-2"}, {"label":"RedHat-9-arm","provider":"provision_service","image":"rhel-9-arm64","machine_type":"t2a-standard-2"}, {..}]`), otherwise it will throw an error. ## Documentation diff --git a/exe/matrix_from_metadata_v2 b/exe/matrix_from_metadata_v2 index 44d8b552..2081b2c9 100755 --- a/exe/matrix_from_metadata_v2 +++ b/exe/matrix_from_metadata_v2 @@ -28,7 +28,6 @@ IMAGE_TABLE = { 'RedHat-7' => 'rhel-7', 'RedHat-8' => 'rhel-8', 'RedHat-9' => 'rhel-9', - 'RedHat-9-arm' => 'rhel-9-arm64', 'SLES-12' => 'sles-12', 'SLES-15' => 'sles-15', 'Windows-2016' => 'windows-2016', @@ -36,6 +35,10 @@ IMAGE_TABLE = { 'Windows-2022' => 'windows-2022' }.freeze +ARM_IMAGE_TABLE = { + 'RedHat-9-arm' => 'rhel-9-arm64' +}.freeze + DOCKER_PLATFORMS = { 'CentOS-6' => 'litmusimage/centos:6', 'CentOS-7' => 'litmusimage/centos:7', @@ -112,7 +115,6 @@ if ARGV.include?('--provision-service') 'Ubuntu-20.04' => 'ubuntu-2004-lts', 'Ubuntu-22.04' => 'ubuntu-2204-lts' } - updated_list = IMAGE_TABLE.dup.clone updated_list.merge!(updated_platforms) @@ -152,7 +154,14 @@ else os = sup['operatingsystem'] sup['operatingsystemrelease'].sort_by(&:to_i).each do |ver| image_key = "#{os}-#{ver}" - + # Add ARM images if they exist and are not excluded + if ARM_IMAGE_TABLE.key?("#{image_key}-arm") && !exclude_list.include?("#{image_key.downcase}-arm") + matrix[:platforms] << { + label: "#{image_key}-arm", + provider: 'provision_service', + image: ARM_IMAGE_TABLE["#{image_key}-arm"] + } + end if IMAGE_TABLE.key?(image_key) && !exclude_list.include?(image_key.downcase) matrix[:platforms] << { label: image_key, diff --git a/spec/exe/fake_metadata.json b/spec/exe/fake_metadata.json index c0eeaed0..1905cf63 100644 --- a/spec/exe/fake_metadata.json +++ b/spec/exe/fake_metadata.json @@ -24,7 +24,7 @@ "operatingsystem": "RedHat", "operatingsystemrelease": [ "8", - "9-arm" + "9" ] }, { diff --git a/spec/exe/matrix_from_metadata_v2_spec.rb b/spec/exe/matrix_from_metadata_v2_spec.rb index 849355d5..25522526 100644 --- a/spec/exe/matrix_from_metadata_v2_spec.rb +++ b/spec/exe/matrix_from_metadata_v2_spec.rb @@ -16,7 +16,7 @@ expect(result.status_code).to eq 0 end - it 'generates the matrix' do + it 'generates the matrix' do # rubocop:disable RSpec/ExampleLength expect(result.stdout).to include('::warning::Cannot find image for Ubuntu-14.04') expect(github_output_content).to include( [ @@ -24,6 +24,7 @@ '"platforms":[', '{"label":"CentOS-6","provider":"docker","image":"litmusimage/centos:6"},', '{"label":"RedHat-8","provider":"provision_service","image":"rhel-8"},', + '{"label":"RedHat-9","provider":"provision_service","image":"rhel-9"},', '{"label":"RedHat-9-arm","provider":"provision_service","image":"rhel-9-arm64"},', '{"label":"Ubuntu-18.04","provider":"docker","image":"litmusimage/ubuntu:18.04"}', '],', @@ -36,7 +37,7 @@ expect(github_output_content).to include( 'spec_matrix={"include":[{"puppet_version":"~> 7.24","ruby_version":2.7},{"puppet_version":"~> 8.0","ruby_version":3.2}]}' ) - expect(result.stdout).to include("Created matrix with 10 cells:\n - Acceptance Test Cells: 8\n - Spec Test Cells: 2") + expect(result.stdout).to include("Created matrix with 12 cells:\n - Acceptance Test Cells: 10\n - Spec Test Cells: 2") end end @@ -53,7 +54,7 @@ expect(result.status_code).to eq 0 end - it 'generates the matrix without excluded platforms' do + it 'generates the matrix without excluded platforms' do # rubocop:disable RSpec/ExampleLength expect(result.stdout).to include('::warning::Cannot find image for Ubuntu-14.04') expect(result.stdout).to include('::warning::Ubuntu-18.04 was excluded from testing') expect(github_output_content).to include( @@ -62,6 +63,7 @@ '"platforms":[', '{"label":"CentOS-6","provider":"docker","image":"litmusimage/centos:6"},', '{"label":"RedHat-8","provider":"provision_service","image":"rhel-8"},', + '{"label":"RedHat-9","provider":"provision_service","image":"rhel-9"},', '{"label":"RedHat-9-arm","provider":"provision_service","image":"rhel-9-arm64"}', '],', '"collection":[', @@ -73,7 +75,7 @@ expect(github_output_content).to include( 'spec_matrix={"include":[{"puppet_version":"~> 7.24","ruby_version":2.7},{"puppet_version":"~> 8.0","ruby_version":3.2}]}' ) - expect(result.stdout).to include("Created matrix with 8 cells:\n - Acceptance Test Cells: 6\n - Spec Test Cells: 2") + expect(result.stdout).to include("Created matrix with 10 cells:\n - Acceptance Test Cells: 8\n - Spec Test Cells: 2") end end From c21775baa6107976ef33fb94e098fa817e2009a5 Mon Sep 17 00:00:00 2001 From: jordanbreen28 Date: Thu, 9 Nov 2023 09:34:45 +0000 Subject: [PATCH 2/3] (maint) - Run spec on ruby 3.2 and 2.7 --- .github/workflows/ci.yml | 9 +++++++++ .github/workflows/nightly.yml | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 677c885b..24e19cdf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,5 +8,14 @@ on: jobs: spec: + strategy: + fail-fast: false + matrix: + ruby_version: + - '2.7' + - '3.2' + name: "spec (ruby ${{ matrix.ruby_version }})" uses: "puppetlabs/cat-github-actions/.github/workflows/gem_ci.yml@main" secrets: "inherit" + with: + ruby_version: ${{ matrix.ruby_version }} diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 64154daa..6e74a119 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -7,5 +7,14 @@ on: jobs: spec: + strategy: + fail-fast: false + matrix: + ruby_version: + - '2.7' + - '3.2' + name: "spec (ruby ${{ matrix.ruby_version }})" uses: "puppetlabs/cat-github-actions/.github/workflows/gem_ci.yml@main" secrets: "inherit" + with: + ruby_version: ${{ matrix.ruby_version }} From 4fc60d44a06db0587d4c0add5e234a5bed804a4d Mon Sep 17 00:00:00 2001 From: jordanbreen28 Date: Fri, 10 Nov 2023 11:04:51 +0000 Subject: [PATCH 3/3] (maint) - Add example matrix --- README.md | 2 +- docs/custom_matrix.json | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 docs/custom_matrix.json diff --git a/README.md b/README.md index 914fc327..733f4772 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ In order to use this new functionality, run: `$: bundle exec matrix_from_metadata_v2 --custom-matrix matrix.json` -> Note: The file should contain a valid Array of JSON Objects (i.e. `[{"label":"AlmaLinux-8","provider":"provision_service","image":"almalinux-cloud/almalinux-8","machine_type":"n1-standard-2"}, {"label":"RedHat-9-arm","provider":"provision_service","image":"rhel-9-arm64","machine_type":"t2a-standard-2"}, {..}]`), otherwise it will throw an error. +> Note: The file should contain a valid Array of JSON Objects (i.e. see [here](https://github.com/puppetlabs/puppet_litmus/blob/main/docs/custom_matrix.json)), otherwise it will throw an error. ## Documentation diff --git a/docs/custom_matrix.json b/docs/custom_matrix.json new file mode 100644 index 00000000..c8f91e15 --- /dev/null +++ b/docs/custom_matrix.json @@ -0,0 +1,17 @@ +[ + { + "label":"AlmaLinux-8", + "provider":"provision_service", + "image":"almalinux-cloud/almalinux-8" + }, + { + "label":"RedHat-9", + "provider":"provision_service", + "image":"rhel-9" + }, + { + "label":"centos-7", + "provider":"docker", + "image":"litmusimage/centos-7" + } +]