Class: PoiseBoiler::Helpers::Rake::Travis

Inherits:
Halite::HelperBase
  • Object
show all
Defined in:
lib/poise_boiler/helpers/rake/travis.rb

Overview

Helper for a Rakefile to install a task for testing on CI.

Examples:

Installing tasks

require 'poise_boiler/helpers/rake/travis'
PoiseBoiler::Helpers::Rake::Travis.install

Running CI suite

$ rake travis

Since:

  • 1.0.0

Instance Method Summary collapse

Instance Method Details

#installvoid

This method returns an undefined value.

Install the rake tasks.

Since:

  • 1.0.0



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/poise_boiler/helpers/rake/travis.rb', line 35

def install
  # Delayed so that Rake doesn't need to be loaded to run this file.
  extend ::Rake::DSL

  file 'test/docker/docker.key' do
    sh(*%w{openssl rsa -in test/docker/docker.pem -passin env:KITCHEN_DOCKER_PASS -out test/docker/docker.key})
  end

  file './docker' do
    begin
      sh(*%w{wget https://get.docker.com/builds/Linux/x86_64/docker-latest.tgz -O docker.tgz})
    rescue RuntimeError
      sh(*%w{curl https://get.docker.com/builds/Linux/x86_64/docker-latest.tgz -o docker.tgz})
    end
    sh(*%w{tar --strip-components=1 -xzvf docker.tgz})
    File.chmod(0755, *%w{./docker ./docker-containerd ./docker-containerd-ctr ./docker-containerd-shim ./docker-runc})
  end

  file '.ssh/id_rsa' do
    # Add a zero-byte passphrase field.
    cmd = %w{ssh-keygen -f} + [File.expand_path('~/.ssh/id_rsa')] +  %w{-b 1024 -P} + ['']
    sh(*cmd)
  end

  task 'travis:integration:rackspace' do
    if integration_rackspace?
      shell.say('Configuring Rackspace test dependencies')
      task('.ssh/id_rsa').invoke
    end
  end

  task 'travis:integration:docker' do
    if integration_docker?
      shell.say('Configuring Docker test dependencies')
      task('test/docker/docker.key').invoke
      task('./docker').invoke
    end
  end

  task 'travis:integration:ec2' do
    if ENV['KITCHEN_EC2_PASS']
      shell.say('Configuring EC2 test dependencies')
      sh(*%w{openssl rsa -in test/ec2/ssh.pem -passin env:KITCHEN_EC2_PASS -out test/ec2/ssh.key})
    end
  end

  desc 'Run Test-Kitchen integration tests.'
  task 'travis:integration' => %w{travis:integration:rackspace travis:integration:docker travis:integration:ec2 chef:kitchen}

  desc 'Run CI tests'
  task 'travis' do
    ENV['POISE_MASTER_BUILD'] = 'true' if master_build?
    run_subtask('spec')
    run_subtask('chef:foodcritic')
    run_subtask('travis:integration') if integration_tests?
    if @failed && !@failed.empty?
      raise "Subtasks #{@failed.join(', ')} failed"
    end
  end
end