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.

Closes-Bug: #1810401
  (cherry picked from commit 7acca40563)

Change-Id: Ibd1ff419d13cace906d4cd9765dc7b5486bc19a7
This commit is contained in:
Sorin Sbarnea 2019-01-04 10:41:31 +00:00
parent 07d465ac71
commit d83f041db9
6 changed files with 46 additions and 11 deletions

View File

@ -57,7 +57,13 @@ fi
print_header 'Install Bundler' print_header 'Install Bundler'
mkdir -p .bundled_gems mkdir -p .bundled_gems
export GEM_HOME=`pwd`/.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 set -e
./run_tests.sh ./run_tests.sh

View File

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

View File

@ -45,7 +45,13 @@
mkdir .bundled_gems mkdir .bundled_gems
export GEM_HOME=`pwd`/.bundled_gems export GEM_HOME=`pwd`/.bundled_gems
if [ -f Gemfile ]; then 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 install --without system_tests --retry 3
$GEM_HOME/bin/bundle exec rspec spec/acceptance $GEM_HOME/bin/bundle exec rspec spec/acceptance
else else

View File

@ -19,7 +19,13 @@
mkdir .bundled_gems mkdir .bundled_gems
export GEM_HOME=`pwd`/.bundled_gems export GEM_HOME=`pwd`/.bundled_gems
if [ -f Gemfile ]; then 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 $GEM_HOME/bin/bundle install --without system_tests
$GEM_HOME/bin/bundle exec rake lint 2>&1 $GEM_HOME/bin/bundle exec rake lint 2>&1
else else

View File

@ -5,7 +5,13 @@
export PUPPET_GEM_VERSION='~> {{ puppet }}' export PUPPET_GEM_VERSION='~> {{ puppet }}'
mkdir .bundled_gems mkdir .bundled_gems
export GEM_HOME=`pwd`/.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 install --retry 3
# FUTURE_PARSER=yes is only supported by Puppet 3.x # FUTURE_PARSER=yes is only supported by Puppet 3.x
if [ "{{ puppet }}" -lt "4" ]; then if [ "{{ puppet }}" -lt "4" ]; then

View File

@ -1,13 +1,20 @@
- hosts: all - hosts: all
tasks: tasks:
- shell: - name: install ruby bundler and run it
shell:
cmd: | cmd: |
if [ "{{ puppet_gem_version }}" != "latest" ]; then if [ "{{ puppet_gem_version }}" != "latest" ]; then
export PUPPET_GEM_VERSION='~> {{ puppet_gem_version }}.0' export PUPPET_GEM_VERSION='~> {{ puppet_gem_version }}.0'
fi fi
mkdir .bundled_gems mkdir .bundled_gems
export GEM_HOME=`pwd`/.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 install --retry 3
$GEM_HOME/bin/bundle exec rake spec SPEC_OPTS='--format documentation' $GEM_HOME/bin/bundle exec rake spec SPEC_OPTS='--format documentation'
chdir: '{{ ansible_user_dir }}/workspace' chdir: '{{ ansible_user_dir }}/workspace'