Skip to content

Commit f36eef7

Browse files
committed
Add an example with a matrix of Gemfiles
1 parent ec4649b commit f36eef7

1 file changed

Lines changed: 27 additions & 18 deletions

File tree

README.md

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ jobs:
7070
- run: bundle exec rake
7171
```
7272
73-
### Matrix
73+
### Matrix of Ruby Versions
7474
7575
This matrix tests all stable releases and `head` versions of MRI, JRuby and TruffleRuby on Ubuntu and macOS.
7676

@@ -94,6 +94,29 @@ jobs:
9494
- run: bundle exec rake
9595
```
9696

97+
### Matrix of Gemfiles
98+
99+
```yaml
100+
name: My workflow
101+
on: [push]
102+
jobs:
103+
test:
104+
strategy:
105+
fail-fast: false
106+
matrix:
107+
gemfile: [ rails5, rails6 ]
108+
runs-on: ubuntu-latest
109+
env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
110+
BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
111+
steps:
112+
- uses: actions/checkout@v2
113+
- uses: ./
114+
with:
115+
ruby-version: 2.6
116+
bundler-cache: true
117+
- run: bundle exec rake
118+
```
119+
97120
See the GitHub Actions documentation for more details about the
98121
[workflow syntax](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions)
99122
and the [condition and expression syntax](https://help.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions).
@@ -136,24 +159,10 @@ This caching speeds up installing gems significantly and avoids too many request
136159
It needs a `Gemfile` (or `$BUNDLE_GEMFILE` or `gems.rb`) under the [`working-directory`](#working-directory).
137160
If there is a `Gemfile.lock` (or `$BUNDLE_GEMFILE.lock` or `gems.locked`), `bundle config --local deployment true` is used.
138161

139-
To use a `Gemfile` which is not at the root or has a different name, set `BUNDLE_GEMFILE` in the `env` at the job level, so it is set for all steps:
140-
```yaml
141-
jobs:
142-
test:
143-
runs-on: ubuntu-latest
144-
env:
145-
BUNDLE_GEMFILE: subdir/mygemfile
146-
steps:
147-
- uses: actions/checkout@v2
148-
- uses: ruby/setup-ruby@v1
149-
with:
150-
ruby-version: 2.6
151-
bundler-cache: true
152-
- run: bundle exec rake
153-
```
154-
Of course you can also use a matrix of gemfiles if you need to test multiple gemfiles.
162+
To use a `Gemfile` which is not at the root or has a different name, set `BUNDLE_GEMFILE` in the `env` at the job level
163+
as shown in the [example](#matrix-of-gemfiles).
155164

156-
To perform caching, this action will use `bundle config --local path vendor/bundle`.
165+
To perform caching, this action will use `bundle config --local path $PWD/vendor/bundle`.
157166
Therefore, the Bundler `path` should not be changed in your workflow for the cache to work (no `bundle config path`).
158167

159168
## Windows

0 commit comments

Comments
 (0)