gitlab-ci - 在 gitlab-runner 中通过 tox 运行 bandit 行为不正确

标签 gitlab-ci gitlab-ci-runner tox

当我在 gitlab-runner 环境中通过 tox 运行 bandit 时,与通过 tox 运行相比,它的行为有所不同 在我的 Ubuntu 环境中。

  • gitlab-runner 环境 -> 递归分析项目源目录但跳过文件
  • ubuntu环境 -> 递归分析项目源码目录

ubuntu环境中运行时的调用是:tox -e bandit

gitlab-runner环境中运行时的调用是:gitlab-runner exec docker bandit

如果是gitlab-runner环境,相关消息是([source-root-directory]作为src根目录) :

Files skipped (4):
    [source-root-directory]/__init__.py (syntax error while parsing AST from file)
    [source-root-directory]/[some-file].py (syntax error while parsing AST from file)
    [source-root-directory]/[some-other-file].py (syntax error while parsing AST from file)
    ...

tox.ini 的相关摘录为([source-root-directory] 作为 src 根目录):

[tox]
envlist = py27, py34

[testenv:bandit]
deps = {[testenv]deps}
commands = bandit {posargs:-r [source-dir]}

.gitlab-ci.yml 的相关摘录是:

bandit:
  stage: test
  image: python:latest
  script:
  - pip install tox
  - tox -e bandit
  allow_failure: true

最佳答案

您应该检查两个环境中正在运行的工具和 Python 的版本是否相同。 python:latest 目前使用的是 python 3.7,而 Ubuntu 可能运行的是 2.7

关于gitlab-ci - 在 gitlab-runner 中通过 tox 运行 bandit 行为不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49921039/

相关文章:

android - Gradle CI Gitlab CURL文件路径无法加载

git - 如何在 GitLab CI 构建期间从私有(private) GitLab Git 仓库中提取 NPM 依赖项

git - 如何将值传递到Gitlab CI作业

java - 如何使用自己的运行器在 gitlab 作业中将 Postgres 作为服务运行?

python - tox 不读取 setup.cfg

python - 用于测试包的基本毒理学设置

gitlab-ci - 在 Gitlab 上激活 Python 代码的测试覆盖率

GitLab CI 从其他存储库读取文件

python - 如何使用不同的 python 版本获取 tox 来测试 "named"测试环境?

java - Sonarqube 集成到 gitlab.com 上的私有(private)仓库