Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ in the project module root directory run `bundle exec matrix_from_metadata_v3`
| --provision-prefer | NAME | docker | Prefer provisioner |
| --provision-include | NAME | all | Select provisioner |
| --provision-exclude | NAME | provision_service | Filter provisioner |
| --nightly | | | Install from the nightly puppetcore images |

> Refer to the [built-in matrix.json](https://github.com/puppetlabs/puppet_litmus/blob/main/exe/matrix.json) for a list of supported collection, provisioners, and platforms.

Expand All @@ -90,6 +91,10 @@ in the project module root directory run `bundle exec matrix_from_metadata_v3`
```sh
matrix_from_metadata_v3 --arch-exclude x86_64
```
* Run against the nightly puppetcore images
```sh
matrix_from_metadata_v3 --nightly
```

## Documentation

Expand Down
8 changes: 7 additions & 1 deletion exe/matrix_from_metadata_v3
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ begin
opt.on('--provision-prefer NAME', String, "Prefer provisioner (default: #{default_options[:'provision-prefer']})") { |o| options.provision_prefer.push(*o.split(',')) }
opt.on('--provision-include NAME', String, 'Select provisioner (default: all)') { |o| options.provision_include.push(*o.split(',')) }
opt.on('--provision-exclude NAME', String, "Filter provisioner (default: #{default_options[:'provision-exclude'] || 'none'})") { |o| options.provision_exclude.push(*o.split(',')) }

opt.on('--nightly', TrueClass, 'Enable nightly builds') { |o| options.nightly = o }
end.parse!

Action.config(debug: true) if options[:debug]
Expand Down Expand Up @@ -262,7 +264,11 @@ options[:metadata]['requirements']&.each do |req|

version = collection['puppet'].to_i
prefix = 'puppetcore'
matrix[:collection] << "#{prefix}#{version}-nightly"
matrix[:collection] << if options[:nightly]
"#{prefix}#{version}-nightly"
else
"#{prefix}#{version}"
end

spec_matrix[:include] << {
puppet_version: "~> #{collection['puppet']}",
Expand Down
54 changes: 47 additions & 7 deletions spec/exe/matrix_from_metadata_v3_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
'{"label":"Ubuntu-22.04","provider":"docker","arch":"x86_64","image":"litmusimage/ubuntu:22.04","runner":"ubuntu-latest"}',
'],',
'"collection":[',
'"puppetcore8-nightly"',
'"puppetcore8"',
']',
'}'
].join
Expand Down Expand Up @@ -63,7 +63,7 @@
'{"label":"Ubuntu-22.04-arm","provider":"provision_service","arch":"arm","image":"ubuntu-2204-lts-arm64","runner":"ubuntu-latest"}',
'],',
'"collection":[',
'"puppetcore8-nightly"',
'"puppetcore8"',
']',
'}'
].join
Expand Down Expand Up @@ -103,7 +103,7 @@
'{"label":"Ubuntu-22.04-arm","provider":"provision_service","arch":"arm","image":"ubuntu-2204-lts-arm64","runner":"ubuntu-latest"}',
'],',
'"collection":[',
'"puppetcore8-nightly"',
'"puppetcore8"',
']',
'}'
].join
Expand Down Expand Up @@ -142,7 +142,7 @@
'{"label":"Ubuntu-22.04-arm","provider":"provision_service","arch":"arm","image":"ubuntu-2204-lts-arm64","runner":"ubuntu-latest"}',
'],',
'"collection":[',
'"puppetcore8-nightly"',
'"puppetcore8"',
']',
'}'
].join
Expand Down Expand Up @@ -175,7 +175,7 @@
'"platforms":[',
'],',
'"collection":[',
'"puppetcore8-nightly"',
'"puppetcore8"',
']',
'}'
].join
Expand Down Expand Up @@ -215,7 +215,7 @@
'{"label":"Ubuntu-22.04","provider":"docker","arch":"x86_64","image":"litmusimage/ubuntu:22.04","runner":"ubuntu-latest"}',
'],',
'"collection":[',
'"puppetcore8-nightly"',
'"puppetcore8"',
']',
'}'
].join
Expand All @@ -233,8 +233,48 @@
'::group::spec_matrix'
)
expect(github_output_content).to include(
'"collection":["2023.8.4-puppet_enterprise","2021.7.9-puppet_enterprise","puppetcore8-nightly"'
'"collection":["2023.8.4-puppet_enterprise","2021.7.9-puppet_enterprise","puppetcore8"'
)
expect(github_output_content).to include(
'spec_matrix={"include":[{"puppet_version":"~> 8.0","ruby_version":3.2}]}'
)
end
end

context 'with argument --nightly' do
let(:result) { run_matrix_from_metadata_v3(['--puppetlabs', '--nightly']) }
let(:matrix) do
[
'matrix={',
'"platforms":[',
'{"label":"AmazonLinux-2","provider":"docker","arch":"x86_64","image":"litmusimage/amazonlinux:2","runner":"ubuntu-22.04"},',
'{"label":"AmazonLinux-2023","provider":"docker","arch":"x86_64","image":"litmusimage/amazonlinux:2023","runner":"ubuntu-22.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-22.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":[',
'"puppetcore8-nightly"',
']',
'}'
].join
end

it 'run successfully' do
expect(result.status_code).to eq 0
end

it 'generates the matrix' do
expect(result.stdout).to include(
'::warning::CentOS-6 no provisioner found',
'::warning::Ubuntu-14.04 no provisioner found',
'::group::matrix',
'::group::spec_matrix'
)
expect(github_output_content).to include(matrix)
expect(github_output_content).to include(
'spec_matrix={"include":[{"puppet_version":"~> 8.0","ruby_version":3.2}]}'
)
Expand Down