Skip to content

Commit 159b49b

Browse files
authored
Merge pull request #532 from puppetlabs/CAT-1545-add_machine_type_to_matrix
(CAT-1545) - Return RHEL-9 ARM images in matrix
2 parents 367db32 + 4fc60d4 commit 159b49b

File tree

7 files changed

+55
-9
lines changed

7 files changed

+55
-9
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,14 @@ on:
88

99
jobs:
1010
spec:
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
ruby_version:
15+
- '2.7'
16+
- '3.2'
17+
name: "spec (ruby ${{ matrix.ruby_version }})"
1118
uses: "puppetlabs/cat-github-actions/.github/workflows/gem_ci.yml@main"
1219
secrets: "inherit"
20+
with:
21+
ruby_version: ${{ matrix.ruby_version }}

.github/workflows/nightly.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,14 @@ on:
77

88
jobs:
99
spec:
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
ruby_version:
14+
- '2.7'
15+
- '3.2'
16+
name: "spec (ruby ${{ matrix.ruby_version }})"
1017
uses: "puppetlabs/cat-github-actions/.github/workflows/gem_ci.yml@main"
1118
secrets: "inherit"
19+
with:
20+
ruby_version: ${{ matrix.ruby_version }}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ In order to use this new functionality, run:
5959

6060
`$: bundle exec matrix_from_metadata_v2 --custom-matrix matrix.json`
6161

62-
> 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.
62+
> 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.
6363
6464
## Documentation
6565

docs/custom_matrix.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[
2+
{
3+
"label":"AlmaLinux-8",
4+
"provider":"provision_service",
5+
"image":"almalinux-cloud/almalinux-8"
6+
},
7+
{
8+
"label":"RedHat-9",
9+
"provider":"provision_service",
10+
"image":"rhel-9"
11+
},
12+
{
13+
"label":"centos-7",
14+
"provider":"docker",
15+
"image":"litmusimage/centos-7"
16+
}
17+
]

exe/matrix_from_metadata_v2

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,17 @@ IMAGE_TABLE = {
2828
'RedHat-7' => 'rhel-7',
2929
'RedHat-8' => 'rhel-8',
3030
'RedHat-9' => 'rhel-9',
31-
'RedHat-9-arm' => 'rhel-9-arm64',
3231
'SLES-12' => 'sles-12',
3332
'SLES-15' => 'sles-15',
3433
'Windows-2016' => 'windows-2016',
3534
'Windows-2019' => 'windows-2019',
3635
'Windows-2022' => 'windows-2022'
3736
}.freeze
3837

38+
ARM_IMAGE_TABLE = {
39+
'RedHat-9-arm' => 'rhel-9-arm64'
40+
}.freeze
41+
3942
DOCKER_PLATFORMS = {
4043
'CentOS-6' => 'litmusimage/centos:6',
4144
'CentOS-7' => 'litmusimage/centos:7',
@@ -112,7 +115,6 @@ if ARGV.include?('--provision-service')
112115
'Ubuntu-20.04' => 'ubuntu-2004-lts',
113116
'Ubuntu-22.04' => 'ubuntu-2204-lts'
114117
}
115-
116118
updated_list = IMAGE_TABLE.dup.clone
117119
updated_list.merge!(updated_platforms)
118120

@@ -152,7 +154,14 @@ else
152154
os = sup['operatingsystem']
153155
sup['operatingsystemrelease'].sort_by(&:to_i).each do |ver|
154156
image_key = "#{os}-#{ver}"
155-
157+
# Add ARM images if they exist and are not excluded
158+
if ARM_IMAGE_TABLE.key?("#{image_key}-arm") && !exclude_list.include?("#{image_key.downcase}-arm")
159+
matrix[:platforms] << {
160+
label: "#{image_key}-arm",
161+
provider: 'provision_service',
162+
image: ARM_IMAGE_TABLE["#{image_key}-arm"]
163+
}
164+
end
156165
if IMAGE_TABLE.key?(image_key) && !exclude_list.include?(image_key.downcase)
157166
matrix[:platforms] << {
158167
label: image_key,

spec/exe/fake_metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"operatingsystem": "RedHat",
2525
"operatingsystemrelease": [
2626
"8",
27-
"9-arm"
27+
"9"
2828
]
2929
},
3030
{

spec/exe/matrix_from_metadata_v2_spec.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@
1616
expect(result.status_code).to eq 0
1717
end
1818

19-
it 'generates the matrix' do
19+
it 'generates the matrix' do # rubocop:disable RSpec/ExampleLength
2020
expect(result.stdout).to include('::warning::Cannot find image for Ubuntu-14.04')
2121
expect(github_output_content).to include(
2222
[
2323
'matrix={',
2424
'"platforms":[',
2525
'{"label":"CentOS-6","provider":"docker","image":"litmusimage/centos:6"},',
2626
'{"label":"RedHat-8","provider":"provision_service","image":"rhel-8"},',
27+
'{"label":"RedHat-9","provider":"provision_service","image":"rhel-9"},',
2728
'{"label":"RedHat-9-arm","provider":"provision_service","image":"rhel-9-arm64"},',
2829
'{"label":"Ubuntu-18.04","provider":"docker","image":"litmusimage/ubuntu:18.04"}',
2930
'],',
@@ -36,7 +37,7 @@
3637
expect(github_output_content).to include(
3738
'spec_matrix={"include":[{"puppet_version":"~> 7.24","ruby_version":2.7},{"puppet_version":"~> 8.0","ruby_version":3.2}]}'
3839
)
39-
expect(result.stdout).to include("Created matrix with 10 cells:\n - Acceptance Test Cells: 8\n - Spec Test Cells: 2")
40+
expect(result.stdout).to include("Created matrix with 12 cells:\n - Acceptance Test Cells: 10\n - Spec Test Cells: 2")
4041
end
4142
end
4243

@@ -53,7 +54,7 @@
5354
expect(result.status_code).to eq 0
5455
end
5556

56-
it 'generates the matrix without excluded platforms' do
57+
it 'generates the matrix without excluded platforms' do # rubocop:disable RSpec/ExampleLength
5758
expect(result.stdout).to include('::warning::Cannot find image for Ubuntu-14.04')
5859
expect(result.stdout).to include('::warning::Ubuntu-18.04 was excluded from testing')
5960
expect(github_output_content).to include(
@@ -62,6 +63,7 @@
6263
'"platforms":[',
6364
'{"label":"CentOS-6","provider":"docker","image":"litmusimage/centos:6"},',
6465
'{"label":"RedHat-8","provider":"provision_service","image":"rhel-8"},',
66+
'{"label":"RedHat-9","provider":"provision_service","image":"rhel-9"},',
6567
'{"label":"RedHat-9-arm","provider":"provision_service","image":"rhel-9-arm64"}',
6668
'],',
6769
'"collection":[',
@@ -73,7 +75,7 @@
7375
expect(github_output_content).to include(
7476
'spec_matrix={"include":[{"puppet_version":"~> 7.24","ruby_version":2.7},{"puppet_version":"~> 8.0","ruby_version":3.2}]}'
7577
)
76-
expect(result.stdout).to include("Created matrix with 8 cells:\n - Acceptance Test Cells: 6\n - Spec Test Cells: 2")
78+
expect(result.stdout).to include("Created matrix with 10 cells:\n - Acceptance Test Cells: 8\n - Spec Test Cells: 2")
7779
end
7880
end
7981

0 commit comments

Comments
 (0)