diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2017-04-25 19:04:04 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2017-04-25 20:54:33 -0700 |
commit | 6b8130ad431fd61ce865734e7172efc3e0eba672 (patch) | |
tree | 20fd804551035dee4972e8faf3469617a39e0c24 /tasks | |
parent | 71863634ac50dbfb2601de536828b779517066ae (diff) | |
download | chef-6b8130ad431fd61ce865734e7172efc3e0eba672.tar.gz |
major testing overhaullcg/simplify-external-tests
See the PR comments for more philosophical background.
This simplifies the external tests. The major feature here is that
halite, poise, chefspec, etc are removed from the Gemfile.lock and
the transitive Gemfile splicing is gone from the external tests.
We're back to simply tracking master on external projects and bundle
installing without locks and going red if the break. Those external
projects should all similarly track master of chef/chef to reduce
the possibility that they break us here.
This also bumps bundler to 1.14.x and unblocks us there.
It continues to simplify our use of bundler to be more mainstream and
less impenetrable.
There was some crazy shit that I found where I had to remove env vars
like BUNDLE_ENABLE_TRAMPOLINE and the BUNDLE_IGNORE_CONFIG and
BUNDLE_FROZEN env vars in appveyor along with the .bundle/config frozen
setting were necessary to unbreak appveyor. We seem to have gotten
very far afield of standard bundler usage and it was breaking in strange
to debug ways.
Oddly enough this exposed weird errors in the
chef-config/spec/units/fips_spec.rb tests where we need to require the
"win32/registry" file there now even though I can't figure out why that
broke or how it was working previously.
Also, adding x64-mingw32 to x86-mingw32 was necessary to test in
appveyor on 64-bit windows (I tried universal-mingw32 and that failed)
which seems obvious and is another case that I don't understand how it
was working in bundler 1.12.x
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'tasks')
-rwxr-xr-x | tasks/bin/run_external_test | 62 | ||||
-rw-r--r-- | tasks/bundle.rb | 8 | ||||
-rw-r--r-- | tasks/dependencies.rb | 4 |
3 files changed, 22 insertions, 52 deletions
diff --git a/tasks/bin/run_external_test b/tasks/bin/run_external_test index 74f76d3229..1925c3e125 100755 --- a/tasks/bin/run_external_test +++ b/tasks/bin/run_external_test @@ -1,47 +1,25 @@ -#!/bin/bash +#!/usr/bin/env ruby -# Fail fast (e) and echo commands (vx) -set -evx +$:.unshift(File.expand_path("../../lib", File.dirname(__FILE__))) -# Arguments -TEST_GEM=$1 -shift +require "tmpdir" +require "bundler" +require "chef/mixin/shell_out" -PROJECT_ROOT=$(pwd) -PROJECT_BUNDLE_PATH=${BUNDLE_PATH:-$(grep BUNDLE_PATH: $PROJECT_ROOT/.bundle/config | cut -d' ' -f2-)} -if [ -n "$PROJECT_BUNDLE_PATH" ]; then - PROJECT_BUNDLE_PATH=$PROJECT_ROOT/$PROJECT_BUNDLE_PATH -fi +include Chef::Mixin::ShellOut -TEST_GEM_ROOT=$(bundle show $TEST_GEM) +github_repo = ARGV.shift +git_thing = ARGV.shift -# Make a copy of the original Gemfile and stitch in our Gemfile.lock -TEST_GEMFILE=$TEST_GEM_ROOT/Gemfile -MODIFIED_TEST_GEMFILE=$TEST_GEMFILE.externaltest -cat <<EOM > $MODIFIED_TEST_GEMFILE -require_relative "$PROJECT_ROOT/tasks/gemfile_util" -GemfileUtil.include_locked_gemfile(self, "$PROJECT_ROOT/Gemfile", gems: ["$TEST_GEM"] + "$TEST_WITH_GEMS".split(/\s+/)) -$TEST_GEM_OVERRIDES -EOM -cat $TEST_GEMFILE >> $MODIFIED_TEST_GEMFILE -if [ -f $TEST_GEMFILE.lock ]; then - cp $TEST_GEMFILE.lock $MODIFIED_TEST_GEMFILE.lock -elif [ -f $MODIFIED_TEST_GEMFILE.lock ]; then - rm -f $MODIFIED_TEST_GEMFILE.lock -fi - -# Run the bundle install -cd $TEST_GEM_ROOT -export BUNDLE_GEMFILE=$MODIFIED_TEST_GEMFILE -# Don't read from the project .bundle/config, just our env vars -export BUNDLE_IGNORE_CONFIG=true -# Use the top level bundle cache so we don't have to reinstall their packages -if [ -n "$PROJECT_BUNDLE_PATH" ]; then - export BUNDLE_PATH=$PROJECT_BUNDLE_PATH -fi -export BUNDLE_FROZEN= -bundle install -export BUNDLE_FROZEN=true - -bundle config -bundle exec $@ +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_clean_env do + shell_out!("bundle install", live_stream: STDOUT) + shell_out!("bundle exec #{ARGV.join(" ")}", live_stream: STDOUT) + end + end +end diff --git a/tasks/bundle.rb b/tasks/bundle.rb index 0e9b207932..db1bbde4b2 100644 --- a/tasks/bundle.rb +++ b/tasks/bundle.rb @@ -24,9 +24,7 @@ namespace :bundle do task :update, [:args] do |t, rake_args| args = rake_args[:args] || "" Bundler.with_clean_env do - sh "bundle config --local frozen '0'" sh "bundle update #{args}" - sh "bundle config --local frozen '1'" end end @@ -35,9 +33,7 @@ namespace :bundle do args = rake_args[:args] || "" args = rake_args[:args] || "" Bundler.with_clean_env do - sh "bundle config --local frozen '0'" sh "bundle install #{args}" - sh "bundle config --local frozen '1'" end end @@ -57,10 +53,8 @@ namespace :bundle do task :outdated do bundle_outdated = "" Bundler.with_clean_env do - sh "bundle config --local frozen '0'" bundle_outdated = `bundle outdated` puts bundle_outdated - sh "bundle config --local frozen '1'" end outdated_gems = parse_bundle_outdated(bundle_outdated).map { |line, gem_name| gem_name } outdated_gems = outdated_gems.reject { |gem_name| ACCEPTABLE_OUTDATED_GEMS.include?(gem_name) } @@ -74,8 +68,6 @@ desc "Run bundle with arbitrary args" task :bundle, [:args] do |t, rake_args| args = rake_args[:args] || "" Bundler.with_clean_env do - sh "bundle config --local frozen '0'" sh "bundle #{args}" - sh "bundle config --local frozen '1'" end end diff --git a/tasks/dependencies.rb b/tasks/dependencies.rb index 2118644b12..e6e11c0235 100644 --- a/tasks/dependencies.rb +++ b/tasks/dependencies.rb @@ -51,10 +51,10 @@ namespace :dependencies do task task_name do Dir.chdir(dir) do Bundler.with_clean_env do - sh "bundle config --local frozen '0'" + rm_f "#{dir}/Gemfile.lock" sh "bundle lock --update --add-platform ruby" + sh "bundle lock --update --add-platform x64-mingw32" sh "bundle lock --update --add-platform x86-mingw32" - sh "bundle config --local frozen '1'" end end end |