Skip to content

Commit 3833fa8

Browse files
authored
Merge pull request #22 from axelguilmin/master
Add option to run swiftlint only on changed files
2 parents 4fc54d0 + 68744bd commit 3833fa8

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ jobs:
2727
uses: norio-nomura/[email protected]
2828
with:
2929
args: --strict
30+
- name: GitHub Action for SwiftLint (Only files changed in the PR)
31+
uses: norio-nomura/[email protected]
32+
env:
33+
DIFF_BASE: ${{ github.base_ref }}
3034
```
3135
3236
## Secrets

entrypoint.sh

+12-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,15 @@ function convertToGitHubActionsLoggingCommands() {
1111
sed -E 's/^(.*):([0-9]+):([0-9]+): (warning|error|[^:]+): (.*)/::\4 file=\1,line=\2,col=\3::\5/'
1212
}
1313

14-
set -o pipefail && swiftlint "$@" | stripPWD | convertToGitHubActionsLoggingCommands
14+
if ! ${DIFF_BASE+false};
15+
then
16+
changedFiles=$(git --no-pager diff --name-only FETCH_HEAD $(git merge-base FETCH_HEAD $DIFF_BASE) -- '*.swift')
17+
18+
if [ -z "$changedFiles" ]
19+
then
20+
echo "No Swift file changed"
21+
exit
22+
fi
23+
fi
24+
25+
set -o pipefail && swiftlint "$@" -- $changedFiles | stripPWD | convertToGitHubActionsLoggingCommands

0 commit comments

Comments
 (0)