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

Skip EOL operating systems in GHA acceptance tests #129

Merged
merged 1 commit into from
May 8, 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
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)
bastelfreak marked this conversation as resolved.
Show resolved Hide resolved
{
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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The metadata instance doesn't have the original file location and only the parsed content, so it can't point to exactly where it was. In practice we pretty much only support metadata.json so this is close enough now.

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