Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

automatically filter provision_service from matrix #563

Merged
merged 1 commit into from
Jun 28, 2024
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
6 changes: 6 additions & 0 deletions exe/matrix_from_metadata_v2
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ if ARGV.include?('--provision-service')
DOCKER_PLATFORMS = {}.freeze
end

# disable provision service if repository owner is not puppetlabs
unless ['puppetlabs', nil].include?(ENV.fetch('GITHUB_REPOSITORY_OWNER', nil))
IMAGE_TABLE = {}.freeze
ARM_IMAGE_TABLE = {}.freeze
end

metadata_path = ENV['TEST_MATRIX_FROM_METADATA'] || 'metadata.json'
metadata = JSON.parse(File.read(metadata_path))

Expand Down
39 changes: 39 additions & 0 deletions spec/exe/matrix_from_metadata_v2_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,43 @@
expect(result.stdout).to include("Created matrix with 6 cells:\n - Acceptance Test Cells: 4\n - Spec Test Cells: 2")
end
end

context 'without arguments and GITHUB_REPOSITORY_OWNER is not puppetlabs' do
let(:github_output) { Tempfile.new('github_output') }
let(:github_output_content) { github_output.read }
let(:result) { run_matrix_from_metadata_v2 }

before do
ENV['GITHUB_OUTPUT'] = github_output.path
ENV['GITHUB_REPOSITORY_OWNER'] = 'aforkuser'
end

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

it 'generates the matrix' do
expect(result.stdout).to include('::warning::Cannot find image for CentOS-6')
expect(result.stdout).to include('::warning::Cannot find image for Ubuntu-14.04')
expect(github_output_content).to include(
[
'matrix={',
'"platforms":[',
'{"label":"AmazonLinux-2","provider":"docker","image":"litmusimage/amazonlinux:2"},',
'{"label":"AmazonLinux-2023","provider":"docker","image":"litmusimage/amazonlinux:2023"},',
'{"label":"Ubuntu-18.04","provider":"docker","image":"litmusimage/ubuntu:18.04"},',
'{"label":"Ubuntu-22.04","provider":"docker","image":"litmusimage/ubuntu:22.04"}',
'],',
'"collection":[',
'"puppet7-nightly","puppet8-nightly"',
']',
'}'
].join
)
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")
end
end
end
Loading