From 51f9fc6d8af1b3a6926c6fa591c86ca978be9004 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Fri, 10 Jan 2020 23:00:33 +0100 Subject: [PATCH] Show a full example for caching bundle install * Which should help avoid conflicts with previous caches * See https://github.com/eregon/use-ruby-action/issues/7 --- README.md | 21 ++++++++++++++++++++- dist/index.js | 1 + 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 522b639..4a91cf6 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,26 @@ Otherwise (Ruby < 2.6), Bundler 1 is installed when that Ruby was built. ### Caching `bundle install` -See this [example](https://github.com/actions/cache/blob/master/examples.md#ruby---gem) using [actions/cache](https://github.com/actions/cache). +You can cache the installed gems with these two steps: + +```yaml + - uses: actions/cache@v1 + with: + path: vendor/bundle + key: bundle-use-ruby-${{ matrix.os }}-${{ matrix.ruby }}-${{ hashFiles('**/Gemfile.lock') }} + restore-keys: | + bundle-use-ruby-${{ matrix.os }}-${{ matrix.ruby }}- + - name: Bundle install + run: | + bundle config path vendor/bundle + bundle install --jobs 4 --retry 3 +``` + +When using a single job, replace `${{ matrix.ruby }}` with the ruby version used or `${{ hashFiles('.ruby-version') }}`. + +This uses the [cache action](https://github.com/actions/cache). +The code above is more complete version of the [Gem example](https://github.com/actions/cache/blob/master/examples.md#ruby---gem). +Make sure to include `use-ruby` in the `key` to avoid conflicting with previous caches. ## Limitations diff --git a/dist/index.js b/dist/index.js index 25ed05c..519bf2e 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1400,6 +1400,7 @@ async function run() { rubyPrefix = await windows.downloadExtractAndSetPATH(ruby) } else { if (ruby.startsWith('jruby')) { + // Workaround for https://github.com/actions/virtual-environments/issues/242 core.exportVariable('CLASSPATH', '') } rubyPrefix = await downloadAndExtract(platform, ruby)