Workaround for installing correct version of ruby bundler

See https://github.com/bundler/bundler/issues/6870

Bundler 2.x dropped support for Ruby < 2.3 so now we detect ruby
version and install last known to work version.

This means that newer OS will get newer versions of bundler.

Change-Id: I906ad01187ad5b929b378107de065d32d23c5fc2
Closes-Bug: #1810401
This commit is contained in:
Sorin Sbarnea 2019-01-04 10:41:31 +00:00
parent d87c564bc4
commit 7acca40563
6 changed files with 46 additions and 11 deletions

View File

@ -63,7 +63,13 @@ fi
print_header 'Install Bundler'
mkdir -p .bundled_gems
export GEM_HOME=`pwd`/.bundled_gems
gem install bundler --version 1.17.3 --no-rdoc --no-ri --verbose
ruby <<EOF
cmd = 'gem install bundler --no-rdoc --no-ri --verbose'
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.3.0') then
cmd += ' -v 1.17.3'
end
system(cmd)
EOF
set -e
./run_tests.sh

View File

@ -41,10 +41,14 @@
state: directory
- name: Install bundler
gem:
name: bundler
# Required against https://bugs.launchpad.net/puppet-openstack-integration/+bug/1810401
version: 1.17.3
user_install: false
shell:
cmd: |
ruby <<EOF
cmd = 'gem install bundler --no-rdoc --no-ri --verbose'
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.3.0') then
cmd += ' -v 1.17.3'
end
system(cmd)
EOF
environment:
GEM_HOME: "{{ ansible_user_dir }}/workspace/puppet-openstack-integration/.bundled_gems"

View File

@ -46,7 +46,13 @@
mkdir .bundled_gems
export GEM_HOME=`pwd`/.bundled_gems
if [ -f Gemfile ]; then
gem install bundler --version 1.17.3 --no-rdoc --no-ri --verbose
ruby <<EOF
cmd = 'gem install bundler --no-rdoc --no-ri --verbose'
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.3.0') then
cmd += ' -v 1.17.3'
end
system(cmd)
EOF
$GEM_HOME/bin/bundle install --without system_tests --retry 3
$GEM_HOME/bin/bundle exec rspec spec/acceptance
else

View File

@ -20,7 +20,13 @@
mkdir .bundled_gems
export GEM_HOME=`pwd`/.bundled_gems
if [ -f Gemfile ]; then
gem install --version 1.17.3 bundler --no-rdoc --no-ri --verbose
ruby <<EOF
cmd = 'gem install bundler --no-rdoc --no-ri --verbose'
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.3.0') then
cmd += ' -v 1.17.3'
end
system(cmd)
EOF
$GEM_HOME/bin/bundle install --without system_tests --retry 3
$GEM_HOME/bin/bundle exec rake lint 2>&1
if [ -f metadata.json ]; then

View File

@ -5,7 +5,13 @@
export PUPPET_GEM_VERSION='~> {{ puppet }}'
mkdir .bundled_gems
export GEM_HOME=`pwd`/.bundled_gems
gem install bundler --version 1.17.3 --no-rdoc --no-ri --verbose
ruby <<EOF
cmd = 'gem install bundler --no-rdoc --no-ri --verbose'
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.3.0') then
cmd += ' -v 1.17.3'
end
system(cmd)
EOF
$GEM_HOME/bin/bundle install --retry 3
$GEM_HOME/bin/bundle exec rake syntax
chdir: '{{ ansible_user_dir }}/workspace'

View File

@ -1,6 +1,7 @@
- hosts: all
tasks:
- shell:
- name: install ruby bundler and run it
shell:
cmd: |
if [ "{{ puppet_gem_version }}" != "latest" ]; then
if [ "{{ puppet_gem_version }}" == "5.5" ]; then
@ -12,7 +13,13 @@
fi
mkdir .bundled_gems
export GEM_HOME=`pwd`/.bundled_gems
gem install bundler --version 1.17.3 --no-rdoc --no-ri --verbose
ruby <<EOF
cmd = 'gem install bundler --no-rdoc --no-ri --verbose'
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.3.0') then
cmd += ' -v 1.17.3'
end
system(cmd)
EOF
$GEM_HOME/bin/bundle install --retry 3
$GEM_HOME/bin/bundle exec rake spec SPEC_OPTS='--format documentation'
chdir: '{{ ansible_user_dir }}/workspace'