File tree 1 file changed +9
-9
lines changed
1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change 10
10
11
11
jobs :
12
12
13
- # Workflow adapted from Rails
14
- # https://github.com/rails/rails/blob/main/.github/workflows/rubocop.yml
15
13
rubocop :
16
14
name : RuboCop
17
15
runs-on : ubuntu-latest
@@ -27,20 +25,22 @@ jobs:
27
25
ruby-version : 3.1.4
28
26
bundler-cache : true
29
27
30
- # Deleted files are excluded
31
28
# adapted from https://github.com/actions/checkout/issues/520#issuecomment-1167205721
29
+ # and: https://robertfaldo.medium.com/commands-to-run-rubocop-and-specs-you-changed-in-your-branch-e6d2f2e4110b
30
+ # --diff-filter=d excludes deleted files
31
+ # "|| test $? = 1;" is used to ignore the exit code of grep when no files
32
+ # are found matching the pattern
32
33
- name : Get changed ruby files (git diff)
33
34
run : |
34
- changedFiles=$(git diff-tree --name-only --diff-filter=d -r HEAD^1 HEAD | grep '\.rb$')
35
+ changedFiles=$(git diff-tree --name-only --diff-filter=d -r HEAD^1 HEAD | grep '\.rb$' || test $? = 1; )
35
36
echo "Changed ruby files: $changedFiles"
36
37
echo "CHANGED_FILES=$changedFiles" >> $GITHUB_ENV
37
38
38
- # Scope Rubocop to changed files:
39
- # https://robertfaldo.medium.com/commands-to-run-rubocop-and-specs-you-changed-in-your-branch-e6d2f2e4110b
40
- # Exclude deleted files
39
+ # See RuboCop command line flags here:
40
+ # https://docs.rubocop.org/rubocop/usage/basic_usage.html#command-line-flags
41
41
- name : Run RuboCop
42
- run : |
43
- $CHANGED_FILES | xargs bundle exec rubocop --parallel
42
+ if : ${{ env.CHANGED_FILES != '' }}
43
+ run : $CHANGED_FILES | xargs bundle exec rubocop
44
44
45
45
46
46
# eslint:
You can’t perform that action at this time.
0 commit comments