我在Github Actions中有以下步骤:
steps:
- name: Check out repository code
uses: actions/checkout@v2
- name: Cache dependencies
id: pip-cache
uses: actions/cache@v2
with:
path: ~.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
if: steps.pip-cache.outputs.cache-hit != 'true'
run: pip install -r requirements.txt
- name: run mypy
run: mypy .
缓存运作正常,但是当发生缓存命中并尝试运行mypy时,会出现以下错误:
Run mypy .
/home/runner/work/_temp/9887df5b-d5cc-46d7-90e1-b884d8c49272.sh: line 1: mypy: command not found
Error: Process completed with exit code 127.
整个缓存依赖的目的是为了我不必在每次运行工作流时都安装它们。我该如何使用缓存的依赖项?
if: steps.pip-cache.outputs.cache-hit != 'true'
就可以解决问题了。我添加它是因为我看到 pip 的输出说installing dependencies
,但没有仔细看到它说的是installing cached dependencies
... 大家一定要仔细阅读日志。 - rcb