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

Add Arch Linux support #15

Closed
wants to merge 1 commit into from
Closed
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
9 changes: 5 additions & 4 deletions lib/puppet_metadata/beaker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,18 @@ class << self
def os_release_to_setfile(os, release, use_fqdn: false, pidfile_workaround: false)
return unless os_supported?(os)

name = "#{os.downcase}#{release.tr('.', '')}-64"
real_release = ['Gentoo', 'Archlinux'].include?(os) ? 'rolling' : release
name = "#{os.downcase}#{real_release.tr('.', '')}-64"

options = {}
options[:hostname] = "#{name}.example.com" if use_fqdn

# Docker messes up cgroups and some systemd versions can't deal with
# that when PIDFile is used.
if pidfile_workaround?(pidfile_workaround, os)
return if PIDFILE_INCOMPATIBLE[os]&.include?(release)
return if PIDFILE_INCOMPATIBLE[os]&.include?(real_release)

if (image = PIDFILE_COMPATIBLE_IMAGES.dig(os, release))
if (image = PIDFILE_COMPATIBLE_IMAGES.dig(os, real_release))
options[:image] = image
end
end
Expand All @@ -65,7 +66,7 @@ def os_release_to_setfile(os, release, use_fqdn: false, pidfile_workaround: fals
# Return whether a Beaker setfile can be generated for the given OS
# @param [String] os The operating system
def os_supported?(os)
['CentOS', 'Fedora', 'Debian', 'Ubuntu'].include?(os)
['CentOS', 'Fedora', 'Debian', 'Ubuntu', 'Archlinux'].include?(os)
end

private
Expand Down
39 changes: 26 additions & 13 deletions lib/puppet_metadata/github_actions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,35 @@ def puppet_unit_test_matrix
end.compact
end

def construct_matrix_include(setfile, puppet_version)
{
setfile: {
name: setfile[1],
value: setfile[0],
},
puppet: puppet_version
}
end

def github_action_test_matrix(use_fqdn: false, pidfile_workaround: false)
latest_supported_puppet_major_version = metadata.latest_supported_puppet_major_version
metadata.operatingsystems.each_with_object([]) do |(os, releases), matrix_include|
releases&.each do |release|
puppet_major_versions.each do |puppet_version|
next unless AIO.has_aio_build?(os, release, puppet_version[:value])

setfile = PuppetMetadata::Beaker.os_release_to_setfile(os, release, use_fqdn: use_fqdn, pidfile_workaround: pidfile_workaround)
next unless setfile
case os
when 'Archlinux', 'Gentoo'
setfile = PuppetMetadata::Beaker.os_release_to_setfile(os, 'rolling', use_fqdn: use_fqdn, pidfile_workaround: pidfile_workaround)
if setfile
matrix_include << construct_matrix_include(setfile, latest_supported_puppet_major_version)
end
else
releases.each do |release|
puppet_major_versions.each do |puppet_version|
# we currently support beaker jobs in GitHub only for operatingsystems with AIO packages from Puppet Inc
next unless AIO.has_aio_build?(os, release, puppet_version[:value])

matrix_include << {
setfile: {
name: setfile[1],
value: setfile[0],
},
puppet: puppet_version
}
setfile = PuppetMetadata::Beaker.os_release_to_setfile(os, release, use_fqdn: use_fqdn, pidfile_workaround: pidfile_workaround)
next unless setfile
matrix_include << construct_matrix_include(setfile, puppet_version)
end
end
end
end
Expand Down
15 changes: 14 additions & 1 deletion lib/puppet_metadata/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,18 @@ def puppet_major_versions
end
end

# @return [Integer] The newest/latest supported puppet major version
# @see #puppet_major_versions
def latest_supported_puppet_major_version
puppet_major_versions.sort.last
end

# @return [Integer] The oldest supported puppet major version
# @see #puppet_major_versions
def oldest_supported_puppet_major_version
puppet_major_versions.sort.first
end

# A hash representation of the dependencies
#
# Every element in the original array is converted. The name is used as a
Expand Down Expand Up @@ -197,7 +209,8 @@ def github_actions
def beaker_setfiles(use_fqdn: false, pidfile_workaround: false)
operatingsystems.each do |os, releases|
next unless PuppetMetadata::Beaker.os_supported?(os)
releases&.each do |release|
real_releases = ['Gentoo', 'Archlinux'].include?(os) ? ['rolling'] : releases
real_releases&.each do |release|
Comment on lines +212 to +213
Copy link
Member

Choose a reason for hiding this comment

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

Again, here you can make a case statement and use yield just once. It may be easier to follow.

setfile = PuppetMetadata::Beaker.os_release_to_setfile(os, release, use_fqdn: use_fqdn, pidfile_workaround: pidfile_workaround)
yield setfile if setfile
end
Expand Down