在Docker映像上的预提交钩子中,为python 2.7和3.7运行pylint
我试图使用CircleCI运行一个预提交钩子,该钩子在Python2.7和3.7中都运行pylint在Docker映像上的预提交钩子中,为python 2.7和3.7运行pylint,python,pylint,pre-commit.com,Python,Pylint,Pre Commit.com,我试图使用CircleCI运行一个预提交钩子,该钩子在Python2.7和3.7中都运行pylint .circleci/config.yml为Python 2和Python 3运行预提交: jobs: lint-py2: docker: - image: python:2.7.14 steps: {snip} - run: pre-commit run --all-files {snip} lint-py3: d
.circleci/config.yml
为Python 2和Python 3运行预提交:
jobs:
lint-py2:
docker:
- image: python:2.7.14
steps:
{snip}
- run: pre-commit run --all-files
{snip}
lint-py3:
docker:
- image: python:3.7.3
steps:
{snip}
- run: pre-commit run --all-files
{snip}
预提交(pre-commit)运行pylint:
- repo: https://github.com/pre-commit/mirrors-pylint
rev: v2.3.1 # Which version here?
hooks:
- id: pylint
这里的问题是:Python2.7需要pylint 1.x,Python3.7需要pylint 2.x
如何使Circle CI使用不同版本的pylint运行两个linting作业
我正在考虑几种选择:
- 在预提交配置中添加两次pylint(使用不同的别名),并在作业定义中添加一个或另一个
- 在查看
变量之前,pre-commit似乎会尝试安装依赖项,因此Python 2.7运行无论如何都会尝试安装pylint 2,错误为SKIP
ERROR:找不到满足要求的版本pylint==2.3.1(来自pre-commit dummy package==0.0.0)
- 在查看
- 使用同时具有Python版本和钩子级别的Docker映像
- 这需要建立我自己的Docker形象
- 跳过其中一个皮林作业中的pylint
- 放下2.7或3.7支架
.pre-commit-config.yaml
和一个特殊的.pre-commit-config-py27.yaml
,其中包括python2.7 pylint而不是python3 pylint
在CI中,您将调用python2.7的预提交运行--config.pre-commit-config-py27.yaml--all files--show diff on failure
,以及非py27运行的正常预提交运行--all files--show diff on failure