diff --git a/lib/puppet_metadata/github_actions.rb b/lib/puppet_metadata/github_actions.rb index 18925ad..82b56ed 100644 --- a/lib/puppet_metadata/github_actions.rb +++ b/lib/puppet_metadata/github_actions.rb @@ -9,12 +9,16 @@ def initialize(metadata, options) @options = options end + # @param [Date] at + # The date when to generate the outputs. This affects the acceptance test + # matrix, which excludes EOL operating systems. Its primary purpose is + # reliable (unit) tests which don't break over time. # @return [Hash[Symbol, Any]] The outputs for Github Actions - def outputs + def outputs(at = nil) { puppet_major_versions: puppet_major_versions, puppet_unit_test_matrix: puppet_unit_test_matrix, - puppet_beaker_test_matrix: puppet_beaker_test_matrix, + puppet_beaker_test_matrix: puppet_beaker_test_matrix(at), } end @@ -45,7 +49,7 @@ def puppet_unit_test_matrix end.compact end - def beaker_os_releases + def beaker_os_releases(at = nil) majors = puppet_major_versions distro_puppet_version = { @@ -60,6 +64,19 @@ def beaker_os_releases yield [os, 'rolling', distro_puppet_version] else releases&.each do |release| + if PuppetMetadata::OperatingSystem.eol?(os, release, at) + message = "Skipping EOL operating system #{os} #{release}" + + if ENV.key?('GITHUB_ACTIONS') + # TODO: determine file and position within the file + puts "::warning file=metadata.json::#{message}" + else + warn message + end + + next + end + majors.each do |puppet_version| if AIO.has_aio_build?(os, release, puppet_version[:value]) yield [os, release, puppet_version] @@ -72,10 +89,10 @@ def beaker_os_releases end end - def puppet_beaker_test_matrix + def puppet_beaker_test_matrix(at) matrix_include = [] - beaker_os_releases do |os, release, puppet_version| + beaker_os_releases(at) do |os, release, puppet_version| next if puppet_version_below_minimum?(puppet_version[:value]) setfile = os_release_to_beaker_setfile(os, release, puppet_version[:collection]) diff --git a/spec/github_actions_spec.rb b/spec/github_actions_spec.rb index ccd602d..81bf2bd 100644 --- a/spec/github_actions_spec.rb +++ b/spec/github_actions_spec.rb @@ -3,6 +3,7 @@ describe PuppetMetadata::GithubActions do subject { described_class.new(PuppetMetadata::Metadata.new(JSON.parse(JSON.dump(metadata))), options) } + let(:at) { Date.new(2020, 1, 1) } let(:beaker_pidfile_workaround) { false } let(:minimum_major_puppet_version) { nil } let(:options) do @@ -48,7 +49,7 @@ # rubocop:disable Layout/LineLength,RSpec/ExampleLength describe 'outputs' do - subject { super().outputs } + subject { super().outputs(at) } let(:beaker_pidfile_workaround) { false }