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

(FACT-2599) Run GitHub Actions on Ubuntu 16 and Osx 10 #497

Merged
merged 28 commits into from
May 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e7af2e0
(FACT-2569) implemented acceptance tests run in GitHub Actions
Apr 28, 2020
4f69d4a
Merge branch 'master' into FACT-2569
Filipovici-Andrei Apr 28, 2020
a2bab86
(FACT-2569) deactivate check for files with world writable permissions
Apr 28, 2020
873704e
Merge remote-tracking branch 'origin/FACT-2569' into FACT-2569
Apr 28, 2020
8c81c56
(FACT-2569) changed ruby setup
Apr 28, 2020
ccc20f8
(FACT-2569) skipped failing tests on ubuntu
May 5, 2020
b59a0d2
(FACT-2569) skipped failing tests on ubuntu
May 5, 2020
1cf9bf5
(FACT-2569) changed how facter is replaced
May 5, 2020
f24ec56
(FACT-2569) changed how facter is replaced
May 5, 2020
e9b8104
(FACT-2569) changed how facter is replaced
May 5, 2020
3df86f1
Merge branch 'master' into FACT-2569
May 6, 2020
3fc7a95
(FACT-2599) run on all platforms except windows
May 6, 2020
709b42c
(FACT-2599) removed extra parameter
May 6, 2020
5e30163
Merge remote-tracking branch 'origin/FACT-2599' into FACT-2599
May 6, 2020
fed1848
(FACT-2599) debug
May 6, 2020
c475eab
(FACT-2599) debug
May 6, 2020
249d747
Merge remote-tracking branch 'origin/FACT-2599' into FACT-2599
May 6, 2020
6de6f02
(FACT-2599) debug
May 6, 2020
cffd7eb
Merge branch 'master' into FACT-2599
May 7, 2020
54e8374
(FACT-2599) run open3
May 7, 2020
6f00e7e
(FACT-2599) run open3
May 7, 2020
9410c94
(FACT-2599) run open3
May 7, 2020
272ed6c
(FACT-2599) run open3
May 7, 2020
e399197
(FACT-2599) run open3
May 7, 2020
ed5e4a0
(FACT-2599) run open3
May 7, 2020
eb2a85c
(FACT-2599) run open3
May 7, 2020
b764d19
(FACT-2599) run on mac
May 7, 2020
a876584
(FACT-2599) use beaker 4.21.0
May 8, 2020
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
109 changes: 109 additions & 0 deletions .github/actions/presuite.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
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_options = "#{get_beaker_platform(ENV['ImageOS'].to_sym)}{hypervisor=none\\,hostname=localhost}"

message('BEAKER INITIALIZE')
run("beaker init -h #{beaker_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 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.

24 changes: 18 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@ 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
BEAKER_ROOT: beaker
SHA: latest
BEAKER_VERSION: 4.21.0

steps:
- name: Checkout current PR
Expand All @@ -26,22 +30,30 @@ 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
- name: Fix common permissions
run: sudo chmod a-w /opt

- name: Fix Linux permissions
if: runner.os == 'Linux'
run: |
sudo chmod a-w /opt /home/runner /usr/share
sudo chmod a-w /home/runner /usr/share &&
sudo chmod -R a-w /usr/share/rust /home/runner/.config

- name: Fix ubuntu-16.04 permissions
if: matrix.os == 'ubuntu-16.04'
run: sudo chmod -R a-w /home/linuxbrew

- 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