Skip to content

Commit

Permalink
Fix further errors and improve workflow file
Browse files Browse the repository at this point in the history
  • Loading branch information
Splines committed Nov 14, 2023
1 parent 7515717 commit d294cba
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ on:

jobs:

# Workflow adapted from Rails
# https://github.com/rails/rails/blob/main/.github/workflows/rubocop.yml
rubocop:
name: RuboCop
runs-on: ubuntu-latest
Expand All @@ -27,17 +25,17 @@ jobs:
ruby-version: 3.1.4
bundler-cache: true

# Deleted files are excluded
# adapted from https://github.com/actions/checkout/issues/520#issuecomment-1167205721
# and: https://robertfaldo.medium.com/commands-to-run-rubocop-and-specs-you-changed-in-your-branch-e6d2f2e4110b
# --diff-filter=d excludes deleted files
# "|| test $? = 1;" is used to ignore the exit code of grep when no files
# are found matching the pattern
- name: Get changed ruby files (git diff)
run: |
changedFiles=$(git diff-tree --name-only --diff-filter=d -r HEAD^1 HEAD | grep '\.rb$')
changedFiles=$(git diff-tree --name-only --diff-filter=d -r HEAD^1 HEAD | grep '\.rb$' || test $? = 1;)
echo "Changed ruby files: $changedFiles"
echo "CHANGED_FILES=$changedFiles" >> $GITHUB_ENV
# Scope Rubocop to changed files:
# https://robertfaldo.medium.com/commands-to-run-rubocop-and-specs-you-changed-in-your-branch-e6d2f2e4110b
# Exclude deleted files
- name: Run RuboCop
run: |
$CHANGED_FILES | xargs bundle exec rubocop --parallel
Expand Down

0 comments on commit d294cba

Please sign in to comment.