Skip to content

Commit

Permalink
run external kickstart and grub tests on GHA
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeni committed Dec 19, 2023
1 parent 70b2144 commit 9a2452c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/foreman.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ jobs:
- 'webpack:compile test:integration'
- 'db:seed'
- 'assets:precompile RAILS_ENV=production DATABASE_URL=nulldb://nohost'
- 'test:external'
steps:
- run: sudo apt-get update
- run: sudo apt-get -qq -y install build-essential libcurl4-openssl-dev zlib1g-dev libpq-dev libvirt-dev
Expand Down Expand Up @@ -110,6 +111,11 @@ jobs:
- name: Install NPM packages
run: npm ci --no-audit
if: contains(matrix.task, 'compile')
- name: Install external test dependencies
run: |
pip3 install pykickstart
sudo apt-get -qq -y install grub-common
if: contains(matrix.task, 'external')
- name: Prepare test env
run: |
bundle exec rake db:create
Expand Down
6 changes: 4 additions & 2 deletions test/external/grub_syntax_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ class GrubSyntaxTest < ActiveSupport::TestCase
private

def grub_check(file)
skip unless find_executable 'grub2-script-check'
output = `grub2-script-check "#{file}" 2>&1`
grub_script_check = find_executable 'grub2-script-check'
grub_script_check = find_executable 'grub-script-check' unless grub_script_check
skip unless grub_script_check
output = `#{grub_script_check} "#{file}" 2>&1`
status = $CHILD_STATUS
assert_empty output
assert status.success?
Expand Down
13 changes: 9 additions & 4 deletions test/external/kickstart_syntax_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
require "English"

class KickstartSyntaxTest < ActiveSupport::TestCase
# Kickstart snapshots are generated only for EL7
["RHEL7"].each do |version|
Dir.glob('test/unit/foreman/renderer/snapshots/ProvisioningTemplate/provision/*Kickstart*').each do |file|
ksfiles = Dir.glob('test/unit/foreman/renderer/snapshots/ProvisioningTemplate/provision/*Kickstart*')
ksfiles_rhel9 = ksfiles.select { |ks| ks.match?('rhel9') }
ksfiles_rhel7 = ksfiles - ksfiles_rhel9

versions = {'RHEL7' => ksfiles_rhel7, 'RHEL9' => ksfiles_rhel9}

versions.each do |version, files|
files.each do |file|
context version do
test file do
ksvalidator(file, version)
Expand All @@ -19,7 +24,7 @@ def ksvalidator(file, version)
skip unless find_executable 'ksvalidator'
output = `ksvalidator --version #{version} '#{file}' 2>&1`
status = $CHILD_STATUS
assert_empty output
assert_empty output.strip.sub(/Checking kickstart file [^ ]+/, '')
assert status.success?
end
end

0 comments on commit 9a2452c

Please sign in to comment.