-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add only_changed input to run rubocop only against changed files
Switch to bash for process substitution and working with arrays. Ignore if there are more than 100. Protecting from possibly hitting the command line length limit, it can be much higher and can be calculated or also extracted as one more input if needed. The effect from limiting number of files processed by rubocop is also smaller. Fix ci workflow to fetch all commits for pr branch plus head commit of base branch to be able to find changed files. Co-authored-by: Oliver Günther <[email protected]>
- Loading branch information
1 parent
8d644c0
commit 2aac704
Showing
4 changed files
with
38 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
#!/bin/sh -e | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
cd "${GITHUB_WORKSPACE}/${INPUT_WORKDIR}" || exit | ||
export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}" | ||
|
@@ -85,9 +87,24 @@ else | |
BUNDLE_EXEC="bundle exec " | ||
fi | ||
|
||
if [ "${INPUT_ONLY_CHANGED}" = "true" ]; then | ||
echo '::group:: Getting changed files list' | ||
readarray -t CHANGED_FILES < <( | ||
comm -12 \ | ||
<(git diff --diff-filter=d --name-only "${BASE_REF}..${HEAD_REF}" | sort) \ | ||
<(${BUNDLE_EXEC}rubocop --list-target-files | sort) | ||
Check warning on line 95 in script.sh GitHub Actions / runner / shellcheck
Check failure on line 95 in script.sh GitHub Actions / runner / shellcheck
|
||
) | ||
echo "${CHANGED_FILES[@]}" | ||
if (( ${#CHANGED_FILES[@]} > 100 )); then | ||
echo "More than 100 changed files (${#CHANGED_FILES[@]}), running rubocop on all files" | ||
unset CHANGED_FILES | ||
fi | ||
echo '::endgroup::' | ||
fi | ||
|
||
echo '::group:: Running rubocop with reviewdog 🐶 ...' | ||
# shellcheck disable=SC2086 | ||
${BUNDLE_EXEC}rubocop ${INPUT_RUBOCOP_FLAGS} --require ${GITHUB_ACTION_PATH}/rdjson_formatter/rdjson_formatter.rb --format RdjsonFormatter \ | ||
${BUNDLE_EXEC}rubocop ${INPUT_RUBOCOP_FLAGS} --require ${GITHUB_ACTION_PATH}/rdjson_formatter/rdjson_formatter.rb --format RdjsonFormatter "${CHANGED_FILES[@]}" \ | ||
| reviewdog -f=rdjson \ | ||
-name="${INPUT_TOOL_NAME}" \ | ||
-reporter="${INPUT_REPORTER}" \ | ||
|