Skip to content
This repository was archived by the owner on Nov 1, 2023. It is now read-only.

Commit ff1b9fe

Browse files
authored
Improving Rust caching
1 parent 181545d commit ff1b9fe

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ env:
1818
CARGO_TERM_COLOR: always
1919
SCCACHE_DIR: ${{github.workspace}}/sccache/
2020
SCCACHE_CACHE_SIZE: 1G
21-
ACTIONS_CACHE_KEY_DATE: 2023-04-19
21+
ACTIONS_CACHE_KEY_DATE: 2023-06-19
2222
CI: true
2323

2424
jobs:
@@ -59,6 +59,7 @@ jobs:
5959
# it's a release build if version doesn't have a hyphen in it
6060
IS_RELEASE_BUILD=$(if [[ "$VERSION" =~ '-' ]]; then echo 'false'; else echo 'true'; fi)
6161
echo "RELEASE_BUILD=$IS_RELEASE_BUILD" >> $GITHUB_OUTPUT
62+
echo "RUST_VERSION=$RUST_VERSION, RELEASE_BUILD=$RELEASE_BUILD"
6263
id: rust-version
6364
- name: Rust artifact cache
6465
id: cache-agent-artifacts
@@ -71,35 +72,29 @@ jobs:
7172
path: artifacts
7273
key: agent-artifacts|${{ join(matrix.os, ':') }}|${{steps.rust-version.outputs.RUST_VERSION}}|${{ env.ACTIONS_CACHE_KEY_DATE }}|${{ hashFiles('src/agent/**/*') }}|${{hashFiles('src/ci/agent.sh')}}
7374
# note: also including the ACTIONS_CACHE_KEY_DATE to rebuild if the Prereq Cache is invalidated
75+
- name: Rust build cache
76+
id: rust-build-cache
77+
uses: Swatinem/rust-cache@v2
78+
if: steps.cache-agent-artifacts.outputs.cache-hit != 'true'
79+
with:
80+
key: ${{ACTIONS_CACHE_KEY_DATE}} # additional key for cache-busting
81+
workspaces: src/agent
7482
- name: Linux Prereqs
7583
if: runner.os == 'Linux' && steps.cache-agent-artifacts.outputs.cache-hit != 'true'
7684
run: |
7785
sudo apt-get -y update
7886
sudo apt-get -y install libssl-dev libunwind-dev build-essential pkg-config
79-
- name: Rust Prereq Cache
80-
if: steps.cache-agent-artifacts.outputs.cache-hit != 'true'
81-
uses: actions/cache@v3
82-
id: cache-rust-prereqs
83-
with:
84-
path: |
85-
~/.cargo/registry
86-
~/.cargo/git
87-
~/.cargo/bin
88-
key: rust|${{ join(matrix.os, ':') }}|${{steps.rust-version.outputs.RUST_VERSION}}|${{ env.ACTIONS_CACHE_KEY_DATE }}
8987
- name: Install Rust Prereqs
90-
if: steps.cache-rust-prereqs.outputs.cache-hit != 'true' && steps.cache-agent-artifacts.outputs.cache-hit != 'true'
88+
if: steps.rust-build-cache.outputs.cache-hit != 'true' && steps.cache-agent-artifacts.outputs.cache-hit != 'true'
9189
shell: bash
9290
run: src/ci/rust-prereqs.sh
93-
- name: Rust Compile Cache
91+
- name: Rust Sccache
9492
if: steps.cache-agent-artifacts.outputs.cache-hit != 'true'
9593
uses: actions/cache@v3
9694
with:
97-
path: |
98-
sccache
99-
src/agent/target
95+
path: sccache
10096
key: agent|${{ join(matrix.os, ':') }}|${{steps.rust-version.outputs.RUST_VERSION}}|${{ env.ACTIONS_CACHE_KEY_DATE }}|${{ hashFiles('src/agent/Cargo.lock') }}
101-
restore-keys: |
102-
agent|${{ join(matrix.os, ':') }}|${{steps.rust-version.outputs.RUST_VERSION}}|${{ env.ACTIONS_CACHE_KEY_DATE }}|
97+
restore-keys: agent|${{ join(matrix.os, ':') }}|${{steps.rust-version.outputs.RUST_VERSION}}|${{ env.ACTIONS_CACHE_KEY_DATE }}|
10398
- run: src/ci/agent.sh
10499
if: steps.cache-agent-artifacts.outputs.cache-hit != 'true'
105100
shell: bash

0 commit comments

Comments
 (0)