Skip to content

Commit a0fc6f7

Browse files
authored
Merge pull request #34 from m-herold/working_directory
Add optional WORKING_DIRECTORY environment variable and fix test run (#33)
2 parents f3d1a1d + d593cc1 commit a0fc6f7

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

.github/workflows/docker-build.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
- name: Exit Status on Warnings with `--strict`
4949
run: |
5050
STATUS=$(docker run -v $(pwd):$(pwd) -w $(pwd) --rm action-swiftlint --strict &>/dev/null; echo $?)
51-
[[ $STATUS == "3" ]]
51+
[[ $STATUS == "2" ]]
5252
working-directory: ./test/Warnings
5353
shell: bash
5454

@@ -61,3 +61,8 @@ jobs:
6161
run: diff <(docker run -v $(pwd):$(pwd) -w $(pwd) --rm action-swiftlint|sort) expected.txt
6262
working-directory: ./test/Warnings
6363
shell: bash
64+
65+
- name: Output on Warnings with WORKING_DIRECTORY environment variable
66+
run: diff <(docker run -v $(pwd):$(pwd) -w $(pwd) --rm --env WORKING_DIRECTORY=Warnings action-swiftlint|sort) Warnings/expected.txt
67+
working-directory: ./test
68+
shell: bash

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ jobs:
3131
uses: norio-nomura/[email protected]
3232
env:
3333
DIFF_BASE: ${{ github.base_ref }}
34+
- name: GitHub Action for SwiftLint (Different working directory)
35+
uses: norio-nomura/[email protected]
36+
env:
37+
WORKING_DIRECTORY: Source
3438
```
3539
3640
## Secrets

entrypoint.sh

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

14+
if ! ${WORKING_DIRECTORY+false};
15+
then
16+
cd ${WORKING_DIRECTORY}
17+
fi
18+
1419
if ! ${DIFF_BASE+false};
1520
then
16-
changedFiles=$(git --no-pager diff --name-only FETCH_HEAD $(git merge-base FETCH_HEAD $DIFF_BASE) -- '*.swift')
21+
changedFiles=$(git --no-pager diff --name-only --relative FETCH_HEAD $(git merge-base FETCH_HEAD $DIFF_BASE) -- '*.swift')
1722

1823
if [ -z "$changedFiles" ]
1924
then

0 commit comments

Comments
 (0)