Skip to content

Commit 00f03e7

Browse files
committed
ci: improve GitHub Actions caching strategy
- Replace manual Go caching with actions/setup-go built-in cache - Switch from actions/cache to Swatinem/rust-cache for Rust dependencies - Enable cache-bin to preserve installed cargo binaries - Add --locked flag to cargo install for deterministic builds - Use shared-key with runner.arch to separate caches for different architectures These changes resolve cache conflict issues and improve workflow efficiency.
1 parent 5026fdd commit 00f03e7

2 files changed

Lines changed: 18 additions & 60 deletions

File tree

.github/workflows/ffmpeg-release.yml

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -44,45 +44,24 @@ jobs:
4444
exit 1
4545
fi
4646
47-
- name: Checkout code
48-
uses: actions/checkout@v6
47+
- uses: actions/checkout@v6
4948

50-
- name: Set up Go
51-
uses: actions/setup-go@v6
49+
- uses: actions/setup-go@v6
5250
with:
5351
go-version: '1.24'
52+
cache: true
5453

55-
- name: Cache Go modules and build cache
56-
uses: actions/cache@v4
57-
with:
58-
path: |
59-
~/go/pkg/mod
60-
~/.cache/go-build
61-
# Workaround for GitHub Actions bug: https://github.com/actions/runner-images/issues/13341
62-
# hashFiles() broken on macOS runners as of 2024-11-23, using static key temporarily
63-
key: ${{ runner.os }}-${{ runner.arch }}-go-${{ matrix.os == 'darwin' && 'static-v1' || hashFiles('go.sum', 'go.mod') }}
64-
restore-keys: |
65-
${{ runner.os }}-${{ runner.arch }}-go-
66-
67-
- name: Install Rust toolchain
68-
uses: dtolnay/rust-toolchain@stable
54+
- uses: dtolnay/rust-toolchain@stable
6955
with:
7056
toolchain: stable
7157

72-
- name: Cache Rust cargo
73-
uses: actions/cache@v4
58+
- uses: Swatinem/rust-cache@v2
7459
with:
75-
path: |
76-
~/.cargo/bin/
77-
~/.cargo/registry/index/
78-
~/.cargo/registry/cache/
79-
~/.cargo/git/db/
80-
key: ${{ runner.os }}-${{ runner.arch }}-cargo-stable
81-
restore-keys: |
82-
${{ runner.os }}-${{ runner.arch }}-cargo-
60+
cache-bin: false
8361

84-
- name: Install cargo-c
85-
run: cargo install cargo-c
62+
- uses: taiki-e/cache-cargo-install-action@v2
63+
with:
64+
tool: cargo-c
8665

8766
- name: Install Linux dependencies
8867
if: matrix.os == 'linux'

.github/workflows/ffmpeg-test.yml

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -35,45 +35,24 @@ jobs:
3535
fail-fast: false
3636

3737
steps:
38-
- name: Checkout code
39-
uses: actions/checkout@v6
38+
- uses: actions/checkout@v6
4039

41-
- name: Set up Go
42-
uses: actions/setup-go@v6
40+
- uses: actions/setup-go@v6
4341
with:
4442
go-version: '1.24'
43+
cache: true
4544

46-
- name: Cache Go modules and build cache
47-
uses: actions/cache@v4
48-
with:
49-
path: |
50-
~/go/pkg/mod
51-
~/.cache/go-build
52-
# Workaround for GitHub Actions bug: https://github.com/actions/runner-images/issues/13341
53-
# hashFiles() broken on macOS runners as of 2024-11-23, using static key temporarily
54-
key: ${{ runner.os }}-${{ runner.arch }}-go-${{ matrix.os == 'darwin' && 'static-v1' || hashFiles('go.sum', 'go.mod') }}
55-
restore-keys: |
56-
${{ runner.os }}-${{ runner.arch }}-go-
57-
58-
- name: Install Rust toolchain
59-
uses: dtolnay/rust-toolchain@stable
45+
- uses: dtolnay/rust-toolchain@stable
6046
with:
6147
toolchain: stable
6248

63-
- name: Cache Rust cargo
64-
uses: actions/cache@v4
49+
- uses: Swatinem/rust-cache@v2
6550
with:
66-
path: |
67-
~/.cargo/bin/
68-
~/.cargo/registry/index/
69-
~/.cargo/registry/cache/
70-
~/.cargo/git/db/
71-
key: ${{ runner.os }}-${{ runner.arch }}-cargo-stable
72-
restore-keys: |
73-
${{ runner.os }}-${{ runner.arch }}-cargo-
51+
cache-bin: false
7452

75-
- name: Install cargo-c
76-
run: cargo install cargo-c
53+
- uses: taiki-e/cache-cargo-install-action@v2
54+
with:
55+
tool: cargo-c
7756

7857
- name: Install Linux dependencies
7958
if: matrix.os == 'linux'

0 commit comments

Comments
 (0)