Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch caching to use re-actors/cache-python-deps #93

Merged
merged 5 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/actions/cache-keys/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---

name: placeholder
description: placeholder

outputs:
cache-key-for-dep-files:
description: >-
A cache key string derived from the dependency declaration files.
value: ${{ steps.calc-cache-key-files.outputs.files-hash-key }}

runs:
using: composite
steps:
- name: >-
Calculate dependency files' combined hash value
for use in the cache key
id: calc-cache-key-files
run: |
from os import environ
from pathlib import Path

FILE_APPEND_MODE = 'a'

files_derived_hash = '${{
hashFiles(
'tox.ini',
'pyproject.toml',
'.pre-commit-config.yaml',
'pytest.ini',
'requirements/**',
'setup.cfg'
)
}}'

print(f'Computed file-derived hash is {files_derived_hash}.')

with Path(environ['GITHUB_OUTPUT']).open(
mode=FILE_APPEND_MODE,
) as outputs_file:
print(
f'files-hash-key={files_derived_hash}',
file=outputs_file,
)
shell: python

...
39 changes: 32 additions & 7 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,16 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_LATEST }}
cache: pip
cache-dependency-path:
requirements/*.txt
- name: >-
Calculate dependency files' combined hash value
for use in the cache key
id: calc-cache-key-files
uses: ./.github/actions/cache-keys
- name: Set up pip cache
uses: re-actors/cache-python-deps@release/v1
with:
cache-key-for-dependency-files: >-
${{ steps.calc-cache-key-files.outputs.cache-key-for-dep-files }}
- name: Install core libraries for build
run: python -Im pip install build
- name: Build sdists and pure-python wheel
Expand Down Expand Up @@ -215,6 +222,8 @@ jobs:
timeout-minutes: 5
continue-on-error: ${{ matrix.experimental }}
steps:
- name: Checkout project
uses: actions/checkout@v4
- name: Retrieve the project source from an sdist inside the GHA artifact
uses: re-actors/checkout-python-sdist@release/v2
with:
Expand All @@ -235,8 +244,16 @@ jobs:
with:
python-version: ${{ matrix.pyver }}
allow-prereleases: true
cache: pip
cache-dependency-path: requirements/*.txt
- name: >-
Calculate dependency files' combined hash value
for use in the cache key
id: calc-cache-key-files
uses: ./.github/actions/cache-keys
- name: Set up pip cache
uses: re-actors/cache-python-deps@release/v1
with:
cache-key-for-dependency-files: >-
${{ steps.calc-cache-key-files.outputs.cache-key-for-dep-files }}
- name: Install dependencies
uses: py-actions/py-dependency-install@v4
with:
Expand Down Expand Up @@ -389,8 +406,16 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: 3.13
cache: pip
cache-dependency-path: requirements/*.txt
- name: >-
Calculate dependency files' combined hash value
for use in the cache key
id: calc-cache-key-files
uses: ./.github/actions/cache-keys
- name: Set up pip cache
uses: re-actors/cache-python-deps@release/v1
with:
cache-key-for-dependency-files: >-
${{ steps.calc-cache-key-files.outputs.cache-key-for-dep-files }}
- name: Install dependencies
uses: py-actions/py-dependency-install@v4
with:
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/reusable-linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,16 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_LATEST }}
cache: pip
cache-dependency-path: requirements/*.txt
- name: >-
Calculate dependency files' combined hash value
for use in the cache key
id: calc-cache-key-files
uses: ./.github/actions/cache-keys
- name: Set up pip cache
uses: re-actors/cache-python-deps@release/v1
with:
cache-key-for-dependency-files: >-
${{ steps.calc-cache-key-files.outputs.cache-key-for-dep-files }}
- name: Cache pre-commit.com virtualenvs
uses: actions/cache@v4
with:
Expand Down
7 changes: 7 additions & 0 deletions CHANGES/93.contrib.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
GitHub Actions CI/CD is now configured to manage caching pip-ecosystem
dependencies using `re-actors/cache-python-deps`_ -- an action by
:user:`webknjaz` that takes into account ABI stability and the exact
version of Python runtime.

.. _`re-actors/cache-python-deps`:
https://github.com/marketplace/actions/cache-python-deps
Loading