Why is GitHub Action's setup-python action's cache still making pip install all the dependencies?
I have this simple workflow
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
From the logs, it's a cache hit:
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
Yet the Python dependencies are installed
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
....
I expected dependency to be already present and return something like this
Requirement already satisfied: Flask-Cors==3.0.9 in
....
I use this to cache the dependencies, before this step you checkout the repo, load the cache deps, and then install or carry onwards with your actions.
- name: Load Cached Virtualenv
id: cached-pip-wheels
uses: actions/cache@v3
with:
path: ~/.cache
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
Keep in mind that this is using poetry.lock, you would need to replace the file with your requirements.txt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With