Skip to content

Commit 06fc779

Browse files
committed
test different NodeJS versions using beaker_facter
1 parent a10de4a commit 06fc779

3 files changed

Lines changed: 48 additions & 5 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ jobs:
1616
uses: voxpupuli/gha-puppet/.github/workflows/beaker.yml@v2
1717
with:
1818
pidfile_workaround: 'false'
19+
beaker_facter: 'nodejs_version:NodeJS:16,18,20'

.sync.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ spec/spec_helper.rb:
33
mock_with: ':mocha'
44
spec/spec_helper_acceptance.rb:
55
unmanaged: true
6+
.github/workflows/ci.yml:
7+
beaker_facter: 'nodejs_version:NodeJS:16,18,20'

spec/acceptance/class_spec.rb

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
pkg_cmd = 'dpkg -s nodejs | grep "^Maintainer"'
1111
end
1212

13+
nodejs_version = ENV.fetch('BEAKER_FACTER_nodejs_version', '20')
14+
1315
context 'default parameters' do
1416
it_behaves_like 'an idempotent resource' do
1517
let(:manifest) { "class { 'nodejs': }" }
@@ -27,6 +29,45 @@
2729
end
2830
end
2931

32+
context "explicitly using version #{nodejs_version} from nodesource", if: %w[RedHat Debian].include?(fact('os.family')), skip: (nodejs_version != '16' && fact('os.family') == 'RedHat' && fact('os.release.major') == '7' ? 'Only NodeJS 16 is supported on EL7' : nil) do
33+
# Only nodejs 16 is supported on EL7 by nodesource
34+
35+
include_examples 'cleanup'
36+
37+
# Debian 12 contains NodeJS 18, when we test 16, we need to force the nodesource version
38+
repo_pin =
39+
if nodejs_version == '16' && fact('os.family') == 'Debian' && fact('os.release.major') == '12'
40+
'1000'
41+
else
42+
'undef'
43+
end
44+
45+
it_behaves_like 'an idempotent resource' do
46+
let(:manifest) do
47+
<<-PUPPET
48+
class { 'nodejs':
49+
repo_version => '#{nodejs_version}',
50+
repo_pin => #{repo_pin},
51+
}
52+
PUPPET
53+
end
54+
end
55+
56+
describe package('nodejs') do
57+
it { is_expected.to be_installed }
58+
59+
it 'comes from the expected source' do
60+
pkg_output = shell(pkg_cmd)
61+
expect(pkg_output.stdout).to match 'nodesource'
62+
end
63+
end
64+
65+
describe command('node --version') do
66+
its(:exit_status) { is_expected.to eq 0 }
67+
its(:stdout) { is_expected.to match(%r{^v#{nodejs_version}}) }
68+
end
69+
end
70+
3071
context 'RedHat with repo_class => epel', if: fact('os.family') == 'RedHat' do
3172
include_examples 'cleanup'
3273

@@ -65,12 +106,11 @@ class { 'nodejs':
65106
end
66107
end
67108

68-
context 'RedHat with repo_class => nodejs::repo::dnfmodule', if: fact('os.family') == 'RedHat' && %w[8 9].include?(fact('os.release.major')) do
69-
include_examples 'cleanup'
70-
109+
context 'RedHat with repo_class => nodejs::repo::dnfmodule', if: fact('os.family') == 'RedHat' && %w[8 9].include?(fact('os.release.major')), skip: ((nodejs_version == '20' && fact('os.name') != 'CentOS') || (nodejs_version == '16' && fact('os.release.major') == '9') ? 'NodeJS 20 is not yet in a released EL, NodeJS 16 is not available on EL9' : nil) do
71110
# Node 20 is only available in Stream yet, not in a released EL
72-
# So we're testing 18 here
73-
nodejs_version = '18'
111+
# Node 16 is not available on EL9
112+
113+
include_examples 'cleanup'
74114

75115
it_behaves_like 'an idempotent resource' do
76116
let(:manifest) do

0 commit comments

Comments
 (0)