Skip to content

Commit 0e86a10

Browse files
committed
Optimize .travis.yml
1 parent 4e40865 commit 0e86a10

File tree

5 files changed

+106
-26
lines changed

5 files changed

+106
-26
lines changed

.kitchen.docker.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
driver:
3+
name: docker
4+
privileged: true
5+
6+
platforms:
7+
- name: centos-6.6
8+
run_list: 'recipe[docker-integration-test]'
9+
10+
suites:
11+
- name: docker-integration-test
12+
run_list:
13+
- 'recipe[docker-integration-test]'

.travis.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
before_install:
2-
- git submodule update --init --recursive
3-
bundler_args: --without development:integration
1+
sudo: required
2+
3+
services:
4+
- docker
5+
46
language: ruby
5-
rvm:
6-
- 2.3.1
7-
script: bundle exec rake travis
7+
8+
cache: bundler
9+
bundler_args: --without development
10+
11+
script:
12+
- travis_retry bundle exec rake travis

Rakefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ Dir.glob(File.join(__dir__, 'tasks', '**', '*.rb'), &method(:require))
1414

1515
#----------------------------------------------------------------------- tasks
1616
desc 'Run all tests on Travis'
17-
# task :travis => ['style', 'spec', 'integration:cloud']
18-
task :travis => %w(style spec)
17+
task :travis => %w(style spec integration:docker)
1918

2019
# Default
21-
task :default => ['style', 'style:travis', 'spec']
20+
task :default => %w(style spec)

tasks/integration.rb

Lines changed: 78 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,86 @@
2222
require 'rake'
2323

2424
#----------------------------------------------------------- integration tests
25-
begin
26-
require 'kitchen/rake_tasks'
27-
Kitchen::RakeTasks.new
28-
29-
desc 'Run all test instances'
30-
task :kitchen => ['kitchen:all']
31-
rescue LoadError, NameError
32-
STDOUT.puts '[WARN] Kitchen::RakeTasks not loaded'.yellow
33-
end
25+
# begin
26+
# require 'kitchen/rake_tasks'
27+
# Kitchen::RakeTasks.new
28+
#
29+
# desc 'Run all test instances'
30+
# task :kitchen => ['kitchen:all']
31+
# rescue LoadError, NameError
32+
# STDOUT.puts '[WARN] Kitchen::RakeTasks not loaded'.yellow
33+
# end
34+
#
3435

35-
# TODO: from sudo cookboook:
36+
# # TODO: from sudo cookboook:
3637
# Integration tests. Kitchen.ci
3738
namespace :integration do
38-
desc 'Run Test Kitchen with Docker'
39-
task :docker do
40-
Kitchen.logger = Kitchen.default_file_logger
41-
Kitchen::Config.new.instances.each do |instance|
42-
instance.test(:always)
43-
end
39+
begin
40+
require 'kitchen'
41+
42+
desc 'Run Test Kitchen integration tests with Docker'
43+
task :docker do
44+
Kitchen.logger = Kitchen.default_file_logger
45+
loader_config = { :local_config => '.kitchen.docker.yml' }
46+
config = { :loader => Kitchen::Loader::YAML.new(loader_config) }
47+
Kitchen::Config.new(config).instances.each do |instance|
48+
instance.test(:always)
49+
end
50+
end # task
51+
rescue LoadError, NameError
52+
STDOUT.puts '[WARN] Kitchen::RakeTasks not loaded'.yellow
4453
end
4554
end
55+
56+
task :integration => %w(integration:docker)
57+
58+
# where
59+
# integration:cloud
60+
# integration:local
61+
# integration:travis
62+
63+
# how
64+
# integration:docker
65+
# integration:vagrant
66+
# integration:parallels
67+
68+
69+
# desc 'Run Test Kitchen integration tests'
70+
# namespace :integration do
71+
# # Gets a collection of instances.
72+
# #
73+
# # @param regexp [String] regular expression to match against instance names.
74+
# # @param config [Hash] configuration values for the `Kitchen::Config` class.
75+
# # @return [Collection<Instance>] all instances.
76+
# def kitchen_instances(regexp, config)
77+
# instances = Kitchen::Config.new(config).instances
78+
# return instances if regexp.nil? || regexp == 'all'
79+
# instances.get_all(Regexp.new(regexp))
80+
# end
81+
#
82+
# # Runs a test kitchen action against some instances.
83+
# #
84+
# # @param action [String] kitchen action to run (defaults to `'test'`).
85+
# # @param regexp [String] regular expression to match against instance names.
86+
# # @param loader_config [Hash] loader configuration options.
87+
# # @return void
88+
# def run_kitchen(action, regexp, loader_config = {})
89+
# action = 'test' if action.nil?
90+
# require 'kitchen'
91+
# Kitchen.logger = Kitchen.default_file_logger
92+
# config = { loader: Kitchen::Loader::YAML.new(loader_config) }
93+
# kitchen_instances(regexp, config).each { |i| i.send(action) }
94+
# end
95+
#
96+
# desc 'Run integration tests with kitchen-vagrant'
97+
# task :vagrant, [:regexp, :action] do |_t, args|
98+
# run_kitchen(args.action, args.regexp)
99+
# end
100+
#
101+
# desc 'Run integration tests with kitchen-docker'
102+
# task :docker, [:regexp, :action] do |_t, args|
103+
# run_kitchen(args.action, args.regexp, local_config: '.kitchen.docker.yml')
104+
# end
105+
# end
106+
#
107+
# task default: %w(integration:vagrant)

tasks/style.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@
6969
end # task
7070
rescue LoadError, NameError
7171
STDOUT.puts '[WARN] Travis gem not loaded'.yellow
72+
task :travis
7273
end
7374
end # namespace
7475

7576
desc 'Run all style checks'
76-
task :style => ['style:chef', 'style:ruby']
77+
task :style => ['style:chef', 'style:ruby', 'style:travis']

0 commit comments

Comments
 (0)