diff --git a/.kitchen.yml b/.kitchen.yml index 6386c82..8f69921 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -1,18 +1,24 @@ --- driver: - name: vagrant - # name: docker - # binary: /usr/bin/docker - # use_sudo: false - # remove_images: true - # build_context: '.' + name: docker + hostname: salt-formula.ci.local + use_sudo: false + require_chef_omnibus: false + +driver_config: + cap_add: + - SYS_PTRACE + +# verifier: +# name: inspec platforms: - - name: debian-jessie64 - # - name: ubuntu-14.04-minimal - driver_config: - box: ssplatt/salt-deb-8 - # box: saltstack/ubuntu-14.04-minimal + - name: ubuntu-14.04 + - name: ubuntu-16.04 + - name: debian-7 + - name: debian-8 + - name: centos-6 + - name: centos-7 provisioner: name: salt_solo @@ -21,9 +27,9 @@ provisioner: is_file_root: false formula: wordpress dependencies: - - {name: php, path: ../php-formula} - - {name: apache, path: ../apache-formula} - - {name: mysql, path: ../mysql-formula} + - {name: php, path: ../php} + - {name: apache, path: ../apache} + - {name: mysql, path: ../mysql} pillars: top.sls: base: diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..790af4c --- /dev/null +++ b/.travis.yml @@ -0,0 +1,43 @@ +language: php + +rvm: + - 2.2.5 + +sudo: required +services: + - docker + - mysql + - apache + +env: + matrix: + - INSTANCE: high-ubuntu-1404 + - INSTANCE: high-ubuntu-1604 + - INSTANCE: high-debian-7 + - INSTANCE: high-debian-8 + - INSTANCE: high-centos-6 + - INSTANCE: cli-ubuntu-1404 + - INSTANCE: cli-ubuntu-1604 + - INSTANCE: cli-debian-7 + - INSTANCE: cli-debian-8 + - INSTANCE: cli-centos-6 + - INSTANCE: config-ubuntu-1404 + - INSTANCE: config-ubuntu-1604 + - INSTANCE: config-debian-7 + - INSTANCE: config-debian-8 + - INSTANCE: config-centos-6 + +# https://github.com/zuazo/kitchen-in-travis-native/issues/1#issuecomment-142455888 +before_script: + - sudo iptables -L DOCKER || sudo iptables -N DOCKER + - sudo apt-get install git + - git clone https://github.com/saltstack-formulas/apache-formula.git /tmp/kitchen/srv/salt/apache + - git clone https://github.com/saltstack-formulas/php-formula.git /tmp/kitchen/srv/salt/php + - git clone https://github.com/saltstack-formulas/mysql-formula.git /tmp/kitchen/srv/salt/mysql + +install: + # setup ci for test formula + - export BUNDLE_GEMFILE=$PWD/Gemfile + - bundle install + +script: bundle exec kitchen verify ${INSTANCE} diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..30fbf14 --- /dev/null +++ b/Gemfile @@ -0,0 +1,18 @@ +source 'https://rubygems.org' + +gem 'codeclimate-test-reporter', group: :test, require: nil +gem 'rake' +gem 'berkshelf', '~> 4.0' + +group :integration do + gem 'test-kitchen' + gem 'kitchen-salt' + gem 'kitchen-inspec' +end + +group :docker do + gem 'kitchen-docker' +end + +# vi: set ft=ruby : +gem "kitchen-vagrant" \ No newline at end of file diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..340c55e --- /dev/null +++ b/Rakefile @@ -0,0 +1,31 @@ +require 'rake' +require 'rake/testtask' +require 'bundler/setup' + +Rake::TestTask.new do |t| + t.libs << 'lib' + t.pattern = 'test/**/*_test.rb' + t.verbose = false +end + +desc 'Run Test Kitchen integration tests' +namespace :integration do + desc 'Run integration tests with kitchen-docker' + task :docker do + require 'kitchen' + Kitchen.logger = Kitchen.default_file_logger + @loader = Kitchen::Loader::YAML.new(local_config: '.kitchen.docker.yml') + Kitchen::Config.new(loader: @loader).instances.each do |instance| + instance.test(:always) + end + end +end + +task default: :test + +begin + require 'kitchen/rake_tasks' + Kitchen::RakeTasks.new +rescue LoadError + puts '>>>>> Kitchen gem not loaded, omitting tasks' unless ENV['CI'] +end \ No newline at end of file diff --git a/test/shared/spec_helper.rb b/test/shared/spec_helper.rb new file mode 100644 index 0000000..d62fc6d --- /dev/null +++ b/test/shared/spec_helper.rb @@ -0,0 +1,9 @@ +require "serverspec" +require "pathname" + +# Set backend type +set :backend, :exec + +RSpec.configure do |c| + c.path = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" +end