Skip to content

Commit 162416a

Browse files
committed
Fix further errors and improve workflow file
1 parent 7515717 commit 162416a

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

.github/workflows/linter.yml

+9-9
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ on:
1010

1111
jobs:
1212

13-
# Workflow adapted from Rails
14-
# https://github.com/rails/rails/blob/main/.github/workflows/rubocop.yml
1513
rubocop:
1614
name: RuboCop
1715
runs-on: ubuntu-latest
@@ -27,20 +25,22 @@ jobs:
2725
ruby-version: 3.1.4
2826
bundler-cache: true
2927

30-
# Deleted files are excluded
3128
# 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
3233
- name: Get changed ruby files (git diff)
3334
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;)
3536
echo "Changed ruby files: $changedFiles"
3637
echo "CHANGED_FILES=$changedFiles" >> $GITHUB_ENV
3738
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
4141
- 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
4444

4545

4646
# eslint:

0 commit comments

Comments
 (0)