Skip to content

Commit 951ea8f

Browse files
authored
Merge pull request rails#54754 from lovro-bikic/github-actions-rubocop-cache
Add RuboCop cache to GHA workflow templates
2 parents ce35980 + ceb0678 commit 951ea8f

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

railties/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
* Add RuboCop cache restoration to RuboCop job in GitHub Actions workflow templates.
2+
3+
*Lovro Bikić*
4+
15
* Skip generating mailer-related files in authentication generator if the application does
26
not use ActionMailer
37

railties/lib/rails/generators/rails/app/templates/github/ci.yml.tt

+12
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ jobs:
4848
<%- unless skip_rubocop? -%>
4949
lint:
5050
runs-on: ubuntu-latest
51+
env:
52+
RUBOCOP_CACHE_ROOT: tmp/rubocop
5153
steps:
5254
- name: Checkout code
5355
uses: actions/checkout@v4
@@ -58,6 +60,16 @@ jobs:
5860
ruby-version: .ruby-version
5961
bundler-cache: true
6062

63+
- name: Prepare RuboCop cache
64+
uses: actions/cache@v4
65+
env:
66+
DEPENDENCIES_HASH: ${{ hashFiles('.ruby-version', '**/.rubocop.yml', 'Gemfile.lock') }}
67+
with:
68+
path: ${{ env.RUBOCOP_CACHE_ROOT }}
69+
key: rubocop-${{ runner.os }}-${{ env.DEPENDENCIES_HASH }}-${{ github.ref_name == github.event.repository.default_branch && github.run_id || 'default' }}
70+
restore-keys: |
71+
rubocop-${{ runner.os }}-${{ env.DEPENDENCIES_HASH }}-
72+
6173
- name: Lint code for consistent style
6274
run: bin/rubocop -f github
6375

railties/lib/rails/generators/rails/plugin/templates/github/ci.yml.tt

+14-1
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,29 @@ jobs:
99
<%- unless skip_rubocop? -%>
1010
lint:
1111
runs-on: ubuntu-latest
12+
env:
13+
RUBY_VERSION: <%= ENV["RBENV_VERSION"] || ENV["rvm_ruby_string"] || "#{RUBY_ENGINE}-#{RUBY_ENGINE_VERSION}" %>
14+
RUBOCOP_CACHE_ROOT: tmp/rubocop
1215
steps:
1316
- name: Checkout code
1417
uses: actions/checkout@v4
1518

1619
- name: Set up Ruby
1720
uses: ruby/setup-ruby@v1
1821
with:
19-
ruby-version: <%= ENV["RBENV_VERSION"] || ENV["rvm_ruby_string"] || "#{RUBY_ENGINE}-#{RUBY_ENGINE_VERSION}" %>
22+
ruby-version: ${{ env.RUBY_VERSION }}
2023
bundler-cache: true
2124

25+
- name: Prepare RuboCop cache
26+
uses: actions/cache@v4
27+
env:
28+
DEPENDENCIES_HASH: ${{ hashFiles('**/.rubocop.yml', 'Gemfile.lock') }}
29+
with:
30+
path: ${{ env.RUBOCOP_CACHE_ROOT }}
31+
key: rubocop-${{ runner.os }}-${{ env.RUBY_VERSION }}-${{ env.DEPENDENCIES_HASH }}-${{ github.ref_name == github.event.repository.default_branch && github.run_id || 'default' }}
32+
restore-keys: |
33+
rubocop-${{ runner.os }}-${{ env.RUBY_VERSION }}-${{ env.DEPENDENCIES_HASH }}-
34+
2235
- name: Lint code for consistent style
2336
run: bin/rubocop -f github
2437

0 commit comments

Comments
 (0)