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

Conversation

bastelfreak
Copy link
Member

No description provided.

@ekohl
Copy link
Member

ekohl commented Dec 21, 2020

This is blocked on getting beaker, beaker-puppet and beaker-hostgenerator releases out. voxpupuli/beaker-hostgenerator#191 (comment) has a good overview of what's needed. After that, 👍

@bastelfreak bastelfreak force-pushed the add-archlinux branch 5 times, most recently from c4917c0 to 8a7a903 Compare December 5, 2021 12:32
@bastelfreak bastelfreak force-pushed the add-archlinux branch 3 times, most recently from 22ff65d to 5f7b57e Compare December 5, 2021 12:48
@@ -54,7 +54,8 @@ def puppet_unit_test_matrix

def github_action_test_matrix(use_fqdn: false, pidfile_workaround: false)
metadata.operatingsystems.each_with_object([]) do |(os, releases), matrix_include|
releases&.each do |release|
real_releases = ['Gentoo', 'Archlinux'].include?(os) ? ['rolling'] : releases
Copy link
Member

Choose a reason for hiding this comment

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

I'd like to avoid the duplication between here and the other 2 places. I'm not sure what the best place to capture it, but it feels like this should be captured in the metadata somehow.

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 code is now working . What do you think is the best to do deduplication? we could hack lib/puppet_metadata.rb and set the release to rolling for Arch Linux and Gentoo. But that could confuse people if they assume the metadata object is 1:1 what's in the metadata.json

@bastelfreak bastelfreak force-pushed the add-archlinux branch 3 times, most recently from 059da74 to defe4ea Compare December 5, 2021 13:27
@bastelfreak
Copy link
Member Author

@bastelfreak
Copy link
Member Author

@ekohl can you take a look here again as well?

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

Could you perhaps add some tests. I'd have expected it to fail here:

describe 'beaker_setfiles' do

Looks like that ensures certain values are yielded, but not that nothing else is yielded.

puppet_major_versions.each do |puppet_version|
next unless AIO.has_aio_build?(os, release, puppet_version[:value])
# we currently support beaker jobs in GitHub only for operatingsystems with AIO packages from Puppet Inc or Archlinux
next unless AIO.has_aio_build?(os, release, puppet_version[:value]) || os == 'Archlinux' && puppet_version[:value] == puppet_major_versions.map{|h| h[:value]}.sort.reverse.first
Copy link
Member

Choose a reason for hiding this comment

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

While it doesn't make a huge difference, it's better to do puppet_major_versions.map{|h| h[:value]}.sort.reverse.first outside of the loop. puppet_major_versions doesn't change within it and that makes it a bit more efficient. It can also be more readable if you assign it a variable because right now it's quite a long line.

Also, I think braces around os == 'Archlinux' && ... is clearer.

However, that does make me wonder if we should change the implementation to roughly thing:

metadata.operatingsystems.each_with_object([]) do |(os, releases), matrix_include|
  case os
  when 'Archlinux', 'Gentoo'
    setfile = PuppetMetadata::Beaker.os_release_to_setfile(os, 'rolling', use_fqdn: use_fqdn, pidfile_workaround: pidfile_workaround)
    if setfile
      puppet_version = puppet_major_versions.max_by { |version| version[:value] }[:value]
      matrix_include << construct_matrix_include(setfile, puppet_version)
    end
  else
    releases.each do |release|
      # Pretty much the current code but use construct_matrix_include
    end
  end
end

Copy link
Member Author

Choose a reason for hiding this comment

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

I will have a look at your suggestion later again. for now I created two methods in the metadata class to provide the lowest/highest puppet versions. They are quite short but could be useful for others as well. I just tested it in https://github.com/voxpupuli/puppet-borg/pull/90/checks and it's working as expected.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm a bit confused by construct_matrix_include(). That method doesn't yet exist?

Copy link
Member Author

Choose a reason for hiding this comment

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

I implemented the method. The generated matrix works but the Arch Linux name is now a bit odd:
2022-02-13-132411_465x403_scrot

Copy link
Member Author

Choose a reason for hiding this comment

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

mhm

irb(main):011:0> m.construct_matrix_include(setfile, puppet_version)
=>
{:setfile=>
  {:name=>"Archlinux rolling", :value=>"archlinuxrolling-64{hostname=archlinuxrolling-64.example.com}"},
 :puppet=>7}
irb(main):012:0>

Comment on lines +200 to +213
real_releases = ['Gentoo', 'Archlinux'].include?(os) ? ['rolling'] : releases
real_releases&.each do |release|
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.

@bastelfreak bastelfreak force-pushed the add-archlinux branch 3 times, most recently from 043b990 to 4ca3143 Compare February 13, 2022 11:59
@ekohl ekohl mentioned this pull request Feb 13, 2022
@bastelfreak bastelfreak removed the enhancement New feature or request label Feb 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants