Skip to content

Commit

Permalink
Feature/extra options and log (#3)
Browse files Browse the repository at this point in the history
* more logs 
* extra options for all libs
  • Loading branch information
ricardochaves authored Dec 28, 2019
1 parent fd57586 commit d0a3d57
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 18 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,28 @@ steps:
use-black: false
use-mypy: false
use-isort: false
extra-pylint-options: ""
extra-pycodestyle-options: ""
extra-flake8-options: ""
extra-black-options: ""
extra-mypy-options: ""
extra-isort-options: ""
```
Command build logic list:
```bash
pylint $(extra-pylint-options) $(python-root-list)

pycodestyle $(extra-pycodestyle-options) $(python-root-list)

flake8 $(extra-flake8-options) $(python-root-list)

black --check $(extra-black-options) $(python-root-list)

mypy $(extra-mypy-options) $(python-root-list)"

isort -rc $(extra-isort-options) $(python-root-list) -c --diff
```

## License
Expand Down
32 changes: 32 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,32 @@ inputs:
description: "Use isort"
required: false
default: true
extra-pylint-options:
description: "Extra options: pylint $(extra-pylint-options) $(python-root-list)"
required: false
default: ""
extra-pycodestyle-options:
description: "Extra options: pycodestyle $(extra-pycodestyle-options) $(python-root-list)"
required: false
default: ""
extra-flake8-options:
description: "Extra options: flake8 $(extra-flake8-options) $(python-root-list)"
required: false
default: ""
extra-black-options:
description: "Extra options: black --check $(extra-black-options) $(python-root-list)"
required: false
default: ""
extra-mypy-options:
description: "Extra options: mypy $(extra-mypy-options) $(python-root-list)"
required: false
default: ""
extra-isort-options:
description: "Extra options: isort -rc $(extra-isort-options) $(python-root-list) -c --diff "
required: false
default: ""


runs:
using: "docker"
image: "Dockerfile"
Expand All @@ -40,3 +66,9 @@ runs:
- ${{ inputs.use-black }}
- ${{ inputs.use-mypy }}
- ${{ inputs.use-isort }}
- ${{ inputs.extra-pylint-options }}
- ${{ inputs.extra-pycodestyle-options }}
- ${{ inputs.extra-flake8-options }}
- ${{ inputs.extra-black-options }}
- ${{ inputs.extra-mypy-options }}
- ${{ inputs.extra-isort-options }}
64 changes: 46 additions & 18 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,32 @@
#!/bin/sh -l

# Parameters
#
# $1 - python-root-list
# $2 - use-pylint
# $3 - use-pycodestyle
# $4 - use-flake8
# $5 - use-black
# $6 - use-mypy
# $7 - use-isort
# $8 - extra-pylint-options
# $9 - extra-pycodestyle-options
# ${10} - extra-flake8-options
# ${11} - extra-black-options
# ${12} - extra-mypy-options
# ${13} - extra-isort-options

if [ "$2" = true ] ; then

pylint $1
echo Running: pylint $8 $1

pylint $8 $1
exit_code=$?

if [ "$exit_code" = "0" ]; then
echo ::log-command ::"Pylint ok"
echo "Pylint ok"
else
echo ::error :: "Pylint error"
echo "Pylint error"
exit $exit_code
fi

Expand All @@ -17,69 +35,79 @@ fi

if [ "$3" = true ] ; then

pycodestyle $1
echo Running: pycodestyle $9 $1

pycodestyle $9 $1
exit_code=$?

if [ "$exit_code" = "0" ]; then
echo ::log-command ::"pycodestyle ok"
echo "pycodestyle ok"
else
echo ::error :: "pycodestyle error"
echo "pycodestyle error"
exit $exit_code
fi

fi

if [ "$4" = true ] ; then

flake8 $1
echo Running: flake8 ${10} $1

flake8 ${10} $1
exit_code=$?

if [ "$exit_code" = "0" ]; then
echo ::log-command ::"Flake8 ok"
echo "Flake8 ok"
else
echo ::error :: "Flake8 error"
echo "Flake8 error"
exit $exit_code
fi

fi

if [ "$5" = true ] ; then

black --check $1
echo Running: black --check ${11} $1

black --check ${11} $1
exit_code=$?

if [ "$exit_code" = "0" ]; then
echo ::log-command ::"Black ok"
echo "Black ok"
else
echo ::error :: "Black error"
echo "Black error"
exit $exit_code
fi

fi

if [ "$6" = true ] ; then

mypy $1
echo Running: mypy ${12} $1

mypy ${12} $1
exit_code=$?

if [ "$exit_code" = "0" ]; then
echo ::log-command ::"mypy ok"
echo "mypy ok"
else
echo ::error :: "mypy error"
echo "mypy error"
exit $exit_code
fi

fi

if [ "$7" = true ] ; then

isort -rc $1 -c --diff
echo Running: isort -rc ${13} $1 -c --diff

isort -rc ${13} $1 -c --diff
exit_code=$?

if [ "$exit_code" = "0" ]; then
echo ::log-command ::"isort ok"
echo "isort ok"
else
echo ::error :: "isort error"
echo "isort error"
exit $exit_code
fi

Expand Down

0 comments on commit d0a3d57

Please sign in to comment.