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

(FACT-2600) Run acceptance tests on Windows #519

Merged
merged 69 commits into from
Jun 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 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
243661a
Merge branch 'master' into FACT-2599
May 8, 2020
1587143
(FACT-2600) run on windows
May 8, 2020
308c584
(FACT-2600) run on windows
May 8, 2020
3a6cb0b
(FACT-2600) uninstall beaker
May 11, 2020
90f6e3d
(FACT-2600) uninstall beaker
May 11, 2020
db3d6c5
(FACT-2600) uninstall beaker
May 11, 2020
194cb0b
(FACT-2600) beaker debug
May 12, 2020
eec1681
(FACT-2600) add custom beaker with git
May 12, 2020
0cbf6f0
Merge branch 'master' into FACT-2600
May 13, 2020
e7841d9
(FACT-2600) benchmark bundle install
May 13, 2020
6164a7c
(FACT-2600) debug
May 13, 2020
404b550
(FACT-2600) debug
May 13, 2020
b31494c
Merge branch 'master' into FACT-2600
May 15, 2020
37d6413
(FACT-2600) debug
May 15, 2020
995e7d3
(FACT-2600) debug
May 15, 2020
8860336
Merge branch 'master' into FACT-2600
May 15, 2020
5c6189c
(FACT-2600) run on windows 2019 only
May 15, 2020
06d02aa
(FACT-2600) removed use of custom beaker-puppet
May 18, 2020
dd33354
Revert "(FACT-2600) removed use of custom beaker-puppet"
May 18, 2020
a5db86d
(FACT-2600) changed beaker repo
May 20, 2020
feac35f
(FACT-2600) changed facter branch
May 20, 2020
7b14fa7
Merge branch 'master' into FACT-2600
May 21, 2020
c8a81fa
(maint) changelog for 4.0.24 release
May 26, 2020
6b0baf0
(FACT-2635) Add SearchFact and ResolvedFact with nil type.
May 26, 2020
b0ef7d4
(FACT-2635) Move nil fact resolution to internal fact manager. Fix te…
May 26, 2020
36c43cc
(FACT-2634) Add test for nil fact.
May 26, 2020
f644cf5
(FACT-2635) Rubocop fixes.
May 26, 2020
b669e26
(FACT-2635) Remove unused arguments from error_check.
May 26, 2020
ef96d6b
Merge branch 'master' of github.com:puppetlabs/facter-ng
May 28, 2020
a2e3fac
(FACT-2600) removed custom beaker-puppet
May 21, 2020
f185cfa
Merge branch 'master' into FACT-2600
May 28, 2020
fef475f
Merge branch 'master' of github.com:puppetlabs/facter-ng
May 29, 2020
89dc915
Merge branch 'master' into FACT-2600
May 29, 2020
920ceb7
(FACT-2635) Fix formatter for keys that contain ":" in their name.
May 29, 2020
5f43b7b
Merge branch 'FACT-2635' into FACT-2600
May 29, 2020
451a019
replace any combination of slashes in custom facts paths with File::S…
Jun 2, 2020
7b933dd
Merge branch 'master' of github.com:puppetlabs/facter-ng
Jun 3, 2020
538b6eb
Merge branch 'master' into FACT-2600
Jun 3, 2020
7f64b49
Merge branch 'master' of github.com:puppetlabs/facter-ng
Jun 3, 2020
19248dc
Merge branch 'master' into FACT-2600
Jun 3, 2020
198ab6a
Merge branch 'master' of github.com:puppetlabs/facter-ng
Jun 9, 2020
72ebf46
Merge branch 'master' into FACT-2600
Jun 9, 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
107 changes: 74 additions & 33 deletions .github/actions/presuite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,55 +5,91 @@ def install_bundler
run('gem install bundler')
end

def install_facter_3_dependecies
def install_facter_3_dependencies
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')
def use_custom_beaker
message('USE CUSTOM BEAKER')
beaker_path, _ = run('bundle info beaker --path', FACTER_3_ACCEPTANCE_PATH)
Dir.chdir(beaker_path.split("\n").last) do
run('git init')
run("git remote add origin https://github.com/Filipovici-Andrei/beaker.git")
run('git fetch')
run("git reset --hard origin/github_actions")
end
end

def initialize_beaker
beaker_options = "#{get_beaker_platform(ENV['ImageOS'].to_sym)}{hypervisor=none\\,hostname=localhost}"
beaker_platform_with_options = platform_with_options(beaker_platform)

message('BEAKER INITIALIZE')
run("beaker init -h #{beaker_options} -o config/aio/options.rb")
run("beaker init -h #{beaker_platform_with_options} -o #{File.join('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'
}
def beaker_platform
{
'ubuntu-18.04' => 'ubuntu1804-64a',
'ubuntu-16.04' => 'ubuntu1604-64a',
'macos-10.15' => 'osx1015-64a',
'windows-2016' => 'windows2016-64a',
'windows-2019' => 'windows2019-64a'
}[HOST_PLATFORM]
end

beaker_platforms[host_platform]
def platform_with_options(platform)
return "\"#{platform}{hypervisor=none,hostname=localhost,is_cygwin=false}\"" if platform.include? 'windows'
"#{platform}{hypervisor=none\\,hostname=localhost}"
end

def install_puppet_agent
message('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')
presuite_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}")
run("beaker exec pre-suite --pre-suite #{presuite_file_path} --preserve-state", './', env_path_var)
end

def replace_facter_3_with_facter_4
def puppet_bin_dir
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')
windows_puppet_bin_dir = 'C:\\Program Files\\Puppet Labs\\Puppet\\bin'

(HOST_PLATFORM.include? 'windows') ? windows_puppet_bin_dir : linux_puppet_bin_dir
end

def puppet_command
return '/opt/puppetlabs/puppet/bin/puppet' unless HOST_PLATFORM.include? 'windows'
"\"C:\\Program Files\\Puppet Labs\\Puppet\\bin\\puppet\""
end

def gem_command
return '/opt/puppetlabs/puppet/bin/gem' unless HOST_PLATFORM.include? 'windows'
"\"C:\\Program Files\\Puppet Labs\\Puppet\\puppet\\bin\\gem\""
end

def env_path_var
(HOST_PLATFORM.include? 'windows') ? { 'PATH' => "#{puppet_bin_dir};#{ENV['PATH']}" } : {}
end

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

install_latest_facter_4(gem_command)

message('CHANGE FACTER 3 WITH FACTER 4')

extension = (HOST_PLATFORM.include? 'windows') ? '.bat' : ''
run("mv facter-ng#{extension} facter#{extension}", puppet_bin_dir)
end


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

Expand All @@ -62,14 +98,12 @@ def replace_facter_3_with_facter_4

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')

run('beaker exec tests --test-tag-exclude=server,facter_3 --test-tag-or=risk:high,audit:high', './', env_path_var)
end

def message(message)
Expand All @@ -80,21 +114,28 @@ def message(message)
puts "\n\n#{result}\n\n"
end

def run(command, dir = './')
def run(command, dir = './', env = {})
puts command
output, status = Open3.capture2(command, chdir: dir)
puts output
output = ''
status = 0
Open3.popen2e(env, command, chdir: dir) do |_stdin, stdout_and_err, wait_thr|
stdout_and_err.each do |line|
puts line
output += line
end
status = wait_thr.value
end
[output, status]
end

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

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) { install_facter_3_dependencies }
use_custom_beaker

Dir.chdir(FACTER_3_ACCEPTANCE_PATH) do
initialize_beaker
Expand Down
28 changes: 13 additions & 15 deletions .github/workflows/acceptance_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ jobs:
name: Platform
strategy:
matrix:
os: [ubuntu-18.04, ubuntu-16.04, macos-10.15]
os: [windows-2016, windows-2019, ubuntu-16.04, ubuntu-18.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 @@ -33,22 +31,16 @@ jobs:
uses: actions/checkout@v2
with:
repository: puppetlabs/facter
ref: skip_failures_on_ng
ref: windows_github
path: facter_3

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

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

- name: Fix common permissions
- name: Fix common Linux and MacOs permissions
if: runner.os != 'Windows'
run: sudo chmod a-w /opt

- name: Fix Linux permissions
Expand All @@ -57,11 +49,17 @@ jobs:
sudo chmod a-w /home/runner /usr/share &&
sudo chmod -R a-w /usr/share/rust /home/runner/.config /home/linuxbrew

- name: Instal dhclient
- name: Instal dhclient for Linux
if: runner.os == 'Linux'
run: |
sudo apt install dhcpcd5
sudo dhclient

- name: Run acceptance tests
run: sudo -E "PATH=$PATH" ruby facter_4/.github/actions/presuite.rb
- name: Run acceptance tests on Linux like platform
if: runner.os != 'Windows'
run: sudo -E "PATH=$PATH" ruby $FACTER_4_ROOT/.github/actions/presuite.rb ${{ matrix.os }}

- name: Run acceptance tests on Windows like platform
if: runner.os == 'Windows'
run: ruby $Env:FACTER_4_ROOT/.github/actions/presuite.rb ${{ matrix.os }}