首页 > 解决方案 > CircleCI 和 Config.yml 的问题没有找到 requirements.txt 和 dev_requirements.txt

问题描述

我正在尝试为一个小项目设置 circleci,并且我有以下配置 yml 文件:

version: 2.1

orbs:
  python: circleci/python@0.2.1

jobs:
  build-and-test:
    docker:
      - image: circleci/python:3.7.9
    executor: python/default
    steps:
      - checkout
      - python/load-cache
      - run:
          command: pip install -r src/requirements.txt
          name: Install Deps
      - python/save-cache
      - run:
          command: ./manage.py test
          name: Test

workflows:
  main:
    jobs:
      - build-and-test

在我的 github 项目中,我的requirements.txtdev_requirements.txt文件位于一个名为src.

在仪表板上,我收到以下错误:

error computing cache key: template: cacheKey:1:7: executing "cacheKey" at <checksum "requirements.txt">: error calling checksum: open /home/circleci/project/requirements.txt: no such file or directory


我该如何解决这个问题?

谢谢

标签: pythonpython-3.xpipcontinuous-integrationcircleci

解决方案


这个 Python orb 有点过时了,但是对于旧的和当前的 orb,答案是一样的。指定需求文件的位置,这是 Circle 创建校验和所需要的,用于确定需求是否已更新(是否需要 d/l 新的或使用缓存)。这两个命令代替python/load-cacheand python/save-cache

 - restore_cache:
      keys:
        - v1-dependencies-{{ checksum "YOURPATH/requirements.txt" }}
        # fallback to using the latest cache if no exact match is found
        - v1-dependencies-

  - save_cache:
      paths:
        - ./venv
      key: v1-dependencies-{{ checksum "YOURPATH/requirements.txt" }}

推荐阅读