Skip to content

Commit 7d65512

Browse files
authored
Merge pull request #2482 from lzutao/precise-cache-target
ci: fallback to PR target branch caching
2 parents 1de7057 + 6e05bd2 commit 7d65512

12 files changed

+34
-12
lines changed

.github/workflows/centos-fmt-clippy-on-all.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,17 @@ jobs:
4545
~/.cargo/registry
4646
~/.cargo/git
4747
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
48+
- name: Get rustc commit hash
49+
id: cargo-target-cache
50+
run: |
51+
echo "::set-output name=rust_hash::$(rustc -Vv | grep commit-hash | awk '{print $2}')"
52+
shell: bash
4853
- name: Cache cargo build
4954
uses: actions/cache@v2
5055
with:
5156
path: target
52-
key: ${{ runner.os }}-cargo-build-clippy-beta-${{ hashFiles('**/Cargo.lock') }}
57+
key: ${{ github.base_ref }}-${{ github.head_ref }}-${{ runner.os }}-cargo-clippy-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
58+
restore-keys: ${{ github.base_ref }}-${{ runner.os }}-cargo-clippy-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
5359
- name: Install Rustup using ./rustup-init.sh
5460
run: |
5561
sh ./rustup-init.sh --default-toolchain=none --profile=minimal -y

.github/workflows/linux-builds-on-master.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ jobs:
7171
uses: actions/cache@v2
7272
with:
7373
path: target
74-
key: ${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
74+
key: ${{ github.base_ref }}-${{ github.head_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
75+
restore-keys: ${{ github.base_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
7576
- name: Install Rustup using ./rustup-init.sh
7677
run: |
7778
sh ./rustup-init.sh --default-toolchain=none --profile=minimal -y

.github/workflows/linux-builds-on-pr.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ jobs:
6464
uses: actions/cache@v2
6565
with:
6666
path: target
67-
key: ${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
67+
key: ${{ github.base_ref }}-${{ github.head_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
68+
restore-keys: ${{ github.base_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
6869
- name: Install Rustup using ./rustup-init.sh
6970
run: |
7071
sh ./rustup-init.sh --default-toolchain=none --profile=minimal -y

.github/workflows/linux-builds-on-stable.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ jobs:
9292
uses: actions/cache@v2
9393
with:
9494
path: target
95-
key: ${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
95+
key: ${{ github.base_ref }}-${{ github.head_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
96+
restore-keys: ${{ github.base_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
9697
- name: Install Rustup using ./rustup-init.sh
9798
run: |
9899
sh ./rustup-init.sh --default-toolchain=none --profile=minimal -y

.github/workflows/macos-builds-on-all.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ jobs:
5757
uses: actions/cache@v2
5858
with:
5959
path: target
60-
key: ${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
60+
key: ${{ github.base_ref }}-${{ github.head_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
61+
restore-keys: ${{ github.base_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
6162
- name: Install Rustup using ./rustup-init.sh
6263
run: |
6364
sh ./rustup-init.sh --default-toolchain=none --profile=minimal -y

.github/workflows/windows-builds-on-master.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ jobs:
7979
uses: actions/cache@v2
8080
with:
8181
path: target
82-
key: ${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
82+
key: ${{ github.base_ref }}-${{ github.head_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
83+
restore-keys: ${{ github.base_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
8384
- name: Install Rustup using win.rustup.rs
8485
run: |
8586
# Disable the download progress bar which can cause perf issues

.github/workflows/windows-builds-on-pr.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ jobs:
7676
uses: actions/cache@v2
7777
with:
7878
path: target
79-
key: ${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
79+
key: ${{ github.base_ref }}-${{ github.head_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
80+
restore-keys: ${{ github.base_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
8081
- name: Install Rustup using win.rustup.rs
8182
run: |
8283
# Disable the download progress bar which can cause perf issues

.github/workflows/windows-builds-on-stable.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ jobs:
7979
uses: actions/cache@v2
8080
with:
8181
path: target
82-
key: ${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
82+
key: ${{ github.base_ref }}-${{ github.head_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
83+
restore-keys: ${{ github.base_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
8384
- name: Install Rustup using win.rustup.rs
8485
run: |
8586
# Disable the download progress bar which can cause perf issues

ci/actions-templates/centos-fmt-clippy-template.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,17 @@ jobs:
4545
~/.cargo/registry
4646
~/.cargo/git
4747
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
48+
- name: Get rustc commit hash
49+
id: cargo-target-cache
50+
run: |
51+
echo "::set-output name=rust_hash::$(rustc -Vv | grep commit-hash | awk '{print $2}')"
52+
shell: bash
4853
- name: Cache cargo build
4954
uses: actions/cache@v2
5055
with:
5156
path: target
52-
key: ${{ runner.os }}-cargo-build-clippy-beta-${{ hashFiles('**/Cargo.lock') }}
57+
key: ${{ github.base_ref }}-${{ github.head_ref }}-${{ runner.os }}-cargo-clippy-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
58+
restore-keys: ${{ github.base_ref }}-${{ runner.os }}-cargo-clippy-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
5359
- name: Install Rustup using ./rustup-init.sh
5460
run: |
5561
sh ./rustup-init.sh --default-toolchain=none --profile=minimal -y

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ jobs:
100100
uses: actions/cache@v2
101101
with:
102102
path: target
103-
key: ${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
103+
key: ${{ github.base_ref }}-${{ github.head_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
104+
restore-keys: ${{ github.base_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
104105
- name: Install Rustup using ./rustup-init.sh
105106
run: |
106107
sh ./rustup-init.sh --default-toolchain=none --profile=minimal -y

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ jobs:
5757
uses: actions/cache@v2
5858
with:
5959
path: target
60-
key: ${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
60+
key: ${{ github.base_ref }}-${{ github.head_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
61+
restore-keys: ${{ github.base_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
6162
- name: Install Rustup using ./rustup-init.sh
6263
run: |
6364
sh ./rustup-init.sh --default-toolchain=none --profile=minimal -y

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ jobs:
8787
uses: actions/cache@v2
8888
with:
8989
path: target
90-
key: ${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
90+
key: ${{ github.base_ref }}-${{ github.head_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
91+
restore-keys: ${{ github.base_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
9192
- name: Install Rustup using win.rustup.rs
9293
run: |
9394
# Disable the download progress bar which can cause perf issues

0 commit comments

Comments
 (0)