Skip to content

Commit

Permalink
Merge pull request #2092 from Filipovici-Andrei/fix_github
Browse files Browse the repository at this point in the history
(maint) Fix facter install on windows.
  • Loading branch information
sebastian-miclea authored Sep 18, 2020
2 parents ca71f1e + 3037a7f commit a8c5dc3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
24 changes: 15 additions & 9 deletions .github/actions/presuite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
require 'open3'
require 'fileutils'

def if_no_env_vars_set_defaults
ENV['FACTER_ROOT'] = __dir__.gsub('/.github/actions', '') unless ENV['FACTER_ROOT']
ENV['SHA'] = 'latest' unless ENV['SHA']
ENV['RELEASE_STREAM'] = 'puppet7' unless ENV['RELEASE_STREAM']
end

def install_bundler
message('INSTALL BUNDLER')
run('gem install bundler')
Expand Down Expand Up @@ -43,7 +49,7 @@ def platform_with_options(platform)
def install_puppet_agent
message('INSTALL PUPPET AGENT')

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

run("beaker exec pre-suite --pre-suite #{presuite_file_path} --preserve-state", './', env_path_var)
Expand Down Expand Up @@ -75,7 +81,8 @@ def install_facter
message('OVERWRITE FACTER FROM PUPPET AGENT')

Dir.chdir('../') do
run("\'#{puppet_ruby}\' install.rb --bindir=#{puppet_bin_dir} --sitelibdir=#{facter_lib_path.gsub('facter', '')}")
run("\'#{puppet_ruby}\' install.rb --bindir=\'#{puppet_bin_dir}\' " \
"--sitelibdir=\'#{facter_lib_path.gsub('facter', '')}\'")
end
end

Expand All @@ -96,19 +103,20 @@ def message(message)
def run(command, dir = './', env = {})
puts command
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
exit_status = wait_thr.value
exit(exit_status) if exit_status != 0
end
[output, status]
output
end

ENV['DEBIAN_DISABLE_RUBYGEMS_INTEGRATION'] = 'no_warnings'
ACCEPTANCE_PATH = File.join(ENV['FACTER_4_ROOT'], 'acceptance')
if_no_env_vars_set_defaults
ACCEPTANCE_PATH = File.join(ENV['FACTER_ROOT'], 'acceptance')
HOST_PLATFORM = ARGV[0]

install_bundler
Expand All @@ -118,7 +126,5 @@ def run(command, dir = './', env = {})
initialize_beaker
install_puppet_agent
install_facter

_, status = run_acceptance_tests
exit(status.exitstatus)
run_acceptance_tests
end
8 changes: 4 additions & 4 deletions .github/workflows/acceptance_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ jobs:
os: [windows-2016, windows-2019, ubuntu-16.04, ubuntu-18.04, ubuntu-20.04, macos-10.15]
runs-on: ${{ matrix.os }}
env:
FACTER_4_ROOT: facter_4
FACTER_ROOT: facter
SHA: latest
RELEASE_STREAM: puppet7

steps:
- name: Checkout current PR
uses: actions/checkout@v2
with:
path: facter_4
path: facter

- name: Install Ruby 2.6
uses: ruby/setup-ruby@v1
Expand Down Expand Up @@ -57,8 +57,8 @@ jobs:
- 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 }}
run: sudo -E "PATH=$PATH" ruby $FACTER_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 }}
run: ruby $Env:FACTER_ROOT/.github/actions/presuite.rb ${{ matrix.os }}

0 comments on commit a8c5dc3

Please sign in to comment.