|
1 |
| -# cache-python-deps |
2 |
| -A GitHub Action maintaining caches dependent on Python runtime and ABI stability |
| 1 | +# `re-actors/cache-python-deps@release/v1` — ABI-sensitive cache management |
| 2 | + |
| 3 | +A GitHub Action maintaining caches dependent on Python runtime and ABI |
| 4 | +stability. |
| 5 | + |
| 6 | +The action is meant to be run instead of using the `cache` input of |
| 7 | +`actions/setup-python`. |
| 8 | + |
| 9 | + |
| 10 | +## Usage |
| 11 | + |
| 12 | +To use the action add the following step to your workflow file (e.g. |
| 13 | +`.github/workflows/ci-cd.yml`) |
| 14 | + |
| 15 | +```yaml |
| 16 | +- name: Restore pip cache |
| 17 | + uses: re-actors/cache-python-deps@release/v1 |
| 18 | + with: |
| 19 | + cache-key-for-dependency-files: >- |
| 20 | + ${{ |
| 21 | + hashFiles( |
| 22 | + '.pre-commit-config.yaml', |
| 23 | + 'requirements/**', |
| 24 | + 'tox.ini', |
| 25 | + 'tox.toml', |
| 26 | + 'pyproject.toml' |
| 27 | + ) |
| 28 | + }} |
| 29 | +``` |
| 30 | +
|
| 31 | +
|
| 32 | +## Options |
| 33 | +
|
| 34 | +### `cache-directory-lookup-command` |
| 35 | + |
| 36 | +A command that prints cache directory to standard output. Defaults to |
| 37 | +pip cache lookup. |
| 38 | +**(DEFAULT: `python -Im pip cache dir`)** |
| 39 | + |
| 40 | +### `cache-key-for-dependency-files` |
| 41 | + |
| 42 | +A cache key string derived from the dependency declaration files. Should |
| 43 | +be pre-computed by the caller. Something like `hashFiles()` should do. |
| 44 | +**(REQUIRED)** |
| 45 | + |
| 46 | + |
| 47 | +## Gotchas |
| 48 | + |
| 49 | +The `cache-key-for-dependency-files` must be computed before calling the |
| 50 | +action. It would typically depend on the contents of files containing |
| 51 | +dependency declarations. This means that the dependency files should be |
| 52 | +on disk before that (they can be retrieved by calling one of |
| 53 | +[`re-actors/checkout-python-sdist`] or `actions/checkout`, for example). |
| 54 | + |
| 55 | +In case the `cache-key-for-dependency-files` computation is done in an |
| 56 | +early job in the workflow and the value is just being passed around, this |
| 57 | +action does not necessarily have to be called after checking out the |
| 58 | +repository. It should however still be invoked after `actions/setup-python` |
| 59 | +so that the correct cache entry is picked up. |
| 60 | + |
| 61 | + |
| 62 | +## Any users? |
| 63 | + |
| 64 | +At the moment, it is used by [@aio-libs], [@CherryPy], with more to come. |
| 65 | + |
| 66 | +[`re-actors/checkout-python-sdist`]: |
| 67 | +https://github.com/marketplace/actions/checkout-python-sdist |
| 68 | +[@aio-libs]: https://github.com/aio-libs |
| 69 | +[@CherryPy]: https://github.com/cherrypy |
0 commit comments