Skip to content

Commit

Permalink
update to composition
Browse files Browse the repository at this point in the history
  • Loading branch information
tsuyoshicho committed Feb 6, 2021
1 parent 64dba89 commit 51863c3
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 70 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/depup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: haya14busa/action-depup@v1
id: depup
with:
file: Dockerfile
file: action.yml
version_name: REVIEWDOG_VERSION
repo: reviewdog/reviewdog

Expand Down
13 changes: 0 additions & 13 deletions .github/workflows/dockerimage.yml

This file was deleted.

22 changes: 0 additions & 22 deletions Dockerfile

This file was deleted.

13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@

This is a action-mypy repository for [reviewdog](https://github.com/reviewdog/reviewdog) action with release automation.

Notice:
This action is `composition action`. It need `npm ci`.

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`.

## Input

```yaml
Expand Down Expand Up @@ -62,6 +70,9 @@ inputs:
description: 'mypy options (default: <none>)'
required: false
default: ''
tool_name:
description: 'Tool name to use for reviewdog reporter'
default: 'mypy'
```
### Input note
Expand All @@ -83,7 +94,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: tsuyoshicho/action-mypy@v2
- uses: tsuyoshicho/action-mypy@v3
with:
github_token: ${{ secrets.github_token }}
# Change reviewdog reporter if you need [github-pr-check,github-check,github-pr-review].
Expand Down
24 changes: 21 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,28 @@ inputs:
description: 'mypy options (default: <none>)'
required: false
default: ''
tool_name:
description: 'Tool name to use for reviewdog reporter'
default: 'mypy'
runs:
using: 'docker'
image: 'Dockerfile'

using: 'composite'
steps:
- run: $GITHUB_ACTION_PATH/script.sh
shell: sh
env:
REVIEWDOG_VERSION: v0.11.0
# INPUT_<VARIABLE_NAME> is not available in Composite run steps
# https://github.community/t/input-variable-name-is-not-available-in-composite-run-steps/127611
INPUT_GITHUB_TOKEN: ${{ inputs.github_token }}
INPUT_WORKDIR: ${{ inputs.workdir }}
INPUT_TARGET: ${{ inputs.target }}
INPUT_LEVEL: ${{ inputs.level }}
INPUT_REPORTER: ${{ inputs.reporter }}
INPUT_FILTER_MODE: ${{ inputs.filter_mode }}
INPUT_FAIL_ON_ERROR: ${{ inputs.fail_on_error }}
INPUT_REVIEWDOG_FLAGS: ${{ inputs.reviewdog_flags }}
INPUT_MYPY_FLAGS: ${{ inputs.mypy_flags }}
INPUT_TOOL_NAME: ${{ inputs.tool_name }}
# Ref: https://haya14busa.github.io/github-action-brandings/
branding:
icon: 'check'
Expand Down
30 changes: 0 additions & 30 deletions entrypoint.sh

This file was deleted.

49 changes: 49 additions & 0 deletions script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/sh

# shellcheck disable=SC2086,SC2089,SC2090

cd "${GITHUB_WORKSPACE}/${INPUT_WORKDIR}" || exit

TEMP_PATH="$(mktemp -d)"
PATH="${TEMP_PATH}:$PATH"

echo '::group::🐶 Installing reviewdog ... https://github.com/reviewdog/reviewdog'
curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b "${TEMP_PATH}" "${REVIEWDOG_VERSION}" 2>&1
echo '::endgroup::'

echo '::group:: Installing mypy ... https://github.com/python/mypy'
if type "mypy" > /dev/null 2>&1 ; then
echo 'already installed'
else
echo 'install mypy'
pip install mypy
fi

if type "mypy" > /dev/null 2>&1 ; then
mypy --version
else
echo 'This repository was not configured for mypy, process done.'
exit 1
fi
echo '::endgroup::'

export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}"


echo '::group:: Running mypy with reviewdog 🐶 ...'
# shellcheck disable=SC2086
mypy \
--show-column-numbers \
--show-absolute-path \
${INPUT_MYPY_FLAGS} \
"${INPUT_TARGET:-.}" \
| reviewdog \
-efm="%f:%l:%c: %t%*[^:]: %m" \
-name="mypy" \
-reporter="${INPUT_REPORTER:-github-pr-check}" \
-filter-mode="${INPUT_FILTER_MODE}" \
-fail-on-error="${INPUT_FAIL_ON_ERROR}" \
-level="${INPUT_LEVEL}" \
${INPUT_REVIEWDOG_FLAGS}
echo '::endgroup::'

0 comments on commit 51863c3

Please sign in to comment.