Skip to content

Commit af5a955

Browse files
committed
chore: cache asdf and pre-commit downloads
1 parent db1481d commit af5a955

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

.github/workflows/pre-commit.yaml

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,43 @@ jobs:
88
runs-on: ubuntu-latest
99
steps:
1010
- uses: actions/checkout@v3
11-
- uses: asdf-vm/actions/install@v4
12-
- uses: pre-commit/action@v3.0.1
11+
12+
# --- 1. ASDF Caching and Installation ---
13+
- name: 💾 Cache ASDF Tool Versions
14+
uses: actions/cache@v4
15+
id: cache-asdf
16+
with:
17+
# Cache the directory where asdf installs tools
18+
path: ~/.asdf/installs
19+
# Key is based on OS and the content of .tool-versions
20+
key: ${{ runner.os }}-asdf-${{ hashFiles('.tool-versions') }}
21+
restore-keys: |
22+
${{ runner.os }}-asdf-
23+
24+
# Setup asdf itself (it's fast)
25+
- name: ⚙️ Setup ASDF
26+
uses: asdf-vm/actions/setup@v1
27+
28+
# Install runtimes (only downloads if not restored by cache)
29+
- name: 🔨 Install ASDF Runtimes
30+
uses: asdf-vm/actions/install@v4
31+
32+
# --- 2. Pre-commit Caching and Execution ---
33+
- name: 💾 Cache Pre-commit Hooks
34+
uses: actions/cache@v4
35+
with:
36+
# Cache the directory where pre-commit installs its environments
37+
path: ~/.cache/pre-commit
38+
# Key is based on OS and the content of the pre-commit config
39+
key: ${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
40+
restore-keys: |
41+
${{ runner.os }}-pre-commit-
42+
43+
# Run pre-commit (will use cached environments if available)
44+
- name: ✅ Run pre-commit hooks
45+
uses: pre-commit/action@v3.0.1
46+
# It's generally not necessary to pass GITHUB_TOKEN to pre-commit/action
47+
# unless one of your hooks specifically needs it for network access.
48+
# If it's not needed by a hook, you can remove the 'env' block.
1349
env:
1450
GITHUB_TOKEN: ${{ secrets.RELEASE_PLEASE_PAT }}

0 commit comments

Comments
 (0)