mirror of
https://github.com/actions/cache.git
synced 2024-11-30 07:19:03 +00:00
Recommend ruby/setup-ruby's bundler-cache: true option
Manually caching gems has many issues: * Not working if there is no Gemfile.lock but only a Gemfile * Not having the OS version in the key, which might cause binary incompatibility with system libraries of different ABI version. * Not taking the Ruby version in account. * Not taking the Ruby ABI version of development builds into accounts, which cannot be done with a key, but needs the commit hash. * Using restore-keys would grow the cache over time and have extra gems in the cache. * Those reasons are summarized in https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby#caching-bundle-install-manually
This commit is contained in:
parent
354332455a
commit
1bfe3accb3
23
examples.md
23
examples.md
@ -468,21 +468,18 @@ Replace `~/.local/share/renv` with the correct `path` if not using Ubuntu.
|
|||||||
|
|
||||||
## Ruby - Bundler
|
## Ruby - Bundler
|
||||||
|
|
||||||
```yaml
|
Caching gems with Bundler correctly is not trivial and just using `actions/cache`
|
||||||
- uses: actions/cache@v2
|
is [not enough](https://github.com/ruby/setup-ruby#caching-bundle-install-manually).
|
||||||
with:
|
|
||||||
path: vendor/bundle
|
Instead, it is recommended to use `ruby/setup-ruby`'s
|
||||||
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
|
[`bundler-cache: true` option](https://github.com/ruby/setup-ruby#caching-bundle-install-automatically)
|
||||||
restore-keys: |
|
whenever possible:
|
||||||
${{ runner.os }}-gems-
|
|
||||||
```
|
|
||||||
When dependencies are installed later in the workflow, we must specify the same path for the bundler.
|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Bundle install
|
- uses: ruby/setup-ruby@v1
|
||||||
run: |
|
with:
|
||||||
bundle config path vendor/bundle
|
ruby-version: ...
|
||||||
bundle install --jobs 4 --retry 3
|
bundler-cache: true
|
||||||
```
|
```
|
||||||
|
|
||||||
## Rust - Cargo
|
## Rust - Cargo
|
||||||
|
Loading…
Reference in New Issue
Block a user