diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml new file mode 100644 index 00000000..d5a0ef5d --- /dev/null +++ b/.github/workflows/pylint.yml @@ -0,0 +1,44 @@ +name: Linter +on: pull_request +jobs: + PyLint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - id: files + uses: jitterbit/get-changed-files@v1 + + - name: Run checks + run: | + for files in ${{ steps.files.outputs.added_modified }}; do + extension="${files##*.}" + if [[ $extension == 'py' ]]; then + changed_files_pylint+=" ${files}" + fi + done + + if [[ ! -z ${changed_files_pylint} ]]; then + sudo apt-get --no-install-recommends install -y build-essential curl python3-dev python3-pip python3-venv + python3 -m venv .env + . .env/bin/activate + pip install -U pip wheel setuptools + pip install pylint-json2html + pip install $(egrep "pylint.*" ./cvat/requirements/development.txt) + mkdir -p pylint_report + + echo "Pylint version: "`pylint --version | head -1` + echo "The files will be checked: "`echo ${changed_files_pylint}` + pylint ${changed_files_pylint} --output-format=json > ./pylint_report/pylint_checks.json || exit_code=`echo $?` || true + pylint-json2html -o ./pylint_report/pylint_checks.html ./pylint_report/pylint_checks.json + deactivate + exit ${exit_code} + else + echo "No files with the \"py\" extension found" + fi + + - name: Upload artifacts + if: failure() + uses: actions/upload-artifact@v2 + with: + name: pylint_report + path: pylint_report