Skip to content

Commit

Permalink
Add support for OpenVox beaker jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
bastelfreak committed Jan 25, 2025
1 parent c2d5696 commit 608986a
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 14 deletions.
4 changes: 4 additions & 0 deletions lib/puppet_metadata/aio.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ class AIO
8 => '3.2',
}.freeze

OPENVOX_RUBY_VERSIONS = {
8 => '3.2',
}.freeze

class << self
def find_base_os(os)
COMPATIBLE.fetch(os, os)
Expand Down
37 changes: 31 additions & 6 deletions lib/puppet_metadata/github_actions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ def initialize(metadata, options)
def outputs(at = nil)
{
puppet_major_versions: puppet_major_versions,
openvox_major_versions: openvox_major_versions,
puppet_unit_test_matrix: puppet_unit_test_matrix,
puppet_beaker_test_matrix: puppet_beaker_test_matrix(at),
puppet_beaker_test_matrix: puppet_beaker_test_matrix(at) + openvox_beaker_test_matrix(at),
}
end

Expand All @@ -36,6 +37,18 @@ def puppet_major_versions
end.compact
end

def openvox_major_versions
metadata.openvox_major_versions.sort.reverse.map do |version|
next if puppet_version_below_minimum?(version)

{
name: "Puppet #{version}",
value: version,
collection: "openvox#{version}",
}
end.compact
end

def puppet_unit_test_matrix
metadata.puppet_major_versions.sort.reverse.map do |puppet|
ruby = PuppetMetadata::AIO::PUPPET_RUBY_VERSIONS[puppet]
Expand All @@ -49,15 +62,19 @@ def puppet_unit_test_matrix
end.compact
end

def beaker_os_releases(at = nil)
majors = puppet_major_versions
def beaker_os_releases(at = nil, collection)

Check failure on line 65 in lib/puppet_metadata/github_actions.rb

View workflow job for this annotation

GitHub Actions / rubocop_and_matrix

Style/OptionalArguments: Optional arguments should appear at the end of the argument list. (https://rubystyle.guide#optional-arguments)
majors = case collection
when 'puppet'
puppet_major_versions
when 'openvox'
openvox_major_versions
end

distro_puppet_version = {
name: 'Distro Puppet',
value: nil, # We don't know the version and since it's rolling, it can be anything
collection: 'none',
}

metadata.operatingsystems.each do |os, releases|
case os
when 'Archlinux', 'Gentoo'
Expand Down Expand Up @@ -90,17 +107,25 @@ def beaker_os_releases(at = nil)
end

def puppet_beaker_test_matrix(at)
beaker_test_matrix(at, 'puppet')
end

def openvox_beaker_test_matrix(at)
beaker_test_matrix(at, 'openvox')
end

def beaker_test_matrix(at, collection)
matrix_include = []

beaker_os_releases(at) do |os, release, puppet_version|
beaker_os_releases(at, collection) 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])
next unless setfile

name = "#{puppet_version[:name]} - #{setfile[1]}"
env = {
'BEAKER_PUPPET_COLLECTION' => puppet_version[:collection],
"BEAKER_#{collection.upcase}_COLLECTION" => puppet_version[:collection],
'BEAKER_SETFILE' => setfile[0],
}

Expand Down
20 changes: 14 additions & 6 deletions lib/puppet_metadata/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,20 +137,28 @@ def satisfies_requirement?(name, version)
matches?(requirements[name], version)
end

def puppet_major_versions
major_versions('puppet')
end

def openvox_major_versions
major_versions('openvox')
end

# @return [Array[Integer]] Supported major Puppet versions
# @see #requirements
def puppet_major_versions
requirement = requirements['puppet']
raise Exception, 'No Puppet requirement found' unless requirement
def major_versions(collection)
requirement = requirements[collection]
# don't raise an exception
# raise Exception, "No #{collection} requirement found" unless requirement
return [] unless requirement

# Current latest major is 7. It is highly recommended that modules
# actually specify exact bounds, but this prevents an infinite loop.
end_major = (requirement.end == SemanticPuppet::Version::MAX) ? 7 : requirement.end.major

(requirement.begin.major..end_major).select do |major|
requirement.include?(SemanticPuppet::Version.new(major, 0,
0)) || requirement.include?(SemanticPuppet::Version.new(major,
99, 99))
requirement.include?(SemanticPuppet::Version.new(major, 0, 0)) || requirement.include?(SemanticPuppet::Version.new(major, 99, 99))
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/github_actions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
let(:beaker_pidfile_workaround) { false }

it { is_expected.to be_an_instance_of(Hash) }
it { expect(subject.keys).to contain_exactly(:puppet_major_versions, :puppet_unit_test_matrix, :puppet_beaker_test_matrix) }
it { expect(subject.keys).to contain_exactly(:puppet_major_versions, :openvox_major_versions, :puppet_unit_test_matrix, :puppet_beaker_test_matrix, :openvox_beaker_test_matrix) }

describe 'puppet_major_versions' do
subject { super()[:puppet_major_versions] }
Expand Down
3 changes: 2 additions & 1 deletion spec/metadata_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
its(:operatingsystems) { is_expected.to eq({}) }
it { expect(subject.os_release_supported?('any', 'version')).to be(true) }
it { expect(subject.eol_operatingsystems).to eq({}) }
it { expect { subject.puppet_major_versions }.to raise_error(/No Puppet requirement found/) }
# TODO: check that we have at least one thing listed as requirement
# it { expect { subject.puppet_major_versions }.to raise_error(/No puppet requirement found/) }
end

context 'full metadata' do
Expand Down

0 comments on commit 608986a

Please sign in to comment.