From d0a3d5762aa67d39858adc6e3b95d719d9db9553 Mon Sep 17 00:00:00 2001 From: Ricardo Baltazar Chaves Date: Sat, 28 Dec 2019 14:46:38 -0300 Subject: [PATCH] Feature/extra options and log (#3) * more logs * extra options for all libs --- README.md | 22 ++++++++++++++++++ action.yml | 32 ++++++++++++++++++++++++++ entrypoint.sh | 64 ++++++++++++++++++++++++++++++++++++--------------- 3 files changed, 100 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 6c5d43c..03a5479 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/action.yml b/action.yml index c849def..b0b9b15 100644 --- a/action.yml +++ b/action.yml @@ -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" @@ -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 }} \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh index f6b0bf2..d27939b 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -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 @@ -17,13 +35,15 @@ 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 @@ -31,13 +51,15 @@ 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 @@ -45,13 +67,15 @@ 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 @@ -59,13 +83,15 @@ 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 @@ -73,13 +99,15 @@ 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