Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Gitlab:使用CI检查pylint提交的Python文件_Python_Gitlab_Pylint - Fatal编程技术网

Gitlab:使用CI检查pylint提交的Python文件

Gitlab:使用CI检查pylint提交的Python文件,python,gitlab,pylint,Python,Gitlab,Pylint,如何在Gitlab项目中设置CI,该项目在每个提交的python文件上运行pylint?(也许CI也不是最好的策略,而是我能想到的第一个想法 也许答案已经在某处了,但我找不到 (稍后,我还想检查存储库中已经存在的所有文件,我还想对shell和R脚本使用一些linter。)类似的操作应该可以: stages: - lint pylint: image: "python:latest" stage: lint script: - pip install pylint

如何在Gitlab项目中设置CI,该项目在每个提交的python文件上运行pylint?(也许CI也不是最好的策略,而是我能想到的第一个想法

也许答案已经在某处了,但我找不到


(稍后,我还想检查存储库中已经存在的所有文件,我还想对shell和R脚本使用一些linter。)

类似的操作应该可以:

stages:
  - lint

pylint:
  image: "python:latest"
  stage: lint
  script:
    - pip install pylint
    - pylint src/

这就是你能做的

.gitlab ci.yml

stages:
  - Lint

Lint:
  stage: Lint
  allow_failure: true
  script:
  - chmod +x lint.sh
  - ./lint.sh
lint.sh

#! /bin/sh

pip install pycodestyle
current_branch="$CI_BUILD_REF_NAME" 
echo $current_branch
all_changed_files=$(git diff --name-only origin/master origin/$current_branch)
echo "Checking changes!"
for each_file in $all_changed_files
do
# Checks each newly added file change with pycodestyle
    pycodestyle $each_file
done
echo "Completed checking"

你是不是把
-pylint src/
作为一个特定的命令来引用?这会拉取
没有名为src/
@lcadc17的模块,那么你没有
src/
目录,我想是的,这是我说的。我的意思是,这不是lint检查提交的文件的命令,如果你
pylint
某个文件夹,它会检查所有的*.py文件,无论上次提交时是否更改