Skip to content

Commit ada8ed3

Browse files
Cache dependencies for CI jobs (#4181)
Adds a simple cache of the `~/.cargo/registry` directory and Kani's `target` directory to reduce compilation times of our dependencies in CI. This also caches the `~/.rustup` directory to avoid having to re-download toolchains and re-compile the standard library every CI run. Caches are shared between workflows that compile Kani in the same way (e.g. between the `benchcomp-tests` & `perf` jobs since they both compile in release mode). Based on testing on my local fork, this change seems to make a minor, but not insignificant impact on runtimes. Although lost in the noise on longer jobs, `llbc-regression` & `benchcomp-tests` got noticeably faster, as did the compiler benchmarking workflows which have to compile Kani for each commit they are comparing. **Test runs:** General Kani CI workflow: [before](https://github.com/AlexanderPortland/kani/actions/runs/15886762745) | [after](https://github.com/AlexanderPortland/kani/actions/runs/15887740017) Compiler bench workflow: [before](https://github.com/AlexanderPortland/kani/actions/runs/15888031249) | [after](https://github.com/AlexanderPortland/kani/actions/runs/15889545021) Resolves #4153 By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.
1 parent 96eb502 commit ada8ed3

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

.github/workflows/bench-compiler.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,18 @@ jobs:
3737
ref: ${{ env.NEW_REF }}
3838
fetch-depth: 1
3939

40+
- name: Cache Kani build artifacts
41+
uses: Swatinem/rust-cache@v2
42+
with:
43+
cache-on-failure: true
44+
shared-key: "kani-rust-cache-bench"
45+
workspaces: |
46+
new
47+
new/tools/compile-timer
48+
old
49+
old/tools/compile-timer
50+
cache-directories: "~/.rustup"
51+
4052
- name: Set up Kani Dependencies (old variant)
4153
uses: ./old/.github/actions/setup
4254
with:
@@ -101,6 +113,18 @@ jobs:
101113
ref: ${{ env.NEW_REF }}
102114
fetch-depth: 1
103115

116+
- name: Cache Kani build artifacts
117+
uses: Swatinem/rust-cache@v2
118+
with:
119+
cache-on-failure: true
120+
shared-key: "kani-rust-cache-bench"
121+
workspaces: |
122+
new
123+
new/tools/compile-timer
124+
old
125+
old/tools/compile-timer
126+
cache-directories: "~/.rustup"
127+
104128
- name: Set up Kani Dependencies (old variant)
105129
uses: ./old/.github/actions/setup
106130
with:

.github/workflows/kani.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ jobs:
2323
- name: Checkout Kani
2424
uses: actions/checkout@v4
2525

26+
- name: Cache Kani build artifacts
27+
uses: Swatinem/rust-cache@v2
28+
with:
29+
cache-on-failure: true
30+
shared-key: "kani-rust-cache-dev"
31+
cache-directories: "~/.rustup"
32+
2633
- name: Setup Kani Dependencies
2734
uses: ./.github/actions/setup
2835
with:
@@ -43,6 +50,13 @@ jobs:
4350
sudo apt-get install -y python3-pip
4451
pushd tools/benchcomp && pip3 install -r requirements.txt
4552
53+
- name: Cache Kani build artifacts
54+
uses: Swatinem/rust-cache@v2
55+
with:
56+
cache-on-failure: true
57+
shared-key: "kani-rust-cache-release"
58+
cache-directories: "~/.rustup"
59+
4660
- name: Setup Kani Dependencies
4761
uses: ./.github/actions/setup
4862
with:
@@ -60,6 +74,13 @@ jobs:
6074
- name: Checkout Kani
6175
uses: actions/checkout@v4
6276

77+
- name: Cache Kani build artifacts
78+
uses: Swatinem/rust-cache@v2
79+
with:
80+
cache-on-failure: true
81+
shared-key: "kani-rust-cache-release"
82+
cache-directories: "~/.rustup"
83+
6384
- name: Setup Kani Dependencies
6485
uses: ./.github/actions/setup
6586
with:
@@ -76,6 +97,12 @@ jobs:
7697
- name: Checkout Kani
7798
uses: actions/checkout@v4
7899

100+
- name: Cache Kani build artifacts
101+
uses: Swatinem/rust-cache@v2
102+
with:
103+
cache-on-failure: true
104+
cache-directories: "~/.rustup"
105+
79106
- name: Setup Kani Dependencies
80107
uses: ./.github/actions/setup
81108
with:

.github/workflows/verify-std-check.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ jobs:
4141
path: kani
4242
fetch-depth: 0
4343

44+
- name: Cache Kani build artifacts
45+
uses: Swatinem/rust-cache@v2
46+
with:
47+
cache-on-failure: true
48+
workspaces: kani
49+
shared-key: "kani-rust-cache-dev"
50+
cache-directories: "~/.rustup"
51+
4452
- name: Setup Kani Dependencies
4553
uses: ./kani/.github/actions/setup
4654
with:

0 commit comments

Comments
 (0)