This is a action-mypy repository for reviewdog action with release automation.
Limitation: mypy report multiline error, but now, multiline error may be handled under JSON output is enabled.
Notice:
This action is composition action
.
You accept below one:
- Your workflow manually setup to run
pip install -r requirements.txt
or other setup method. - This action automatic run
pip install mypy
.
inputs:
github_token:
description: 'GITHUB_TOKEN'
required: false
default: '${{ github.token }}'
workdir:
description: |
Working directory of where to run mypy command.
Relative to the root directory.
required: false
default: '.'
target:
description: |
Target files and/or directories of mypy command.
Enumerate in a space-separated list.
Relative to the working directory.
required: false
default: '.'
### Flags for setup/execute ###
execute_command:
description: |
mypy execute command.
Normally it is "mypy", but for example "poetry run mypy"
if you want to run at Poetry without activating the virtual environment.
required: false
default: 'mypy'
setup_command:
description: |
mypy setup command.
Runs when "setup_method" is "install" or required by "adaptive".
If you want to fix the version of mypy, set the value as in the following example.
"pip install mypy==1.6.0"
required: false
default: 'pip install mypy'
setup_method:
description: |
mypy setup method. Select from below.
"nothing" - no setup process.
This option expects the user to prepare the environment
(ex. previous workflow step executed "pip install -r requirements.txt").
If you do not want immediately package installation (e.g., in a poetry environment), must be this.
"adaptive" - Check "execute_command" with "--version" is executable.
If it can be executed, do the same as "nothing", otherwise do the same as "install".
"install" - execute "setup_command".
Incorrect values behave as "adaptive".
required: false
default: 'nothing'
install_types:
description: |
Pre-run mypy and check for missing stubs.
Then perform stub installation.
(ex. ${execute_command} --install-types)
required: false
default: 'true'
### Flags for reviewdog ###
level:
description: 'Report level for reviewdog [info,warning,error]'
required: false
default: 'error'
reporter:
description: 'Reporter of reviewdog command [github-pr-check,github-pr-review].'
required: false
default: 'github-pr-check'
filter_mode:
description: |
Filtering mode for the reviewdog command [added,diff_context,file,nofilter].
Default is added.
required: false
default: 'added'
fail_on_error:
description: |
Exit code for reviewdog when errors are found [true,false]
Default is `false`.
required: false
default: 'false'
reviewdog_flags:
description: 'Additional reviewdog flags'
required: false
default: ''
### Flags for mypy ###
mypy_flags:
description: 'mypy options (default: <none>)'
required: false
default: ''
tool_name:
description: 'Tool name to use for reviewdog reporter'
default: 'mypy'
ignore_note:
description: |
Currently, this option is always true.
Ignore "note: entries" that as reported by mypy.
Old description:
Ignore note entry.
mypy report some error with optional note entry.
This option is workaround.
required: false
default: 'true'
output_json:
description: |
Use the JSON output format available in mypy 1.11 or higher.
This option defaults to false due to version limitations
and because it is still experimental.
Note the mypy version when setting to true.
required: false
default: 'false'
mypy_flags
is used for workflow setting. (eg '--strict --strict-equality').
Currently always suppress note.
name: reviewdog
on: [pull_request]
jobs:
mypy:
name: runner / mypy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: tsuyoshicho/action-mypy@v4
with:
github_token: ${{ secrets.github_token }}
# Change reviewdog reporter if you need [github-pr-check,github-check,github-pr-review].
reporter: github-pr-review
# 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
If you use mypy with Poetry, you can use it with the following settings (poetry shell
do not work in GitHub workflow, see issue 66).
Example setting:
name: reviewdog
on: [pull_request]
jobs:
mypy:
name: runner / mypy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: tsuyoshicho/action-mypy@v4
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
level: warning
workdir: src
execute_command: 'poetry run mypy'
You can set the "-tee" flag in the reviewdog_flags
to log the process.
You can bump version on merging Pull Requests with specific labels (bump:major,bump:minor,bump:patch). Pushing tag manually by yourself also work.
This action updates major/minor release tags on a tag push. e.g. Update v1 and v1.2 tag when released v1.2.3. ref: https://help.github.com/en/articles/about-actions#versioning-your-action
This reviewdog action mypy itself is integrated with reviewdog to run lints which is useful for Docker container based actions.
This repository uses haya14busa/action-depup to update reviewdog version.