Skip to content

Commit

Permalink
Merge pull request #532 from puppetlabs/CAT-1545-add_machine_type_to_…
Browse files Browse the repository at this point in the history
…matrix

(CAT-1545) - Return RHEL-9 ARM images in matrix
  • Loading branch information
GSPatton authored Nov 10, 2023
2 parents 367db32 + 4fc60d4 commit 159b49b
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 9 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
9 changes: 9 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. see [here](https://github.com/puppetlabs/puppet_litmus/blob/main/docs/custom_matrix.json)), otherwise it will throw an error.
## Documentation

Expand Down
17 changes: 17 additions & 0 deletions docs/custom_matrix.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
15 changes: 12 additions & 3 deletions exe/matrix_from_metadata_v2
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,17 @@ 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',
'Windows-2019' => 'windows-2019',
'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',
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion spec/exe/fake_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"8",
"9-arm"
"9"
]
},
{
Expand Down
10 changes: 6 additions & 4 deletions spec/exe/matrix_from_metadata_v2_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@
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(
[
'matrix={',
'"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"}',
'],',
Expand All @@ -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

Expand All @@ -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(
Expand All @@ -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":[',
Expand All @@ -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

Expand Down

0 comments on commit 159b49b

Please sign in to comment.