-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathaction.yml
105 lines (88 loc) · 2.78 KB
/
action.yml
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
---
name: Setup uv and Handle Its Cache
description: Downloads and installs the Python uv packaging manager and handles its cache.
author: Hynek Schlawack
branding:
icon: package
color: purple
inputs:
cache-suffix:
description: A suffix to append to the cache key.
required: false
default: ""
cache-date-suffix:
description: Arguments to pass to the date command to generate a cache key suffix.
required: false
default: "+%V"
cache-dependency-path:
description: Hash this file and use it as part of the cache key.
required: false
default: "pyproject.toml"
use-cache-if:
description: Save the cache.
required: false
default: "true"
uv-cache-path:
description: Where to put uv's cache directory.
required: false
default: NOT_SET
runs:
using: composite
steps:
- name: Install uv on Linux or macOS
run: |
if [ "${{ inputs.uv-cache-path }}" = "NOT_SET" ]; then
UV_CACHE_DIR="/tmp/scu-uv-cache"
else
UV_CACHE_DIR="${{ inputs.uv-cache-path }}"
fi
echo "UV_CACHE_DIR=$UV_CACHE_DIR" >>$GITHUB_ENV
curl \
--location \
--silent \
--show-error \
--fail \
--proto '=https' \
--tlsv1.2 \
https://astral.sh/uv/install.sh | bash
shell: bash
if: runner.os != 'Windows'
- name: Install uv on Windows
run: |
if ("${{ inputs.uv-cache-path }}" -eq "NOT_SET") {
$UV_CACHE_DIR = "D:\a\_temp\scu-uv-cache"
} else {
$UV_CACHE_DIR = "${{ inputs.uv-cache-path }}"
}
echo "UV_CACHE_DIR=$UV_CACHE_DIR" >> $env:GITHUB_ENV
irm https://astral.sh/uv/install.ps1 | iex
shell: pwsh
if: runner.os == 'Windows'
- name: Check cache dir
shell: bash
run: echo "uv cache dir is $(uv cache dir)"
- name: Compute cache key suffix by hashing ${{ inputs.cache-dependency-path }}
run: >
echo
"HASH_CACHE_SUFFIX=-${{ hashFiles(inputs.cache-dependency-path) }}"
>>$GITHUB_ENV
shell: bash
if: inputs.cache-dependency-path != '' && inputs.use-cache-if == 'true'
- name: Compute date-based cache key suffix
run: >
echo
"DATE_CACHE_SUFFIX=-$(date ${{ inputs.cache-date-suffix }})"
>>$GITHUB_ENV
shell: bash
if: inputs.cache-date-suffix != '' && inputs.use-cache-if == 'true'
- name: Load uv cache
uses: actions/cache@v4
if: inputs.use-cache-if == 'true'
with:
path: ${{ env.UV_CACHE_DIR }}
key: uv-${{ runner.os }}-${{ github.workflow }}-${{ github.job }}${{ inputs.cache-suffix }}${{ env.HASH_CACHE_SUFFIX }}${{ env.DATE_CACHE_SUFFIX }}
- name: Schedule cache pruning
uses: gacts/run-and-post-run@4683764dd706df847f57b9bed39d08164bcd2690
if: inputs.use-cache-if == 'true'
with:
post: uv cache prune --ci