Skip to content

Commit e7acbf3

Browse files
authored
Merge pull request #490 from voxpupuli/more-tests
test different NodeJS versions using beaker_facter
2 parents e01aa10 + 06fc779 commit e7acbf3

6 files changed

Lines changed: 54 additions & 13 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ concurrency:
1313
jobs:
1414
puppet:
1515
name: Puppet
16-
uses: voxpupuli/gha-puppet/.github/workflows/beaker.yml@v1
16+
uses: voxpupuli/gha-puppet/.github/workflows/beaker.yml@v2
1717
with:
1818
pidfile_workaround: 'false'
19+
beaker_facter: 'nodejs_version:NodeJS:16,18,20'

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
jobs:
1313
release:
1414
name: Release
15-
uses: voxpupuli/gha-puppet/.github/workflows/release.yml@v1
15+
uses: voxpupuli/gha-puppet/.github/workflows/release.yml@v2
1616
with:
1717
allowed_owner: 'voxpupuli'
1818
secrets:

.msync.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# Managed by modulesync - DO NOT EDIT
33
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/
44

5-
modulesync_config_version: '7.0.0'
5+
modulesync_config_version: '7.1.0'

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

Gemfile

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ group :test do
77
gem 'voxpupuli-test', '~> 7.0', :require => false
88
gem 'coveralls', :require => false
99
gem 'simplecov-console', :require => false
10-
gem 'puppet_metadata', '~> 3.0', :require => false
10+
gem 'puppet_metadata', '~> 3.5', :require => false
1111
end
1212

1313
group :development do
@@ -16,13 +16,11 @@ group :development do
1616
end
1717

1818
group :system_tests do
19-
gem 'voxpupuli-acceptance', '~> 2.0', :require => false
19+
gem 'voxpupuli-acceptance', '~> 2.2', :require => false
2020
end
2121

2222
group :release do
23-
gem 'github_changelog_generator', '>= 1.16.1', :require => false
24-
gem 'voxpupuli-release', '~> 3.0', :require => false
25-
gem 'faraday-retry', '~> 2.1', :require => false
23+
gem 'voxpupuli-release', '~> 3.0', :require => false
2624
end
2725

2826
gem 'rake', :require => false

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)