puppet-openstack-integration/playbooks/run-lint-tests.yaml
Sorin Sbarnea 7acca40563 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
2019-01-07 11:36:27 +00:00

48 lines
1.9 KiB
YAML

- hosts: all
tasks:
- shell:
cmd: |
set -e
if [ -f Modulefile -o -f metadata.json ]; then
if [ -f Modulefile ]; then
MODULE=$(awk '/^name/ {print $NF}' Modulefile |tr -d \"\')
elif [ -f metadata.json ]; then
MODULE=$(python -c 'import json;print json.load(open("metadata.json"))["name"]')
fi
if [ -z "$MODULE" ]; then
echo "Module name not defined in Modulefile or metadata.json"
else
mkdir -p "$MODULE"
rsync -a --exclude="$MODULE" --exclude ".*" . "$MODULE"
cd "$MODULE"
fi
fi
mkdir .bundled_gems
export GEM_HOME=`pwd`/.bundled_gems
if [ -f Gemfile ]; then
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
$GEM_HOME/bin/bundle exec rake metadata_lint 2>&1
fi
else
gem install rake -n ./.bundled_gems/ --no-ri --no-rdoc
gem install puppet-lint -n ./.bundled_gems/ --no-ri --no-rdoc
gem install metadata-json-lint -n ./.bundled_gems/ --no-ri --no-rdoc
gem install puppetlabs_spec_helper -n ./.bundled_gems/ --no-ri --no-rdoc
gem install puppet -n ./.bundled_gems/ --no-ri --no-rdoc
./.bundled_gems/rake lint 2>&1
if [ -f metadata.json ]; then
./.bundled_gems/metadata-json-lint
fi
fi
chdir: '{{ ansible_user_dir }}/workspace'
environment: '{{ zuul | zuul_legacy_vars }}'