-
Notifications
You must be signed in to change notification settings - Fork 10
65 lines (61 loc) · 2.01 KB
/
Copy pathcache-management.yml
File metadata and controls
65 lines (61 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
name: Cache Management
on:
workflow_call:
inputs:
cache-type:
# Only "dependencies" is used by any caller; the "build" and "container"
# variants were speculative and have never been called. The input is
# kept for backwards-compat but anything other than "dependencies" falls
# through to a sha-based fallback key.
description: 'Type of cache (dependencies)'
required: true
type: string
cache-key-base:
description: 'Base cache key (e.g. test-deps, quality-deps)'
required: true
type: string
python-version:
description: 'Python version for cache key'
required: true
type: string
outputs:
cache-key:
description: 'Generated cache key for use in setup-uv-cached'
value: ${{ jobs.generate-cache-key.outputs.cache-key }}
jobs:
generate-cache-key:
name: Generate Cache Key
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
cache-key: ${{ steps.cache-key.outputs.key }}
steps:
- name: Checkout code
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Generate cache key
id: cache-key
run: |
case "${{ inputs.cache-type }}" in
dependencies)
KEY="${{ inputs.cache-key-base }}-py${{ inputs.python-version }}-${{ hashFiles('.project.yml', 'pyproject.toml', 'uv.lock') }}"
;;
*)
KEY="${{ inputs.cache-key-base }}-${{ github.sha }}"
;;
esac
echo "key=$KEY" >> "$GITHUB_OUTPUT"
echo "Generated cache key: $KEY"
- name: Restore cache
id: cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v5
with:
path: |
~/.cache/uv
.venv
dist/
.pytest_cache
key: ${{ steps.cache-key.outputs.key }}
restore-keys: |
${{ inputs.cache-key-base }}-py${{ inputs.python-version }}-
${{ inputs.cache-key-base }}-