Skip to content

Commit ffba612

Browse files
committed
ci: Add rustc hash for caching target dir
1 parent c022b92 commit ffba612

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

ci/actions-templates/linux-builds-template.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,16 @@ jobs:
8282
with:
8383
path: ~/.cargo/git
8484
key: ${{ runner.os }}-cargo-gits-trimmed-${{ hashFiles('**/Cargo.lock') }}
85+
- name: Get rustc commit hash
86+
id: cargo-target-cache
87+
run: |
88+
echo "::set-output name=rust_hash::$(rustc -Vv | grep commit-hash | awk '{print $2}')"
89+
shell: bash
8590
- name: Cache cargo build
8691
uses: actions/cache@v1
8792
with:
8893
path: target
89-
key: ${{ runner.os }}-cargo-build-trimmed-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
94+
key: ${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
9095
- name: Install Rustup using ./rustup-init.sh
9196
run: |
9297
sh ./rustup-init.sh --default-toolchain=none --profile=minimal -y

ci/actions-templates/macos-builds-template.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,16 @@ jobs:
5151
with:
5252
path: ~/.cargo/git
5353
key: ${{ runner.os }}-cargo-gits-trimmed-${{ hashFiles('**/Cargo.lock') }}
54+
- name: Get rustc commit hash
55+
id: cargo-target-cache
56+
run: |
57+
echo "::set-output name=rust_hash::$(rustc -Vv | grep commit-hash | awk '{print $2}')"
58+
shell: bash
5459
- name: Cache cargo build
5560
uses: actions/cache@v1
5661
with:
5762
path: target
58-
key: ${{ runner.os }}-cargo-build-trimmed-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
63+
key: ${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
5964
- name: Install Rustup using ./rustup-init.sh
6065
run: |
6166
sh ./rustup-init.sh --default-toolchain=none --profile=minimal -y

ci/actions-templates/windows-builds-template.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,16 @@ jobs:
8181
with:
8282
path: ~/.cargo/git
8383
key: ${{ runner.os }}-cargo-gits-trimmed-${{ hashFiles('**/Cargo.lock') }}
84+
- name: Get rustc commit hash
85+
id: cargo-target-cache
86+
run: |
87+
echo "::set-output name=rust_hash::$(rustc -Vv | grep commit-hash | awk '{print $2}')"
88+
shell: bash
8489
- name: Cache cargo build
8590
uses: actions/cache@v1
8691
with:
8792
path: target
88-
key: ${{ runner.os }}-cargo-build-static-crt-trimmed-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
93+
key: ${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
8994
- name: Install Rustup using win.rustup.rs
9095
run: |
9196
# Disable the download progress bar which can cause perf issues

0 commit comments

Comments
 (0)