Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Travis testing #166

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.swp
Gemfile.lock
.vendor
vendor
*/spec/*
11 changes: 11 additions & 0 deletions .travis.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
set -ev
MODS="$(git diff HEAD~1 Puppetfile | grep ^- -B2 | grep mod | cut -d"'" -f2)"
rake validate_puppetfile SPEC_OPTS='--format documentation --color --backtrace' || exit 1
for module in ${MODS}; do
if [ -e ./${module}/Rakefile ]; then
rake test_modules[./${module}/Rakefile] SPEC_OPTS='--format documentation --color --backtrace' || exit 1
else
echo "Missing ./${module}/Rakefile, not running spec tests."
fi
done
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
language: ruby
install:
script: "./.travis.sh"
rvm:
- 2.0.0
matrix:
fast_finish: true
env:
matrix:
- PUPPET_GEM_VERSION="~> 3.7.0"
notifications:
email: false
21 changes: 21 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
source ENV['GEM_SOURCE'] || "https://rubygems.org"

group :development, :test do
gem 'bundler'
gem 'r10k'
gem 'rake', '10.1.1'
end

if facterversion = ENV['FACTER_GEM_VERSION']
gem 'facter', facterversion, :require => false
else
gem 'facter', :require => false
end

if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion, :require => false
else
gem 'puppet', :require => false
end

# vim:ft=ruby
33 changes: 33 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
task(:default).clear
task :default => :test

desc 'Run Puppetfile Validation'
task :test => [:validate_puppetfile,:test_modules]

desc "Validate the Puppetfile syntax"
task :validate_puppetfile do
$stderr.puts "---> syntax:puppetfile"
sh "r10k puppetfile check"
end

desc "Run rspec test on specified modules"
task :test_modules, [:modules] do |t, args|
args.with_defaults(:modules => FileList["*/Rakefile"])
Array(args[:modules]).each do |project|
dir = project.pathmap("%d")
Dir.chdir(dir) do
puts "======"
puts "= Running spec test for #{project}"
puts "======"
system('rm -Rf vendor/')
system('rm -Rf .bundle/')
FileUtils.mkdir 'vendor'
ENV['GEM_HOME'] = "vendor"
system('bundle install --path=vendor/ --gemfile=./Gemfile')
ENV['BUNDLE_GEMFILE'] = "./Gemfile"
system('bundle exec rake spec')
system('rm -Rf vendor')
system('rm -Rf .bundle/')
end
end
end