Skip to content
This repository was archived by the owner on Mar 17, 2023. It is now read-only.

Commit da4b053

Browse files
authored
Merge pull request #80 from echocat/fix_travis
Fix travis
2 parents 54cfc4a + 7500e8c commit da4b053

File tree

8 files changed

+114
-48
lines changed

8 files changed

+114
-48
lines changed

.travis.yml

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
---
22
sudo: false
33
language: ruby
4+
cache: bundler
45
bundler_args: --without system_tests
5-
script: "bundle exec rake validate && bundle exec rake lint && bundle exec rake spec SPEC_OPTS='--format documentation'"
6+
before_install: rm Gemfile.lock || true
7+
script: bundle exec rake validate lint spec
68
matrix:
79
fast_finish: true
810
include:
9-
- rvm: 1.9.3
10-
env: PUPPET_GEM_VERSION="~> 3.4.0"
11-
- rvm: 1.8.7
12-
env: PUPPET_GEM_VERSION="~> 3.0"
13-
- rvm: 1.9.3
14-
env: PUPPET_GEM_VERSION="~> 3.0"
15-
- rvm: 1.9.3
16-
env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes"
17-
- rvm: 2.1.5
18-
env: PUPPET_GEM_VERSION="~> 3.0"
19-
- rvm: 2.1.5
20-
env: PUPPET_GEM_VERSION="~> 3.6.0"
21-
- rvm: 2.1.5
22-
env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes"
11+
- rvm: 2.1.6
12+
env: PUPPET_GEM_VERSION='~> 4.0' COVERAGE=yes STRICT_VARIABLES=yes
13+
- rvm: 2.1.6
14+
env: PUPPET_GEM_VERSION='https://github.com/puppetlabs/puppet.git#stable
15+
- rvm: 2.1.5
16+
env: PUPPET_GEM_VERSION='~> 3.0' FUTURE_PARSER=yes
17+
- rvm: 2.1.5
18+
env: PUPPET_GEM_VERSION='~> 3.0'
19+
- rvm: 1.9.3
20+
env: PUPPET_GEM_VERSION='~> 3.0'
2321
notifications:
2422
email: false

Gemfile

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,41 @@
1-
source 'https://rubygems.org'
2-
3-
puppetversion = ENV.key?('PUPPET_GEM_VERSION') ? "#{ENV['PUPPET_GEM_VERSION']}" : ['>= 3.3']
4-
facterversion = ENV.key?('FACTER_GEM_VERSION') ? "#{ENV['FACTER_GEM_VERSION']}" : ['>= 1.7']
5-
gem 'puppet', puppetversion
6-
gem 'puppetlabs_spec_helper', '>= 0.1.0'
7-
gem 'puppet-lint', '>= 0.3.2'
8-
gem 'facter', facterversion
9-
gem 'rspec', '< 3.2.0'
1+
source ENV['GEM_SOURCE'] || "https://rubygems.org"
2+
3+
def location_for(place, version = nil)
4+
if place =~ /^((?:git|https?)[:@][^#]*)#(.*)/
5+
[version, { :git => $1, :branch => $2, :require => false }].compact
6+
elsif place =~ /^file:\/\/(.*)/
7+
['>= 0', { :path => File.expand_path($1), :require => false }]
8+
else
9+
[place, version, { :require => false }].compact
10+
end
11+
end
12+
13+
gem 'puppetlabs_spec_helper', '>= 0.1.0', :require => false
14+
gem 'puppet-lint', '>= 0.3.2', :require => false
15+
gem 'rspec-puppet', '>= 2.3.2', :require => false
16+
gem 'rspec-puppet-facts', :require => false
17+
gem 'metadata-json-lint', :require => false
18+
# rubi <1.9 versus rake 11.0.0 workaround
19+
gem 'rake', '< 11.0.0', :require => false if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.0.0')
20+
gem 'json', '< 2.0.0', :require => false if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.0.0')
21+
gem 'json_pure', '<= 2.0.1', :require => false if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.0.0')
22+
23+
gem 'puppet', *location_for(ENV['PUPPET_GEM_VERSION'])
24+
25+
# Only explicitly specify Facter/Hiera if a version has been specified.
26+
# Otherwise it can lead to strange bundler behavior. If you are seeing weird
27+
# gem resolution behavior, try setting `DEBUG_RESOLVER` environment variable
28+
# to `1` and then run bundle install.
29+
gem 'facter', *location_for(ENV['FACTER_GEM_VERSION']) if ENV['FACTER_GEM_VERSION']
30+
gem 'hiera', *location_for(ENV['HIERA_GEM_VERSION']) if ENV['HIERA_GEM_VERSION']
31+
32+
33+
# Evaluate Gemfile.local if it exists
34+
if File.exists? "#{__FILE__}.local"
35+
eval(File.read("#{__FILE__}.local"), binding)
36+
end
37+
38+
# Evaluate ~/.gemfile if it exists
39+
if File.exists?(File.join(Dir.home, '.gemfile'))
40+
eval(File.read(File.join(Dir.home, '.gemfile')), binding)
41+
end

Rakefile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@ PuppetLint.configuration.send('disable_class_inherits_from_params_class')
99
PuppetLint.configuration.send('disable_class_parameter_defaults')
1010
PuppetLint.configuration.send('disable_documentation')
1111
PuppetLint.configuration.send('disable_single_quote_string_with_variables')
12-
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]
12+
PuppetLint.configuration.send('disable_variable_is_lowercase')
13+
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp", "vendor/**/*.pp"]
1314

1415
desc "Validate manifests, templates, and ruby files in lib."
1516
task :validate do
16-
Dir['manifests/**/*.pp'].each do |manifest|
17-
sh "puppet parser validate --noop #{manifest}"
18-
end
17+
sh "puppet parser validate --noop #{Dir['manifests/**/*.pp'].join(" ")}"
1918
Dir['lib/**/*.rb'].each do |lib_file|
2019
sh "ruby -c #{lib_file}"
2120
end

manifests/install.pp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,27 @@
3737
before => Anchor['mongodb::install::end']
3838
}
3939

40-
package { 'mongodb-package':
40+
41+
case $::osfamily {
42+
'Debian': {
43+
package { 'mongodb-package':
4144
ensure => $package_ensure,
4245
name => $::mongodb::repos::apt::package_name,
4346
require => $mongodb_10gen_package_require,
4447
before => [Anchor['mongodb::install::end']]
48+
}
49+
}
50+
'RedHat': {
51+
package { 'mongodb-package':
52+
ensure => $package_ensure,
53+
name => $::mongodb::package_name,
54+
require => $mongodb_10gen_package_require,
55+
before => [Anchor['mongodb::install::end']]
56+
}
57+
}
58+
default: {
59+
fail("Unsupported OS ${::osfamily}")
4560
}
61+
}
4662

4763
}

manifests/repos/yum.pp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@
88
#
99
class mongodb::repos::yum {
1010

11-
yumrepo { 'mongodb_yum_repo':
12-
descr => '10gen MongoDB Repo',
13-
baseurl => 'http://downloads-distro.mongodb.org/repo/redhat/os/$basearch',
14-
enabled => 1,
15-
gpgcheck => 0;
16-
}
17-
11+
yumrepo { 'mongodb_yum_repo':
12+
enabled => 1,
13+
descr => '10gen MongoDB Repo',
14+
baseurl => 'http://downloads-distro.mongodb.org/repo/redhat/os/$basearch',
15+
gpgcheck => 0;
16+
}
1817
}

spec/classes/mongodb_spec.rb

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
11
require 'spec_helper'
22

3-
describe 'mongodb' do
3+
describe 'mongodb', :type => 'class' do
44

55
context 'Unsupported OS' do
6-
let(:facts) {{ :osfamily => 'unsupported' }}
7-
it { expect { should contain_class('mongodb')}.to raise_error(Puppet::Error, /Unsupported OS/ )}
6+
let(:facts) {{ :osfamily => 'unsupported', :operatingsystem => 'UnknownOS' }}
7+
it { is_expected.to raise_error(Puppet::Error,/Unsupported OS/ )}
88
end
99

10-
context 'with defaults for all parameters on RedHat' do
11-
let(:facts) {{ :osfamily => 'RedHat' }}
12-
it { should contain_class('mongodb') }
13-
end
10+
on_supported_os.each do |os, facts|
11+
context "on #{os}" do
12+
let(:facts) do
13+
facts
14+
end
15+
let :pre_condition do
16+
'include ::mongodb'
17+
end
1418

15-
context 'with defaults for all parameters on Debian' do
16-
let(:facts) {{ :osfamily => 'Debian', :lsbdistid => 'ubuntu' }}
17-
it { should contain_class('mongodb') }
19+
case facts[:osfamily]
20+
when 'Debian' then
21+
it { should contain_class('mongodb') }
22+
when 'RedHat' then
23+
it { should contain_class('mongodb') }
24+
else
25+
it { is_expected.to raise_error(Puppet::Error,/Unsupported OS/ )}
26+
end
27+
end
1828
end
19-
2029
end

spec/defines/mongod_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
context 'with defaults for all parameters on RedHat' do
88
let(:facts) {{ :osfamily => 'RedHat' }}
9+
let :pre_condition do
10+
'include ::mongodb::params'
11+
end
912
it { should contain_mongodb__mongod('testdb') }
1013
context 'with deactivate_transparent_hugepage set' do
1114
let(:params) {{ :mongod_deactivate_transparent_hugepage => true }}

spec/spec_helper.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1-
require 'puppetlabs_spec_helper/module_spec_helper'
1+
if ENV['COVERAGE'] == 'yes'
2+
RSpec.configure do |c|
3+
c.after(:suite) do
4+
RSpec::Puppet::Coverage.report!
5+
end
6+
end
7+
end
8+
9+
require 'puppetlabs_spec_helper/module_spec_helper'
10+
require 'rspec-puppet-facts'
11+
include RspecPuppetFacts

0 commit comments

Comments
 (0)