Skip to content

Commit 20b0e18

Browse files
committed
ci: use setup-ruby bundler cache
1 parent f8b8b17 commit 20b0e18

11 files changed

Lines changed: 70 additions & 130 deletions

File tree

Lines changed: 15 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Setup Bundler dependencies
2-
description: Cache and install Ruby gems for a Bundler project.
2+
description: Setup Ruby, cache, and install gems for a Bundler project.
33

44
inputs:
55
working-directory:
@@ -8,22 +8,18 @@ inputs:
88
ruby-version:
99
description: Ruby version used by the job.
1010
required: true
11-
bundle-path:
12-
description: Bundler install path, relative to the working directory.
13-
required: false
14-
default: vendor/bundle
1511
frozen:
16-
description: Whether to run Bundler in frozen mode. Cache saving is disabled when false; restore still runs.
12+
description: Whether to run Bundler in frozen mode.
1713
required: false
1814
default: 'true'
1915
bundler-version:
20-
description: Bundler version selector. Use lockfile, system, or x.y.z.
16+
description: Bundler version selector. Use Gemfile.lock, default, latest, none, or x.y.z.
2117
required: false
22-
default: lockfile
23-
install-args:
24-
description: Arguments for bundle install.
18+
default: Gemfile.lock
19+
cache-version:
20+
description: Arbitrary cache-version value passed through to ruby/setup-ruby.
2521
required: false
26-
default: --jobs=4 --retry=3
22+
default: '0'
2723

2824
runs:
2925
using: composite
@@ -37,36 +33,14 @@ runs:
3733
exit 1
3834
fi
3935
40-
- name: Restore Ruby gems cache
41-
id: restore-ruby-gems-cache
42-
uses: actions/cache/restore@v5
43-
with:
44-
path: ${{ inputs.working-directory }}/${{ inputs.bundle-path }}
45-
# Update to bundle-...-v1 in the future to break the cache if necessary
46-
# or v1-bundle-... if you want restore-keys not to trigger either (update the key there in that case)
47-
key: bundle-${{ runner.os }}-${{ inputs.working-directory }}-${{ inputs.bundle-path }}-ruby${{ inputs.ruby-version }}-${{ hashFiles(format('{0}/Gemfile.lock', inputs.working-directory)) }}
48-
restore-keys: |
49-
bundle-${{ runner.os }}-${{ inputs.working-directory }}-${{ inputs.bundle-path }}-ruby${{ inputs.ruby-version }}-
50-
51-
- name: Install Ruby gems
52-
shell: bash
53-
working-directory: ${{ inputs.working-directory }}
36+
- name: Setup Ruby and install cached gems
37+
uses: ruby/setup-ruby@v1
5438
env:
5539
BUNDLE_FROZEN: ${{ inputs.frozen }}
56-
BUNDLE_INSTALL_ARGS: ${{ inputs.install-args }}
57-
BUNDLE_PATH_CONFIG: ${{ inputs.bundle-path }}
58-
BUNDLER_VERSION_CONFIG: ${{ inputs.bundler-version }}
59-
run: |
60-
bundle config set --local path "$BUNDLE_PATH_CONFIG"
61-
bundle config set --local version "$BUNDLER_VERSION_CONFIG"
62-
# shellcheck disable=SC2086
63-
# Intentionally allow install args to split into separate bundle arguments
64-
bundle check || bundle install $BUNDLE_INSTALL_ARGS
65-
66-
- name: Save Ruby gems cache
67-
# We don't want to overwrite the cache for non-frozen Bundler runs
68-
if: inputs.frozen == 'true' && steps.restore-ruby-gems-cache.outputs.cache-hit != 'true'
69-
uses: actions/cache/save@v5
40+
BUNDLE_RETRY: '3'
7041
with:
71-
path: ${{ inputs.working-directory }}/${{ inputs.bundle-path }}
72-
key: ${{ steps.restore-ruby-gems-cache.outputs.cache-primary-key }}
42+
ruby-version: ${{ inputs.ruby-version }}
43+
working-directory: ${{ inputs.working-directory }}
44+
bundler: ${{ inputs.bundler-version }}
45+
bundler-cache: true
46+
cache-version: ${{ inputs.cache-version }}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Setup Ruby runtime
2+
description: Install Ruby runtime prerequisites and setup Ruby without installing gems.
3+
4+
inputs:
5+
ruby-version:
6+
description: Ruby version used by the job.
7+
required: true
8+
bundler-version:
9+
description: Bundler version selector passed through to ruby/setup-ruby.
10+
required: false
11+
default: Gemfile.lock
12+
install-libyaml:
13+
description: Whether to install libyaml-dev before Ruby/Bundler steps.
14+
required: false
15+
default: 'true'
16+
17+
runs:
18+
using: composite
19+
steps:
20+
- name: Install libyaml-dev
21+
if: runner.os == 'Linux' && inputs.install-libyaml == 'true'
22+
shell: bash
23+
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends libyaml-dev
24+
25+
- name: Setup Ruby
26+
uses: ruby/setup-ruby@v1
27+
with:
28+
ruby-version: ${{ inputs.ruby-version }}
29+
bundler: ${{ inputs.bundler-version }}

.github/workflows/benchmark.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,6 @@ jobs:
144144
env:
145145
SECRET_KEY_BASE: 'dummy-secret-key-for-ci-testing-not-used-in-production'
146146
REACT_ON_RAILS_PRO_LICENSE: ${{ secrets.REACT_ON_RAILS_PRO_LICENSE_V2 }}
147-
# Pro gem server does not publish checksums; needed for Pro benchmark gem installs.
148-
BUNDLE_DISABLE_CHECKSUM_VALIDATION: 'true'
149147
BENCHMARK_PORT: '3001'
150148

151149
steps:
@@ -201,15 +199,10 @@ jobs:
201199
# STEP 3: START APPLICATION SERVER
202200
# ============================================
203201

204-
# libyaml-dev is needed for psych v5 native extensions; install before
205-
# setup-bundle so bundle install can compile psych if required.
206-
- name: Install libyaml-dev (required for psych v5 native extensions)
207-
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends libyaml-dev
208-
209202
# Sets up Ruby for unconditional steps (`gem env home`, Foreman cache/install).
210203
# Dummy app gems are installed in the conditional setup-bundle steps below.
211204
- name: Setup Ruby
212-
uses: ruby/setup-ruby@v1
205+
uses: ./.github/actions/setup-ruby
213206
with:
214207
ruby-version: ${{ env.RUBY_VERSION }}
215208

.github/workflows/examples.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,11 @@ jobs:
123123
- uses: actions/checkout@v4
124124
with:
125125
persist-credentials: false
126-
# libyaml-dev is needed for psych v5 native extensions (sdoc -> rdoc -> psych)
127-
- name: Install libyaml-dev (required for psych v5 native extensions)
128-
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends libyaml-dev
129126
- name: Setup Ruby
130-
uses: ruby/setup-ruby@v1
127+
uses: ./.github/actions/setup-ruby
131128
with:
132129
ruby-version: ${{ matrix.ruby-version }}
133-
bundler: 2.5.9
130+
bundler-version: 2.5.9
134131
- name: Setup Node
135132
uses: actions/setup-node@v4
136133
with:

.github/workflows/gem-tests.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,11 @@ jobs:
120120
- uses: actions/checkout@v4
121121
with:
122122
persist-credentials: false
123-
# libyaml-dev is needed for psych v5 native extensions (sdoc -> rdoc -> psych)
124-
- name: Install libyaml-dev (required for psych v5 native extensions)
125-
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends libyaml-dev
126123
- name: Setup Ruby
127-
uses: ruby/setup-ruby@v1
124+
uses: ./.github/actions/setup-ruby
128125
with:
129126
ruby-version: ${{ matrix.ruby-version }}
130-
bundler: 2.5.9
127+
bundler-version: 2.5.9
131128
- name: Print system information
132129
run: |
133130
echo "Linux release: "; cat /etc/issue

.github/workflows/integration-tests.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,11 @@ jobs:
121121
- uses: actions/checkout@v4
122122
with:
123123
persist-credentials: false
124-
# libyaml-dev is needed for psych v5 native extensions (sdoc -> rdoc -> psych)
125-
- name: Install libyaml-dev (required for psych v5 native extensions)
126-
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends libyaml-dev
127124
- name: Setup Ruby
128-
uses: ruby/setup-ruby@v1
125+
uses: ./.github/actions/setup-ruby
129126
with:
130127
ruby-version: ${{ matrix.ruby-version }}
131-
bundler: 2.5.9
128+
bundler-version: 2.5.9
132129
- name: Setup Node
133130
uses: actions/setup-node@v4
134131
with:
@@ -207,14 +204,11 @@ jobs:
207204
- uses: actions/checkout@v4
208205
with:
209206
persist-credentials: false
210-
# libyaml-dev is needed for psych v5 native extensions (sdoc -> rdoc -> psych)
211-
- name: Install libyaml-dev (required for psych v5 native extensions)
212-
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends libyaml-dev
213207
- name: Setup Ruby
214-
uses: ruby/setup-ruby@v1
208+
uses: ./.github/actions/setup-ruby
215209
with:
216210
ruby-version: ${{ matrix.ruby-version }}
217-
bundler: 2.5.9
211+
bundler-version: 2.5.9
218212
- name: Setup Node
219213
uses: actions/setup-node@v4
220214
with:

.github/workflows/lint-js-and-ruby.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,11 @@ jobs:
9595
# No need for history in lint job
9696
fetch-depth: 1
9797
persist-credentials: false
98-
# libyaml-dev is needed for psych v5 native extensions (sdoc -> rdoc -> psych)
99-
- name: Install libyaml-dev (required for psych v5 native extensions)
100-
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends libyaml-dev
10198
- name: Setup Ruby
102-
uses: ruby/setup-ruby@v1
99+
uses: ./.github/actions/setup-ruby
103100
with:
104101
ruby-version: 3
105-
bundler: 2.5.9
102+
bundler-version: 2.5.9
106103
- name: Setup Node
107104
uses: actions/setup-node@v4
108105
with:

.github/workflows/playwright.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@ jobs:
5252
steps:
5353
- uses: actions/checkout@v4
5454

55-
- uses: ruby/setup-ruby@v1
56-
with:
57-
ruby-version: '3.3'
58-
5955
- uses: actions/setup-node@v4
6056
with:
6157
node-version: '20'
@@ -65,7 +61,7 @@ jobs:
6561

6662
- name: Get pnpm store directory
6763
shell: bash
68-
run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
64+
run: echo "STORE_PATH=$(pnpm store path --silent)" >> "$GITHUB_ENV"
6965

7066
- name: Setup pnpm cache
7167
uses: actions/cache@v4

.github/workflows/precompile-check.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,11 @@ jobs:
8383
- uses: actions/checkout@v4
8484
with:
8585
persist-credentials: false
86-
# libyaml-dev is needed for psych v5
87-
- name: Install libyaml-dev (required for psych v5 native extensions)
88-
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends libyaml-dev
8986
- name: Setup Ruby
90-
uses: ruby/setup-ruby@v1
87+
uses: ./.github/actions/setup-ruby
9188
with:
9289
ruby-version: '3.4'
93-
bundler: 2.5.9
90+
bundler-version: 2.5.9
9491
- name: Setup Node
9592
uses: actions/setup-node@v4
9693
with:

.github/workflows/pro-integration-tests.yml

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -98,23 +98,16 @@ jobs:
9898
runs-on: ubuntu-22.04
9999
env:
100100
REACT_ON_RAILS_PRO_LICENSE: ${{ secrets.REACT_ON_RAILS_PRO_LICENSE_V2 }}
101-
# Pro gem server does not publish checksums. Keep this job-level so every
102-
# setup-bundle install in the job sees the same Bundler setting.
103-
BUNDLE_DISABLE_CHECKSUM_VALIDATION: 'true'
104101
steps:
105102
- uses: actions/checkout@v4
106103
with:
107104
persist-credentials: false
108105

109-
# libyaml-dev is needed for psych v5
110-
- name: Install libyaml-dev (required for psych v5 native extensions)
111-
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends libyaml-dev
112-
113106
- name: Setup Ruby
114-
uses: ruby/setup-ruby@v1
107+
uses: ./.github/actions/setup-ruby
115108
with:
116109
ruby-version: ${{ env.RUBY_VERSION }}
117-
bundler: 2.5.4
110+
bundler-version: 2.5.4
118111

119112
- name: Setup Node
120113
uses: actions/setup-node@v4
@@ -205,21 +198,16 @@ jobs:
205198
runs-on: ubuntu-22.04
206199
env:
207200
REACT_ON_RAILS_PRO_LICENSE: ${{ secrets.REACT_ON_RAILS_PRO_LICENSE_V2 }}
208-
BUNDLE_DISABLE_CHECKSUM_VALIDATION: 'true'
209201
steps:
210202
- uses: actions/checkout@v4
211203
with:
212204
persist-credentials: false
213205

214-
# libyaml-dev is needed for psych v5
215-
- name: Install libyaml-dev (required for psych v5 native extensions)
216-
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends libyaml-dev
217-
218206
- name: Setup Ruby
219-
uses: ruby/setup-ruby@v1
207+
uses: ./.github/actions/setup-ruby
220208
with:
221209
ruby-version: ${{ env.RUBY_VERSION }}
222-
bundler: 2.5.4
210+
bundler-version: 2.5.4
223211

224212
- name: Setup Node
225213
uses: actions/setup-node@v4
@@ -386,7 +374,6 @@ jobs:
386374
runs-on: ubuntu-22.04
387375
env:
388376
REACT_ON_RAILS_PRO_LICENSE: ${{ secrets.REACT_ON_RAILS_PRO_LICENSE_V2 }}
389-
BUNDLE_DISABLE_CHECKSUM_VALIDATION: 'true'
390377
# Redis service container
391378
services:
392379
redis:
@@ -403,15 +390,11 @@ jobs:
403390
with:
404391
persist-credentials: false
405392

406-
# libyaml-dev is needed for psych v5
407-
- name: Install libyaml-dev (required for psych v5 native extensions)
408-
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends libyaml-dev
409-
410393
- name: Setup Ruby
411-
uses: ruby/setup-ruby@v1
394+
uses: ./.github/actions/setup-ruby
412395
with:
413396
ruby-version: ${{ env.RUBY_VERSION }}
414-
bundler: 2.5.4
397+
bundler-version: 2.5.4
415398

416399
- name: Setup Node
417400
uses: actions/setup-node@v4

0 commit comments

Comments
 (0)