Commits (2)
image: ruby:2.1
before_script:
- bundle install --jobs $(nproc) --without system_tests --path=/var/cache/gitlab-runner/ "${FLAGS[@]}"
image: ruby:2.3
.job_template: &job_definition
# Test job template
.test_template: &test_definition
stage: test
script:
# don't fail on lint warnings
- bundle exec rake lint || /bin/true
- bundle exec rake syntax
- bundle exec rake validate
- bundle exec rake spec
- bundle install --jobs $(nproc) --without docs --path vendor
- bundle exec rake tests
# Default debian stretch versions
# Test with version present on Debian stable
test:puppet48:
variables:
PUPPET_VERSION: "~> 4.8.2"
FACTER_VERSION: '~> 2.4.6'
<<: *job_definition
HIERA_VERSION: '~> 3.2.0'
<<: *test_definition
# Latest greatest
test:puppet4x:
variables:
PUPPET_VERSION: "> 4"
FACTER_VERSION: '> 2'
<<: *job_definition
# Test with latest Puppet release
test:puppetlatest:
<<: *test_definition
source "https://rubygems.org"
source 'https://rubygems.org'
group :development, :unit_tests do
gem "rake"
gem "rspec-puppet", "~> 2.1", :require => false
gem "rspec-core"
gem "puppetlabs_spec_helper"
gem "semantic_puppet"
gem "metadata-json-lint"
gem "rspec-puppet-facts"
gem "mocha"
end
gem 'rake'
gem 'puppet', ENV['PUPPET_VERSION']
group :system_tests do
gem 'beaker'
gem 'beaker-rspec'
gem 'beaker_spec_helper'
gem 'serverspec'
group :tests do
gem 'facter', ENV['FACTER_VERSION']
gem 'hiera', ENV['HIERA_VERSION']
gem 'puppetlabs_spec_helper'
gem 'metadata-json-lint'
gem 'semantic_puppet'
end
gem "puppet", ENV['PUPPET_VERSION'] || ENV['GEM_PUPPET_VERSION'] || ENV['PUPPET_GEM_VERSION'] || '~> 3.7.0'
gem "facter", ENV['FACTER_VERSION'] || ENV['GEM_FACTER_VERSION'] || ENV['FACTER_GEM_VERSION'] || '~> 2.2.0'
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'
PuppetLint.configuration.send('disable_80chars')
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]
task :tests do
require 'puppetlabs_spec_helper/rake_tasks'
desc "Validate manifests, templates, and ruby files"
task :validate do
Dir['manifests/**/*.pp'].each do |manifest|
sh "puppet parser validate --noop #{manifest}"
end
Dir['spec/**/*.rb','lib/**/*.rb'].each do |ruby_file|
sh "ruby -c #{ruby_file}" unless ruby_file =~ /spec\/fixtures/
end
Dir['templates/**/*.erb'].each do |template|
sh "erb -P -x -T '-' #{template} | ruby -c"
end
end
# run syntax checks on manifests, templates and hiera data
# also runs :metadata_lint
Rake::Task[:validate].invoke
task :test => [:lint, :syntax , :validate, :spec]
# runs puppet-lint
Rake::Task[:lint].invoke
end
......@@ -17,7 +17,7 @@ define borg::backup (
file {
"/usr/local/sbin/borg-${name}":
content => epp('borg/backups.epp', {
content => epp('borg/backups.epp', {
'name' => $name,
'backup_path' => $backup_path,
'archive_name' => $archive_name,
......
{
"name": "baldurmen-borg",
"version": "1.0.0",
"version": "1.0.1",
"author": "Louis-Philippe Véronneau",
"summary": "Simple puppet module to configure backups with borg.",
"license": "GPL-3.0",
......
HOSTS:
debian-9-x64:
platform: debian-9-amd64
image: debian:9
hypervisor: docker
docker_preserve_image: true
docker_cmd: '["/sbin/init"]'
docker_image_commands:
- 'apt-get install -y wget locales-all puppet git'
- 'rm -f /usr/sbin/policy-rc.d'
CONFIG:
type: foss
#log_level: verbose
#log_level: debug
ssh:
password: root
auth_methods: ["password"]
# https://puppetlabs.com/blog/testing-modules-in-the-puppet-forge
require 'puppetlabs_spec_helper/module_spec_helper'
fixture_path = File.expand_path(File.join(__FILE__, '..', 'fixtures'))
RSpec.configure do |c|
c.manifest_dir = File.join(fixture_path, 'manifests')
c.module_path = File.join(fixture_path, 'modules')
c.color = true
end
require 'beaker-rspec'
RSpec.configure do |c|
module_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
module_name = module_root.split('-').last
# Readable test descriptions
c.formatter = :documentation
# Configure all nodes in nodeset
c.before :suite do
# Install module and dependencies
puppet_module_install(:source => module_root, :module_name => module_name)
hosts.each do |host|
shell('git clone https://github.com/puppetlabs/puppetlabs-concat.git /etc/puppet/modules/concat')
end
end
end