如何在Gitlab项目中设置CI,该项目在每个提交的python文件上运行pylint? (也许CI也不是最好的策略,而是我能想到的第一个想法。
也许答案已经存在,但我找不到它。
(稍后,我还要检查存储库中已有的所有文件,并且我还想对shell和R脚本使用一些连接。)
答案 0 :(得分:1)
这就是你可以做的
.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"
答案 1 :(得分:0)
这样的事情应该有效:
stages:
- lint
pylint:
image: "python:latest"
stage: lint
script:
- pip install pylint
- pylint src/