为什么Github Action的setup-python action的缓存仍然需要pip安装所有依赖项?
我拥有以下简单工作流:
我拥有以下简单工作流:
name: Python Testing
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
permissions:
contents: read
jobs:
coverage_check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.6"
cache: 'pip' # caching pip dependencies
- run: pip install -r requirements.txt --use-deprecated=legacy-resolver
根据日志,这是一次缓存命中
Successfully set up CPython (3.6.15)
/opt/hostedtoolcache/Python/3.6.15/x64/bin/pip cache dir
/home/runner/.cache/pip
Received 123461741 of 123461741 (100.0%), 111.2 MBs/sec
Cache Size: ~118 MB (123461741 B)
/usr/bin/tar --use-compress-program unzstd -xf /home/runner/work/_temp/a5d8f986-ce6b-424f-8de9-c082916cdb2f/cache.tzst -P -C /home/runner/work/backend/backend
Cache restored successfully
Cache restored from key: setup-python-Linux-20.04-Ubuntu-python-3.6.15-pip-d0b220da2d89ebae7a0978e97e9d1ce87061e5e2e0f5d3d242c2770b7f983de6
然而Python依赖已安装。
Collecting Flask-Cors==3.0.9
Using cached Flask_Cors-3.0.9-py2.py3-none-any.whl (14 kB)
Collecting Flask-GraphQL==2.0.1
....
我希望依赖项已经存在并返回类似于以下内容的结果
Requirement already satisfied: Flask-Cors==3.0.9 in
....
actions/setup-python
自带的开箱即用缓存由于某些原因无法用于我正在使用的 Python 版本。最终,我使用了actions/cache
以及 Python 的venv
模块的输出目录和 requirements.txt,如此解决了这个问题。 - Absactions/setup-python
缓存解决方案有任何想法。如果没有,我将把这个解决方法标记为已接受的答案。 - Absactions/setup-python
缓存不支持哪些Python版本? - web