Skip to content

Commit 065bd55

Browse files
committed
chore: rework CI cache keys
1 parent 7519be8 commit 065bd55

5 files changed

Lines changed: 93 additions & 32 deletions

File tree

.github/actions/cache-save/action.yml

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: Save Cache
2+
description: "Save caches for the development environment."
23

34
inputs:
45
target-key:
@@ -9,19 +10,51 @@ runs:
910
using: "composite"
1011

1112
steps:
13+
- name: Lookup mise State (Tasks) Cache
14+
id: lookup-mise
15+
uses: actions/cache/restore@v5
16+
with:
17+
path: ~/.local/state/mise
18+
key: mise-state-${{ runner.os }}-${{ hashFiles('**/mise.toml') }}-${{ github.sha }}
19+
lookup-only: true
20+
1221
- name: Save mise State (Tasks)
22+
if: ${{ steps.lookup-mise.outputs.cache-hit != 'true' }}
1323
uses: actions/cache/save@v5
1424
with:
1525
path: ~/.local/state/mise
16-
key: mise-state-${{ runner.os }}-${{ github.sha }}
26+
key: mise-state-${{ runner.os }}-${{ hashFiles('**/mise.toml') }}-${{ github.sha }}
27+
28+
- name: Lookup rustup Cache
29+
id: lookup-rustup
30+
uses: actions/cache/restore@v5
31+
with:
32+
path: ~/.rustup
33+
key: rustup-${{ runner.os }}-${{ hashFiles('**/rust-toolchain.toml') }}
34+
lookup-only: true
1735

1836
- name: Save rustup Cache
37+
if: ${{ steps.lookup-rustup.outputs.cache-hit != 'true' }}
1938
uses: actions/cache/save@v5
2039
with:
2140
path: ~/.rustup
2241
key: rustup-${{ runner.os }}-${{ hashFiles('**/rust-toolchain.toml') }}
2342

43+
- name: Lookup Cargo Cache
44+
id: lookup-cargo
45+
uses: actions/cache/restore@v5
46+
with:
47+
path: |
48+
~/.cargo/registry
49+
~/.cargo/git
50+
~/.cargo/bin
51+
~/.cargo/binstall
52+
~/.cargo/env
53+
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
54+
lookup-only: true
55+
2456
- name: Save Cargo Cache
57+
if: ${{ steps.lookup-cargo.outputs.cache-hit != 'true' }}
2558
uses: actions/cache/save@v5
2659
with:
2760
path: |
@@ -30,7 +63,7 @@ runs:
3063
~/.cargo/bin
3164
~/.cargo/binstall
3265
~/.cargo/env
33-
key: cargo-${{ runner.os }}
66+
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
3467

3568
- name: Save Target Cache
3669
uses: ./.github/actions/cache-save/target
@@ -42,19 +75,38 @@ runs:
4275
run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
4376
shell: bash
4477

78+
- name: Lookup pnpm Cache
79+
id: lookup-pnpm
80+
uses: actions/cache/restore@v5
81+
with:
82+
path: ${{ steps.pnpm-store.outputs.STORE_PATH }}
83+
key: pnpm-${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
84+
lookup-only: true
85+
4586
- name: Save pnpm cache
87+
if: ${{ steps.lookup-pnpm.outputs.cache-hit != 'true' }}
4688
uses: actions/cache/save@v5
4789
with:
48-
path: |
49-
${{ steps.pnpm-store.outputs.STORE_PATH }}
50-
node_modules
90+
path: ${{ steps.pnpm-store.outputs.STORE_PATH }}
5191
key: pnpm-${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
5292

93+
- name: Lookup uv Cache
94+
id: lookup-uv
95+
uses: actions/cache/restore@v5
96+
with:
97+
path: |
98+
~/.cache/uv
99+
~/.local/share/uv
100+
.venv
101+
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
102+
lookup-only: true
103+
53104
- name: Save uv Cache
105+
if: ${{ steps.lookup-uv.outputs.cache-hit != 'true' }}
54106
uses: actions/cache/save@v5
55107
with:
56108
path: |
57109
~/.cache/uv
58110
~/.local/share/uv
59111
.venv
60-
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
112+
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}

.github/actions/cache-save/target/action.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: Save Target Cache
2+
description: "Save cache for the target directory."
23

34
inputs:
45
target-key:
@@ -9,8 +10,17 @@ runs:
910
using: "composite"
1011

1112
steps:
13+
- name: Lookup Target Cache
14+
id: lookup-target
15+
uses: actions/cache/restore@v5
16+
with:
17+
path: target
18+
key: target-${{ runner.os }}-${{ inputs.target-key }}-${{ github.sha }}
19+
lookup-only: true
20+
1221
- name: Save Target Cache
22+
if: ${{ steps.lookup-target.outputs.cache-hit != 'true' }}
1323
uses: actions/cache/save@v5
1424
with:
1525
path: target
16-
key: target-${{ runner.os }}-${{ inputs.target-key }}
26+
key: target-${{ runner.os }}-${{ inputs.target-key }}-${{ github.sha }}

.github/actions/setup/action.yml

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: Set Up Dev Env
2+
description: "Set up development environment by installing dependencies and restoring caches."
23

34
inputs:
45
target-key:
@@ -16,15 +17,18 @@ runs:
1617
uses: actions/cache/restore@v5
1718
with:
1819
path: ~/.local/state/mise
19-
key: mise-state-${{ runner.os }}-${{ github.sha }}
20-
restore-keys: mise-state-${{ runner.os }}-
20+
key: mise-state-${{ runner.os }}-${{ hashFiles('**/mise.toml') }}-${{ github.sha }}
21+
restore-keys: |
22+
mise-state-${{ runner.os }}-${{ hashFiles('**/mise.toml') }}-
23+
mise-state-${{ runner.os }}-
2124
2225
- name: Restore rustup Cache
2326
uses: actions/cache/restore@v5
2427
with:
2528
path: ~/.rustup
2629
key: rustup-${{ runner.os }}-${{ hashFiles('**/rust-toolchain.toml') }}
27-
restore-keys: rustup-${{ runner.os }}-
30+
restore-keys: |
31+
rustup-${{ runner.os }}-
2832
2933
- name: Restore Cargo Cache
3034
uses: actions/cache/restore@v5
@@ -35,15 +39,18 @@ runs:
3539
~/.cargo/bin
3640
~/.cargo/binstall
3741
~/.cargo/env
38-
key: cargo-${{ runner.os }}
39-
restore-keys: cargo-${{ runner.os }}
42+
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
43+
restore-keys: |
44+
cargo-${{ runner.os }}-
4045
4146
- name: Restore Target Cache
4247
uses: actions/cache/restore@v5
4348
with:
4449
path: target
45-
key: target-${{ runner.os }}-${{ inputs.target-key }}
46-
restore-keys: target-${{ runner.os }}-
50+
key: target-${{ runner.os }}-${{ inputs.target-key }}-${{ github.sha }}
51+
restore-keys: |
52+
target-${{ runner.os }}-${{ inputs.target-key }}-
53+
target-${{ runner.os }}-
4754
4855
- name: Get pnpm Store Path
4956
id: pnpm-store
@@ -53,11 +60,10 @@ runs:
5360
- name: Restore pnpm Cache
5461
uses: actions/cache/restore@v5
5562
with:
56-
path: |
57-
${{ steps.pnpm-store.outputs.STORE_PATH }}
58-
node_modules
63+
path: ${{ steps.pnpm-store.outputs.STORE_PATH }}
5964
key: pnpm-${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
60-
restore-keys: pnpm-${{ runner.os }}-
65+
restore-keys: |
66+
pnpm-${{ runner.os }}-
6167
6268
- name: Restore uv Cache
6369
uses: actions/cache/restore@v5
@@ -67,7 +73,8 @@ runs:
6773
~/.local/share/uv
6874
.venv
6975
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
70-
restore-keys: uv-${{ runner.os }}-
76+
restore-keys: |
77+
uv-${{ runner.os }}-
7178
7279
# NOTE: This is workaround for mise action messing up with rustup state:
7380
# - https://github.com/jdx/mise-action/issues/184

.github/workflows/ci-build.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ name: Build
22
on:
33
workflow_dispatch:
44
workflow_call:
5-
inputs:
6-
sha:
7-
required: true
8-
type: string
95

106
jobs:
117
build:
@@ -63,7 +59,7 @@ jobs:
6359
- name: Git Checkout
6460
uses: actions/checkout@v6
6561
with:
66-
ref: ${{ inputs.sha || github.sha }}
62+
ref: ${{ github.sha }}
6763

6864
- name: Set Up Dev Env
6965
uses: ./.github/actions/setup
@@ -84,16 +80,16 @@ jobs:
8480
- name: Save Target Cache
8581
uses: ./.github/actions/cache-save/target
8682
with:
87-
target-key: build-${{ matrix.target }}
83+
target-key: build-${{ matrix.target }}-${{ github.sha }}
8884

8985
- name: Upload CLI Binaries
9086
uses: actions/upload-artifact@v6
9187
with:
9288
path: target/${{ matrix.target }}/release/${{ matrix.cli-name }}
93-
name: ${{ matrix.cli-name }}-${{ matrix.target }}-${{ inputs.sha || github.sha }}
89+
name: ${{ matrix.cli-name }}-${{ matrix.target }}-${{ github.sha }}
9490

9591
- name: Upload LSP Binaries
9692
uses: actions/upload-artifact@v6
9793
with:
9894
path: target/${{ matrix.target }}/release/${{ matrix.lsp-name }}
99-
name: ${{ matrix.lsp-name }}-${{ matrix.target }}-${{ inputs.sha || github.sha }}
95+
name: ${{ matrix.lsp-name }}-${{ matrix.target }}-${{ github.sha }}

.github/workflows/ci.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ jobs:
1313
steps:
1414
- name: Git Checkout
1515
uses: actions/checkout@v6
16-
with:
17-
ref: ${{ inputs.sha || github.sha }}
1816

1917
- name: Set Up Dev Env
2018
uses: ./.github/actions/setup
@@ -62,6 +60,4 @@ jobs:
6260
build:
6361
name: Build
6462
needs: qa
65-
uses: ./.github/workflows/ci-build.yml
66-
with:
67-
sha: ${{ github.event.pull_request.head.sha || github.sha }}
63+
uses: ./.github/workflows/ci-build.yml

0 commit comments

Comments
 (0)