Skip to content

Commit

Permalink
Merge pull request #129 from ekohl/skip-eol-os
Browse files Browse the repository at this point in the history
Skip EOL operating systems in GHA acceptance tests
  • Loading branch information
bastelfreak authored May 8, 2024
2 parents e8d46eb + 265e44d commit 6d63c4e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
27 changes: 22 additions & 5 deletions lib/puppet_metadata/github_actions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 = {
Expand All @@ -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]
Expand All @@ -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])
Expand Down
3 changes: 2 additions & 1 deletion spec/github_actions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }

Expand Down

0 comments on commit 6d63c4e

Please sign in to comment.