Skip to content
This repository has been archived by the owner on Jun 19, 2020. It is now read-only.

Commit

Permalink
Merge 243661a into 91df292
Browse files Browse the repository at this point in the history
  • Loading branch information
Filipovici-Andrei committed May 8, 2020
2 parents 91df292 + 243661a commit d9f6b69
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 54 deletions.
115 changes: 115 additions & 0 deletions .github/actions/presuite.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
require 'open3'

def install_bundler
message('INSTALL BUNDLER')
run('gem install bundler')
end

def install_facter_3_dependecies
message('INSTALL FACTER 3 ACCEPTANCE DEPENDENCIES')
run('bundle install')
end

def install_custom_beaker
message('BUILD CUSTOM BEAKER GEM')
run('gem build beaker.gemspec')

message('INSTALL CUSTOM BEAKER GEM')
run('gem install beaker-*.gem')
end

def initialize_beaker
beaker_platform = get_beaker_platform(ENV['ImageOS'].to_sym)
beaker_platform_with_options = get_platform_with_options(beaker_platform)

message('BEAKER INITIALIZE')
run("beaker init -h #{beaker_platform_with_options} -o config/aio/options.rb")

message('BEAKER PROVISION')
run('beaker provision')
end

def get_beaker_platform(host_platform)
beaker_platforms = {
ubuntu18: 'ubuntu1804-64a',
ubuntu16: 'ubuntu1604-64a',
macos1015: 'osx1015-64a'
}

beaker_platforms[host_platform]
end

def get_platform_with_options(platform)
return "#{platform}{hypervisor=none,hostname=localhost}" if platform.include? 'ubuntu'
"\"#{platform}{hypervisor=none,hostname=localhost}\"" if platform.include? 'osx'
end

def install_puppet_agent
beaker_puppet_root, _ = run('bundle info beaker-puppet --path')
install_puppet_file_path = File.join(beaker_puppet_root.chomp, 'setup', 'aio', '010_Install_Puppet_Agent.rb')

message('INSTALL PUPPET AGENT')
run("beaker exec pre-suite --pre-suite #{install_puppet_file_path}")
end

def replace_facter_3_with_facter_4
linux_puppet_bin_dir = '/opt/puppetlabs/puppet/bin'
gem_command = File.join(linux_puppet_bin_dir, 'gem')
puppet_command = File.join(linux_puppet_bin_dir, 'puppet')

message('SET FACTER 4 FLAG TO TRUE')
run("#{puppet_command} config set facterng true")

message('BUILD FACTER 4 LATEST AGENT GEM')
run("#{gem_command} build agent/facter-ng.gemspec", ENV['FACTER_4_ROOT'])

message('UNINSTALL DEFAULT FACTER 4 AGENT GEM')
run("#{gem_command} uninstall facter-ng")

message('INSTALL FACTER 4 GEM')
run("#{gem_command} install -f facter-ng-*.gem", ENV['FACTER_4_ROOT'])

message('CHANGE FACTER 3 WITH FACTER 4')
run('mv facter-ng facter', linux_puppet_bin_dir)
end

def run_acceptance_tests
message('RUN ACCEPTANCE TESTS')
run('beaker exec tests --test-tag-exclude=server,facter_3 --test-tag-or=risk:high,audit:high')
end

def message(message)
message_length = message.length
total_length = 130
lines_length = (total_length - message_length) / 2
result = ('-' * lines_length + ' ' + message + ' ' + '-' * lines_length)[0, total_length]
puts "\n\n#{result}\n\n"
end

def run(command, dir = './')
puts command
output, status = Open3.capture2(command, chdir: dir)
puts output
[output, status]
end

ENV['DEBIAN_DISABLE_RUBYGEMS_INTEGRATION'] = 'no_wornings'
FACTER_3_ACCEPTANCE_PATH = File.join(ENV['FACTER_3_ROOT'], 'acceptance')

install_bundler

Dir.chdir(FACTER_3_ACCEPTANCE_PATH) { install_facter_3_dependecies }

Dir.chdir(ENV['BEAKER_ROOT']) { install_custom_beaker }

Dir.chdir(FACTER_3_ACCEPTANCE_PATH) do
initialize_beaker
install_puppet_agent
end

replace_facter_3_with_facter_4

Dir.chdir(FACTER_3_ACCEPTANCE_PATH) do
_, status = run_acceptance_tests
exit(status.exitstatus)
end
48 changes: 0 additions & 48 deletions .github/actions/presuite.sh

This file was deleted.

19 changes: 13 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ on: [pull_request]
jobs:
ci:
name: Run acceptance tests
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-18.04, ubuntu-16.04, macos-10.15]
runs-on: ${{ matrix.os }}
env:
FACTER_3_ROOT: facter_3
FACTER_4_ROOT: facter_4
Expand All @@ -26,22 +29,26 @@ jobs:
ref: skip_failures_on_ng
path: facter_3

- name: Clone Mihai's beaker fork
- name: Clone custom beaker fork
uses: actions/checkout@v2
with:
repository: mihaibuzgau/beaker
ref: master
path: beaker

- name: Install Ruby 2.6.x
- name: Install Ruby 2.6
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.6'

- name: Fix permissions
run: |
sudo chmod a-w /opt /home/runner /usr/share
sudo chmod -R a-w /usr/share/rust /home/runner/.config
if [[ $ImageOS == *ubuntu* ]]
then
sudo chmod a-w /home/runner /usr/share &&
sudo chmod -R a-w /usr/share/rust /home/runner/.config
fi
sudo chmod a-w /opt
- name: Run acceptance tests
run: sudo -E bash -c facter_4/.github/actions/presuite.sh
run: sudo -E "PATH=$PATH" ruby facter_4/.github/actions/presuite.rb

0 comments on commit d9f6b69

Please sign in to comment.