Skip to content

Commit

Permalink
Merge pull request #12 from Milly/workdir-change
Browse files Browse the repository at this point in the history
  • Loading branch information
tsuyoshicho authored Jan 18, 2021
2 parents cd272c6 + e96b091 commit 58ce0cd
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 6 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,37 @@ jobs:
level: warning
reviewdog_flags: -filter-mode=file -fail-on-error
workdir: ./testdata/

test-local:
name: runner / mypy (local)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: true
- name: mypy-local
uses: ./
with:
github_token: ${{ secrets.github_token }}
reporter: local
level: error
filter_mode: nofilter
fail_on_error: true
workdir: ./testdata/
- name: mypy-local-error
id: mypy_local_error
uses: ./
with:
github_token: ${{ secrets.github_token }}
reporter: local
level: error
filter_mode: nofilter
fail_on_error: true
workdir: ./testerror/
continue-on-error: true
- name: mypy-local-error-should-failure
if: steps.mypy_local_error.outcome == 'success'
run: |
echo "::error file=.github/workflows/test.yml::mypy-local-error should outcome failure"
false
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,5 @@ $RECYCLE.BIN/
*.lnk

# End of https://www.toptal.com/developers/gitignore/api/windows,linux,macos

.mypy_cache/
Expand Down
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@ inputs:
required: false
default: '${{ github.token }}'
workdir:
description: 'Working directory relative to the root directory.'
description: |
Working directory of where to run mypy command.
Relative to the root directory.
required: false
default: '.'
target:
description: |
Target file or directory of mypy command.
Relative to the working directory.
required: false
default: '.'
### Flags for reviewdog ###
Expand Down Expand Up @@ -83,6 +91,9 @@ jobs:
# Change reporter level if you need.
# GitHub Status Check won't become failure with warning.
level: warning
# Change the current directory to run mypy command.
# mypy command reads setup.cfg or other settings file in this path.
workdir: src
```

## Development
Expand Down Expand Up @@ -110,4 +121,3 @@ This repository uses [haya14busa/action-depup](https://github.com/haya14busa/act
reviewdog version.

[![reviewdog depup demo](https://user-images.githubusercontent.com/3797062/73154254-170e7500-411a-11ea-8211-912e9de7c936.png)](https://github.com/reviewdog/action-template/pull/6)

10 changes: 9 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@ inputs:
required: false
default: '${{ github.token }}'
workdir:
description: 'Working directory relative to the root directory.'
description: |
Working directory of where to run mypy command.
Relative to the root directory.
required: false
default: '.'
target:
description: |
Target file or directory of mypy command.
Relative to the working directory.
required: false
default: '.'
### Flags for reviewdog ###
Expand Down
8 changes: 6 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
set -e

if [ -n "${GITHUB_WORKSPACE}" ] ; then
cd "${GITHUB_WORKSPACE}" || exit
cd "${GITHUB_WORKSPACE}/${INPUT_WORKDIR}" || exit
fi

export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}"

# shellcheck disable=SC2086
mypy --show-column-numbers ${INPUT_MYPY_FLAGS} "${INPUT_WORKDIR}" \
mypy \
--show-column-numbers \
--show-absolute-path \
${INPUT_MYPY_FLAGS} \
"${INPUT_TARGET:-.}" \
| reviewdog \
-efm="%f:%l:%c: %t%*[^:]: %m" \
-name="mypy" \
Expand Down
2 changes: 1 addition & 1 deletion testdata/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ def sub(a: int, b: int) -> int:
return a - b


def div(a: int, b: int) -> int:
def div(a: int, b: int):
return a // b
2 changes: 2 additions & 0 deletions testerror/mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[mypy]
disallow_untyped_defs = True
10 changes: 10 additions & 0 deletions testerror/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
def add(a: int, b: int) -> int:
return a + b


def sub(a: int, b: int) -> int:
return a - b


def div(a: int, b: int):
return a // b

0 comments on commit 58ce0cd

Please sign in to comment.