From 48132d55bba99a4356d91ad13d8639755d9f9401 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Fri, 2 Feb 2018 13:45:12 -0500 Subject: replace the CI tests by the ones used in the backupninja module/ --- .gitlab-ci.yml | 45 +++++++++++------------------------- Gemfile | 29 ++++++++--------------- Rakefile | 25 +++++++------------- spec/acceptance/nodesets/default.yml | 19 --------------- spec/spec_helper.rb | 12 ---------- spec/spec_helper_acceptance.rb | 18 --------------- 6 files changed, 31 insertions(+), 117 deletions(-) delete mode 100644 spec/acceptance/nodesets/default.yml delete mode 100644 spec/spec_helper.rb delete mode 100644 spec/spec_helper_acceptance.rb diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 611058c..e474dab 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,39 +1,22 @@ -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 + except: + - legacy -# Default debian jessie versions -test:puppet37: - variables: - PUPPET_VERSION: "~> 3.7.2" - FACTER_VERSION: '~> 2.2.0' - <<: *job_definition - -test:puppet38_future_parser: - variables: - PUPPET_VERSION: '~> 3.8' - FACTER_VERSION: '~> 2.2.0' - FUTURE_PARSER: 'yes' - <<: *job_definition - -# 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 diff --git a/Gemfile b/Gemfile index 7a16b94..514f893 100644 --- a/Gemfile +++ b/Gemfile @@ -1,23 +1,12 @@ -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' - diff --git a/Rakefile b/Rakefile index 85326bb..401002e 100644 --- a/Rakefile +++ b/Rakefile @@ -1,19 +1,10 @@ -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 diff --git a/spec/acceptance/nodesets/default.yml b/spec/acceptance/nodesets/default.yml deleted file mode 100644 index f09ad62..0000000 --- a/spec/acceptance/nodesets/default.yml +++ /dev/null @@ -1,19 +0,0 @@ -HOSTS: - debian-8-x64: - platform: debian-8-amd64 - image: debian:8 - 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"] diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb deleted file mode 100644 index 3cca63a..0000000 --- a/spec/spec_helper.rb +++ /dev/null @@ -1,12 +0,0 @@ -# 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 diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb deleted file mode 100644 index e6a2cd8..0000000 --- a/spec/spec_helper_acceptance.rb +++ /dev/null @@ -1,18 +0,0 @@ -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 -- cgit v1.2.3