From eb03003f665bcc5ff57f5da59b2ec3c0622d4cbf Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 17 Aug 2018 10:41:32 +0200 Subject: [PATCH] Cache bundles on travis, use bundle exec --- .gitignore | 2 ++ .travis.yml | 3 ++- .travis/release.sh | 5 ++++- .travis/render_release_notes.rb | 3 +++ Gemfile | 4 +--- do-release.sh | 6 +++++- 6 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 5edd8ada36..69b2c1e6d7 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,5 @@ bin/ *.patch */src/site/site.xml pmd-core/dependency-reduced-pom.xml +.bundle +vendor diff --git a/.travis.yml b/.travis.yml index 9337e5c414..a52bb4c806 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,7 +34,7 @@ before_install: # Install OracleJDK 10 - see https://sormuras.github.io/blog/2018-03-20-jdk-matrix.html install: - . ./install-jdk.sh -F 10 -L BCL - - bundle install + - bundle install --without=release_notes_preprocessing before_script: true script: source .travis/build-$BUILD.sh after_success: true @@ -71,6 +71,7 @@ notifications: cache: directories: - "$HOME/.m2" + - vendor/bundle # Secure Keys, that need to be set for snapshot builds diff --git a/.travis/release.sh b/.travis/release.sh index 238bf1a088..883f9721d4 100755 --- a/.travis/release.sh +++ b/.travis/release.sh @@ -28,8 +28,11 @@ if [ "${BUILD}" = "deploy" ]; then true ) +# install the gems required for rendering the release notes +bundle install --with=release_notes_preprocessing + # renders, and skips the first 6 lines - the Jekyll front-matter -RENDERED_RELEASE_NOTES=$(.travis/render_release_notes.rb docs/pages/release_notes.md | tail -n +6) +RENDERED_RELEASE_NOTES=$(bundle exec .travis/render_release_notes.rb docs/pages/release_notes.md | tail -n +6) # Assumes, the release has already been created by travis github releases provider RELEASE_ID=$(curl -s -H "Authorization: token ${GITHUB_OAUTH_TOKEN}" https://api.github.com/repos/pmd/pmd/releases/tags/pmd_releases/${RELEASE_VERSION}|jq ".id") diff --git a/.travis/render_release_notes.rb b/.travis/render_release_notes.rb index e1dd76fa8d..d8acab0e74 100755 --- a/.travis/render_release_notes.rb +++ b/.travis/render_release_notes.rb @@ -15,6 +15,9 @@ require "safe_yaml" require_relative "../docs/_plugins/rule_tag" require_relative "../docs/_plugins/custom_filters" +# explicitly setting safe mode to get rid of the warning +SafeYAML::OPTIONS[:default_mode] = :safe + # START OF THE SCRIPT unless ARGV.length == 1 && File.exists?(ARGV[0]) diff --git a/Gemfile b/Gemfile index 0fff68b993..ed76d93bfe 100644 --- a/Gemfile +++ b/Gemfile @@ -3,9 +3,7 @@ source 'https://rubygems.org/' gem 'pmdtester', '~> 1.0.0.pre.beta3' gem 'danger', '~> 5.6', '>= 5.6' -# I think we could skip installing these if we're not a release build -# https://docs.travis-ci.com/user/languages/ruby/#speeding-up-your-build-by-excluding-non-essential-dependencies -# I don't know where to put that in .travis.yml though... +# This group is only needed during release (via .travis/release.sh and do-release.sh) group :release_notes_preprocessing do gem 'liquid', '>=4.0.0' gem 'safe_yaml', '>=1.0' diff --git a/do-release.sh b/do-release.sh index 5a73bdb61a..baabc34935 100755 --- a/do-release.sh +++ b/do-release.sh @@ -62,6 +62,10 @@ echo "Press enter to continue..." read +# install bundles needed for rendering release notes +bundle install with=release_notes_preprocessing --path vendor/bundle + + export RELEASE_VERSION export DEVELOPMENT_VERSION export CURRENT_BRANCH @@ -137,7 +141,7 @@ read # update release_notes_old OLD_RELEASE_NOTES=$(tail -n +8 docs/pages/release_notes_old.md) -NEW_RELEASE_NOTES=$(.travis/render_release_notes.rb docs/pages/release_notes.md | tail -n +6) +NEW_RELEASE_NOTES=$(bundle exec .travis/render_release_notes.rb docs/pages/release_notes.md | tail -n +6) echo "$(head -n 7 docs/pages/release_notes_old.md)" > docs/pages/release_notes_old.md echo "$NEW_RELEASE_NOTES" >> docs/pages/release_notes_old.md echo >> docs/pages/release_notes_old.md