From 5e3457deb70c314d9c8edf74c7e6c53dba06e14a Mon Sep 17 00:00:00 2001 From: Milly Date: Sun, 17 Jan 2021 14:28:14 +0900 Subject: [PATCH 1/5] ignore .mypy_cache --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 3634bb7..256bb10 100644 --- a/.gitignore +++ b/.gitignore @@ -72,3 +72,5 @@ $RECYCLE.BIN/ *.lnk # End of https://www.toptal.com/developers/gitignore/api/windows,linux,macos + +.mypy_cache/ From 277ee5e6f19baaab482f455efa398867d84a24d5 Mon Sep 17 00:00:00 2001 From: Milly Date: Sun, 17 Jan 2021 15:06:04 +0900 Subject: [PATCH 2/5] add error tests --- .github/workflows/test.yml | 34 ++++++++++++++++++++++++++++++++++ testdata/test.py | 2 +- testerror/mypy.ini | 2 ++ testerror/test.py | 10 ++++++++++ 4 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 testerror/mypy.ini create mode 100644 testerror/test.py diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 49a0940..f0da489 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/testdata/test.py b/testdata/test.py index 59a2fa7..afd592b 100644 --- a/testdata/test.py +++ b/testdata/test.py @@ -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 diff --git a/testerror/mypy.ini b/testerror/mypy.ini new file mode 100644 index 0000000..82aa7eb --- /dev/null +++ b/testerror/mypy.ini @@ -0,0 +1,2 @@ +[mypy] +disallow_untyped_defs = True diff --git a/testerror/test.py b/testerror/test.py new file mode 100644 index 0000000..afd592b --- /dev/null +++ b/testerror/test.py @@ -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 From be26a1bcf8d01b7e18b98e80e72b316cf6dded57 Mon Sep 17 00:00:00 2001 From: Milly Date: Sun, 17 Jan 2021 15:59:05 +0900 Subject: [PATCH 3/5] fix inputs - add target - change workdir behavior --- action.yml | 4 ++++ entrypoint.sh | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 7f589d3..e9493a7 100644 --- a/action.yml +++ b/action.yml @@ -10,6 +10,10 @@ inputs: description: 'Working directory relative to the root directory.' required: false default: '.' + target: + description: 'Target directory relative to the working directory.' + required: false + default: '.' ### Flags for reviewdog ### level: description: 'Report level for reviewdog [info,warning,error]' diff --git a/entrypoint.sh b/entrypoint.sh index 12b0b4b..c3dc3c0 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -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" \ From 3df12759bd4383322d41f4b668da774b7b570c2d Mon Sep 17 00:00:00 2001 From: Milly Date: Tue, 19 Jan 2021 00:54:33 +0900 Subject: [PATCH 4/5] fix documents - Change `workdir` and `target` description - Add `workdir` usage to sample --- README.md | 13 ++++++++++++- action.yml | 8 ++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index db6f36f..b10d593 100644 --- a/README.md +++ b/README.md @@ -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 ### @@ -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 commmand reads setup.cfg or other settings file in this path. + workdir: src ``` ## Development diff --git a/action.yml b/action.yml index e9493a7..12d89bb 100644 --- a/action.yml +++ b/action.yml @@ -7,11 +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 directory relative to the working directory.' + description: | + Target file or directory of mypy command. + Relative to the working directory. required: false default: '.' ### Flags for reviewdog ### From e96b091219d1d29c2eb899597c8a96a82fba55ec Mon Sep 17 00:00:00 2001 From: Tsuyoshi CHO Date: Tue, 19 Jan 2021 07:56:39 +0900 Subject: [PATCH 5/5] Update README.md --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index b10d593..7e41ef0 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ jobs: # GitHub Status Check won't become failure with warning. level: warning # Change the current directory to run mypy command. - # mypy commmand reads setup.cfg or other settings file in this path. + # mypy command reads setup.cfg or other settings file in this path. workdir: src ``` @@ -121,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) -