Skip to content

Commit 9513a3a

Browse files
authored
Cache llvm-cov tool (#34)
Installing `cargo-llvm-cov` each time takes a long time and is wasteful. Cache it the same way we cache `cargo-deny`. | GH Action | Time before | Time after | | ------------- | ------------- | ------------- | | Coverage (PR) | [166 seconds](https://github.com/NethermindEth/rust-template/actions/runs/19867825551) | [38 seconds](https://github.com/NethermindEth/rust-template/actions/runs/20507497399) | | Coverage (Push) | [87 seconds](https://github.com/NethermindEth/rust-template/actions/runs/19242367930) |[ 18 seconds](https://github.com/NethermindEth/rust-template/actions/runs/20507478141) |
1 parent 0e813cc commit 9513a3a

2 files changed

Lines changed: 46 additions & 3 deletions

File tree

.github/workflows/coverage-pr.yml

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,21 @@ jobs:
1919
with:
2020
ref: ${{ github.event.pull_request.head.sha }}
2121

22-
- run: cargo install cargo-llvm-cov
22+
- name: Cache llvm-cov build
23+
id: cache-llvm-cov
24+
uses: actions/cache@v4
25+
continue-on-error: false
26+
with:
27+
path: |
28+
~/.cargo/bin/
29+
~/.cargo/registry/index/
30+
~/.cargo/registry/cache/
31+
~/.cargo/git/db/
32+
target/
33+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
34+
restore-keys: ${{ runner.os }}-cargo-
35+
36+
- run: which cargo-llvm-cov || cargo install cargo-llvm-cov
2337
- run: rustup component add llvm-tools-preview
2438
- run: cargo llvm-cov --workspace --lcov --output-path lcov.info --ignore-filename-regex '^examples/'
2539

@@ -71,9 +85,24 @@ jobs:
7185
with:
7286
ref: ${{ github.event.pull_request.base.sha }}
7387

88+
- name: Cache llvm-cov build
89+
id: cache-llvm-cov
90+
if: ${{ steps.base_art.outputs.found == 'false' }}
91+
uses: actions/cache@v4
92+
continue-on-error: false
93+
with:
94+
path: |
95+
~/.cargo/bin/
96+
~/.cargo/registry/index/
97+
~/.cargo/registry/cache/
98+
~/.cargo/git/db/
99+
target/
100+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
101+
restore-keys: ${{ runner.os }}-cargo-
102+
74103
- name: Install cargo-llvm-cov (fallback path)
75104
if: ${{ steps.base_art.outputs.found == 'false' }}
76-
run: cargo install cargo-llvm-cov
105+
run: which cargo-llvm-cov || cargo install cargo-llvm-cov
77106

78107
- name: Install llvm-tools (fallback path)
79108
if: ${{ steps.base_art.outputs.found == 'false' }}

.github/workflows/coverage.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,21 @@ jobs:
1414
steps:
1515
- uses: actions/checkout@v4
1616

17-
- run: cargo install cargo-llvm-cov
17+
- name: Cache llvm-cov build
18+
id: cache-llvm-cov
19+
uses: actions/cache@v4
20+
continue-on-error: false
21+
with:
22+
path: |
23+
~/.cargo/bin/
24+
~/.cargo/registry/index/
25+
~/.cargo/registry/cache/
26+
~/.cargo/git/db/
27+
target/
28+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
29+
restore-keys: ${{ runner.os }}-cargo-
30+
31+
- run: which cargo-llvm-cov || cargo install cargo-llvm-cov
1832
- run: rustup component add llvm-tools-preview
1933
- run: cargo llvm-cov --workspace --lcov --output-path lcov.info --ignore-filename-regex '^examples/'
2034

0 commit comments

Comments
 (0)