Merge "Trigger apex netvirt csit job on genius patches"
[releng/builder.git] / jjb / packaging / test-puppet.sh
1 #!/bin/bash
2
3 # Options:
4 #   -x: Echo commands
5 #   -e: Fail on errors
6 #   -o pipefail: Fail on errors in scripts this calls, give stacktrace
7 set -ex -o pipefail
8
9 # Adapted from puppet-opendaylight/Vagrantfile
10 # https://git.opendaylight.org/gerrit/gitweb?p=integration/packaging/puppet-opendaylight.git;a=blob;f=Vagrantfile
11
12 # Install system-wide dependencies
13 # TODO: Are all of these still needed?
14 sudo yum install -y ruby-devel gcc-c++ zlib-devel patch redhat-rpm-config make rubygems
15
16 # Install RVM to help build recent version of Ruby
17 # The ruby_dep gem requires >=2.2.5, 2.0.0 is the latest pre-packaged for CentOS
18 gpg2 --keyserver hkp://pool.sks-keyservers.net --recv-keys \
19   409B6B1796C275462A1703113804BB82D39DC0E3 \
20   7D2BAF1CF37B13E2069D6956105BD0E739499BDB
21 curl -L get.rvm.io | bash -s stable
22 # Expected by RVM, seems required to make RVM functions (`rvm use`) available
23 # Silence absurdly verbose rvm output by temporally not echoing commands
24 set +x
25 # Source line has a non-zero exit somewhere, that RVM doesn't mean to indicate
26 # a real failure, but causes our jobs to fail when fail-on-errors is enabled.
27 set +e
28 # shellcheck disable=SC1090
29 source "$HOME/.rvm/scripts/rvm"
30 set -e
31 rvm install 2.6.0
32 set -x
33 ruby --version
34 # This has to be done as a login shell to get rvm fns
35 # https://rvm.io/support/faq#what-shell-login-means-bash-l
36 # http://superuser.com/questions/306530/run-remote-ssh-command-with-full-login-shell
37 bash -lc "rvm use 2.6.0 --default"
38 ruby --version
39
40 # Update RubyGems using itself, as OS package may be old
41 # Ran into RubyGems 2.x installed by OS, 3.x required by Bundler in INTPAK-230
42 gem update --system
43
44 # Install gems dependencies of puppet-opendaylight via Bundler
45 gem install bundler
46 echo export PATH="\\$PATH:/usr/local/bin" >> "$HOME/.bashrc"
47 # RVM's loaded functions print lots of output at this step, silence them
48 set +x
49 pushd "$WORKSPACE/packaging-puppet"
50 set -x
51 bundle install
52 bundle update
53
54 # Execute set of tests passed as param from job
55 bundle exec rake "$TEST_SUITE"