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

Commit

Permalink
Improving Rust caching
Browse files Browse the repository at this point in the history
  • Loading branch information
Porges committed Jun 18, 2023
1 parent 181545d commit ff1b9fe
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ env:
CARGO_TERM_COLOR: always
SCCACHE_DIR: ${{github.workspace}}/sccache/
SCCACHE_CACHE_SIZE: 1G
ACTIONS_CACHE_KEY_DATE: 2023-04-19
ACTIONS_CACHE_KEY_DATE: 2023-06-19
CI: true

jobs:
Expand Down Expand Up @@ -59,6 +59,7 @@ jobs:
# it's a release build if version doesn't have a hyphen in it
IS_RELEASE_BUILD=$(if [[ "$VERSION" =~ '-' ]]; then echo 'false'; else echo 'true'; fi)
echo "RELEASE_BUILD=$IS_RELEASE_BUILD" >> $GITHUB_OUTPUT
echo "RUST_VERSION=$RUST_VERSION, RELEASE_BUILD=$RELEASE_BUILD"
id: rust-version
- name: Rust artifact cache
id: cache-agent-artifacts
Expand All @@ -71,35 +72,29 @@ jobs:
path: artifacts
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')}}
# note: also including the ACTIONS_CACHE_KEY_DATE to rebuild if the Prereq Cache is invalidated
- name: Rust build cache
id: rust-build-cache
uses: Swatinem/rust-cache@v2
if: steps.cache-agent-artifacts.outputs.cache-hit != 'true'
with:
key: ${{ACTIONS_CACHE_KEY_DATE}} # additional key for cache-busting
workspaces: src/agent
- name: Linux Prereqs
if: runner.os == 'Linux' && steps.cache-agent-artifacts.outputs.cache-hit != 'true'
run: |
sudo apt-get -y update
sudo apt-get -y install libssl-dev libunwind-dev build-essential pkg-config
- name: Rust Prereq Cache
if: steps.cache-agent-artifacts.outputs.cache-hit != 'true'
uses: actions/cache@v3
id: cache-rust-prereqs
with:
path: |
~/.cargo/registry
~/.cargo/git
~/.cargo/bin
key: rust|${{ join(matrix.os, ':') }}|${{steps.rust-version.outputs.RUST_VERSION}}|${{ env.ACTIONS_CACHE_KEY_DATE }}
- name: Install Rust Prereqs
if: steps.cache-rust-prereqs.outputs.cache-hit != 'true' && steps.cache-agent-artifacts.outputs.cache-hit != 'true'
if: steps.rust-build-cache.outputs.cache-hit != 'true' && steps.cache-agent-artifacts.outputs.cache-hit != 'true'
shell: bash
run: src/ci/rust-prereqs.sh
- name: Rust Compile Cache
- name: Rust Sccache
if: steps.cache-agent-artifacts.outputs.cache-hit != 'true'
uses: actions/cache@v3
with:
path: |
sccache
src/agent/target
path: sccache
key: agent|${{ join(matrix.os, ':') }}|${{steps.rust-version.outputs.RUST_VERSION}}|${{ env.ACTIONS_CACHE_KEY_DATE }}|${{ hashFiles('src/agent/Cargo.lock') }}
restore-keys: |
agent|${{ join(matrix.os, ':') }}|${{steps.rust-version.outputs.RUST_VERSION}}|${{ env.ACTIONS_CACHE_KEY_DATE }}|
restore-keys: agent|${{ join(matrix.os, ':') }}|${{steps.rust-version.outputs.RUST_VERSION}}|${{ env.ACTIONS_CACHE_KEY_DATE }}|
- run: src/ci/agent.sh
if: steps.cache-agent-artifacts.outputs.cache-hit != 'true'
shell: bash
Expand Down

0 comments on commit ff1b9fe

Please sign in to comment.