summaryrefslogtreecommitdiff
path: root/tasks/bin/run_external_test
blob: 2d191adbb492090b701204bed9f09fd721aeb4f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env ruby

# This script helps to test external gems in the content of the current
# Chef install. We want to make sure that the external gems will still function
# once we release Chef so we run *their* specs against the current contents
# of the chef / ohai repos. It let's us know if we need to update downstream
# gems or fix regressions in chef *before* we release.

$:.unshift(File.expand_path("../../lib", __dir__))

require "tmpdir"
require "bundler"
require "chef/mixin/shell_out"

include Chef::Mixin::ShellOut

github_repo = ARGV.shift
git_thing = ARGV.shift

build_dir = Dir.pwd

env = {
  "GEMFILE_MOD" => "gem 'chef', path: '#{build_dir}'; " \
    "gem 'ohai', git: 'https://github.com/chef/ohai.git', branch: 'master'",
  "CHEF_LICENSE" => "accept-no-persist",
}

Dir.mktmpdir("chef-external-test") do |dir|
  git_url = "https://github.com/#{github_repo}"
  Dir.rmdir dir
  shell_out!("git clone #{git_url} #{dir}", live_stream: STDOUT)
  Dir.chdir(dir) do
    shell_out!("git checkout #{git_thing}", live_stream: STDOUT)
    Bundler.with_unbundled_env do
      shell_out!("bundle install --jobs=3 --retry=3", live_stream: STDOUT, env: env, timeout: 3600)
      shell_out!("bundle exec #{ARGV.join(" ")}", live_stream: STDOUT, env: env)
    end
  end
end