|
70 | 70 | - run: bundle exec rake |
71 | 71 | ``` |
72 | 72 |
|
73 | | -### Matrix |
| 73 | +### Matrix of Ruby Versions |
74 | 74 |
|
75 | 75 | This matrix tests all stable releases and `head` versions of MRI, JRuby and TruffleRuby on Ubuntu and macOS. |
76 | 76 |
|
|
94 | 94 | - run: bundle exec rake |
95 | 95 | ``` |
96 | 96 |
|
| 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 | + |
97 | 120 | See the GitHub Actions documentation for more details about the |
98 | 121 | [workflow syntax](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions) |
99 | 122 | 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 |
136 | 159 | It needs a `Gemfile` (or `$BUNDLE_GEMFILE` or `gems.rb`) under the [`working-directory`](#working-directory). |
137 | 160 | If there is a `Gemfile.lock` (or `$BUNDLE_GEMFILE.lock` or `gems.locked`), `bundle config --local deployment true` is used. |
138 | 161 |
|
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). |
155 | 164 |
|
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`. |
157 | 166 | Therefore, the Bundler `path` should not be changed in your workflow for the cache to work (no `bundle config path`). |
158 | 167 |
|
159 | 168 | ## Windows |
|
0 commit comments