Skip to content

Commit fac29a1

Browse files
petergoldsteinpirj
authored andcommitted
Split out Rubocop into a dedicated job and only run once
Exclude both the "bundle" and "tmp" directory. The former ensures we don't run rubocop against installed gems. The latter ensures we don't run it against generated code and apps locally.
1 parent cef194e commit fac29a1

File tree

5 files changed

+29
-12
lines changed

5 files changed

+29
-12
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,19 @@ on:
99
branches:
1010
- '*'
1111
jobs:
12+
rubocop:
13+
name: Rubocop
14+
runs-on: 'ubuntu-20.04'
15+
steps:
16+
- uses: actions/checkout@v2
17+
- uses: ruby/setup-ruby@v1
18+
with:
19+
ruby-version: '3.0'
20+
- run: script/update_rubygems_and_install_bundler
21+
- run: bundle install --standalone
22+
- run: bundle binstubs --all
23+
- run: script/run_rubocop
24+
1225
test:
1326
name: 'Ruby: ${{ matrix.ruby }}, Rails: ${{ matrix.env.RAILS_VERSION }}'
1427
runs-on: ubuntu-20.04

.rubocop.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ AllCops:
55
Exclude:
66
# Templates are really ERB which Rubocop does not parse
77
- bin/**/*
8+
- bundle/**/*
89
- lib/generators/rspec/*/templates/**/*
10+
- tmp/**/*
911

1012
Bundler/DuplicatedGem:
1113
Enabled: false

script/predicate_functions.sh

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,3 @@ function documentation_enforced {
9797
return 1
9898
fi
9999
}
100-
101-
function style_and_lint_enforced {
102-
if [ -x ./bin/rubocop ]; then
103-
return 0
104-
else
105-
return 1
106-
fi
107-
}

script/run_build

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ if documentation_enforced; then
2626
fold "doc check" check_documentation_coverage
2727
fi
2828

29-
if style_and_lint_enforced; then
30-
fold "rubocop" check_style_and_lint
31-
fi
32-
3329
if is_mri; then
3430
fold "one-by-one specs" run_specs_one_by_one
3531
run_all_spec_suites

script/run_rubocop

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
# This file was generated on 2022-01-10T22:24:10+00:00 from the rspec-dev repo.
3+
# DO NOT modify it by hand as your changes will get lost the next time it is generated.
4+
5+
set -e
6+
source script/functions.sh
7+
8+
# Allow repos to override the default functions and add their own
9+
if [ -f script/custom_build_functions.sh ]; then
10+
source script/custom_build_functions.sh
11+
fi
12+
13+
14+
fold "rubocop" check_style_and_lint

0 commit comments

Comments
 (0)