首页 > 解决方案 > 使用 aws 为 gitlab 创建 CI 管道时出错

问题描述

我正在使用下面的代码在 gitlab 中创建一个带有 aws 的 ci 管道来为 ci 工作。我只需要为它执行 3 个阶段,并且我只发布了代码以进行覆盖,因为我收到错误初始化

coverage:
stage: test
tags:
    - aws-runner
only: 
    - Feature/CI            
image: python:3.7-slim
coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/'
script:
    - pip install coverage moto mock pytest
    - MIN_COVERAGE=85
    - pip3 install --upgrade pip setuptools wheel
    - pip3 install -r requirements.txt
    - coverage run --omit 'utility/*' -m pytest tests/
    - coverage report -m
    - coverage html
    - COVERAGE=$(coverage report -m | grep -i "TOTAL" | awk '{print $4}' | sed 's/%//')
    - if [ "$COVERAGE" -lt "$MIN_COVERAGE" ]; then exit 1; else exit 0; fi
artifacts:
    expire_in: 7 days
    paths:
       - htmlcov/

    

这是上面代码的错误

 $ coverage run --omit 'utility/*' -m pytest tests/
 ============================= test session starts==============================
 platform linux -- Python 3.7.11, pytest-6.2.4, py-1.10.0, pluggy-0.13.1 rootdir: /builds/test-backend 
 collected 0 items
 ============================ no tests ran in 0.00s =============================
 ERROR: file or directory not found: tests/
 Coverage.py warning: No data was collected. (no-data-collected)
 Cleaning up file based variables
 00:02
 ERROR: Job failed: exit code 1

因为我是新手,有什么建议吗?我该如何解决这个问题?

标签: amazon-web-servicesgitlabgitlab-ci

解决方案


我认为您需要检查测试目录是否存在,它应该有 .py 文件


推荐阅读