Skip to content

Commit

Permalink
Merge pull request #22 from axelguilmin/master
Browse files Browse the repository at this point in the history
Add option to run swiftlint only on changed files
  • Loading branch information
norio-nomura authored Jan 26, 2020
2 parents 4fc54d0 + 68744bd commit 3833fa8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ jobs:
uses: norio-nomura/action-swiftlint@3.0.1
with:
args: --strict
- name: GitHub Action for SwiftLint (Only files changed in the PR)
uses: norio-nomura/action-swiftlint@3.0.1
env:
DIFF_BASE: ${{ github.base_ref }}
```
## Secrets
Expand Down
13 changes: 12 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,15 @@ function convertToGitHubActionsLoggingCommands() {
sed -E 's/^(.*):([0-9]+):([0-9]+): (warning|error|[^:]+): (.*)/::\4 file=\1,line=\2,col=\3::\5/'
}

set -o pipefail && swiftlint "$@" | stripPWD | convertToGitHubActionsLoggingCommands
if ! ${DIFF_BASE+false};
then
changedFiles=$(git --no-pager diff --name-only FETCH_HEAD $(git merge-base FETCH_HEAD $DIFF_BASE) -- '*.swift')

if [ -z "$changedFiles" ]
then
echo "No Swift file changed"
exit
fi
fi

set -o pipefail && swiftlint "$@" -- $changedFiles | stripPWD | convertToGitHubActionsLoggingCommands

0 comments on commit 3833fa8

Please sign in to comment.