这个项目提供了pylint格式化程序,可以很好地与GitLab CI集成。
pylint-gitlab的Python项目详细描述
派林吉特实验室
这个项目提供了pylint格式化程序,可以很好地与GitLab CI集成。在
Formatter | Description |
---|---|
^{ | Maps the linting result in Code Climate format |
^{ | Creates a table in an HTML page with linting results and links to source code. |
使用
安装包pylint-gitlab
:
pip install pylint-gitlab
pylint
包是pylint-gitlab
的依赖项,因此它将自动安装。在
现在可以通过运行pylint
命令并使用参数--output-format
设置自定义输出格式来使用格式化程序。在
GitLab CI集成
以下是.gitlab-ci.yml
文件的最低版本:
pylint:stage:testimage:python:3.7-slimbefore_script:-mkdir -p public/badges public/lint-echo undefined > public/badges/$CI_JOB_NAME.score-pip install pylint_gitlabscript:-pylint --exit-zero --output-format=text $(find -type f -name "*.py" ! -path "**/.venv/**") | tee /tmp/pylint.txt-sed -n 's/^Your code has been rated at \([-0-9.]*\)\/.*/\1/p' /tmp/pylint.txt > public/badges/$CI_JOB_NAME.score-pylint --exit-zero --output-format=pylint_gitlab.GitlabCodeClimateReporter $(find -type f -name "*.py" ! -path "**/.venv/**") > codeclimate.json-pylint --exit-zero --output-format=pylint_gitlab.GitlabPagesHtmlReporter $(find -type f -name "*.py" ! -path "**/.venv/**") > public/lint/index.htmlafter_script:-anybadge --overwrite --label $CI_JOB_NAME --value=$(cat public/badges/$CI_JOB_NAME.score) --file=public/badges/$CI_JOB_NAME.svg 4=red 6=orange 8=yellow 10=green-|echo "Your score is: $(cat public/badges/$CI_JOB_NAME.score)"artifacts:paths:-publicreports:codequality:codeclimate.jsonwhen:alwayspages:stage:deployimage:alpine:latestscript:-echoartifacts:paths:-publiconly:refs:-master
然后,您可以使用发布的徽章对结果进行linting处理。在
[![pylint](https://<USER/GROUP_NAME>.gitlab.io/<PROJECT_PATH>/badges/pylint.svg)](https://<USER/GROUP_NAME>.gitlab.io/<PROJECT_PATH>/lint/)
- 项目
标签: