From 51579272193dc7af46bf5b1a740445d557f2b2b7 Mon Sep 17 00:00:00 2001
From: Yuki Okushi <huyuumi.dev@gmail.com>
Date: Thu, 28 May 2020 02:19:58 +0900
Subject: [PATCH] Update `actions/cache` to v2

---
 .github/workflows/linux.yml   | 22 ++++++++++------------
 .github/workflows/macos.yml   | 20 +++++++++-----------
 .github/workflows/windows.yml | 20 +++++++++-----------
 3 files changed, 28 insertions(+), 34 deletions(-)

diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml
index a95eac7ee..e3450c898 100644
--- a/.github/workflows/linux.yml
+++ b/.github/workflows/linux.yml
@@ -35,18 +35,16 @@ jobs:
         uses: actions-rs/cargo@v1
         with:
           command: generate-lockfile
-      - name: Cache cargo registry
-        uses: actions/cache@v1
+      - name: Cache cargo dirs
+        uses: actions/cache@v2
         with:
-          path: ~/.cargo/registry
-          key: ${{ matrix.version }}-x86_64-unknown-linux-gnu-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
-      - name: Cache cargo index
-        uses: actions/cache@v1
-        with:
-          path: ~/.cargo/git
-          key: ${{ matrix.version }}-x86_64-unknown-linux-gnu-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
+          path:
+            ~/.cargo/registry
+            ~/.cargo/git
+            ~/.cargo/bin
+          key: ${{ matrix.version }}-x86_64-unknown-linux-gnu-cargo-trimmed-${{ hashFiles('**/Cargo.lock') }}
       - name: Cache cargo build
-        uses: actions/cache@v1
+        uses: actions/cache@v2
         with:
           path: target
           key: ${{ matrix.version }}-x86_64-unknown-linux-gnu-cargo-build-trimmed-${{ hashFiles('**/Cargo.lock') }}
@@ -67,7 +65,7 @@ jobs:
       - name: Generate coverage file
         if: matrix.version == 'stable' && (github.ref == 'master' || github.event_name == 'pull_request')
         run: |
-          cargo install cargo-tarpaulin
+          which cargo-tarpaulin || cargo install cargo-tarpaulin
           cargo tarpaulin --out Xml --workspace --all-features
 
       - name: Upload to Codecov
@@ -78,5 +76,5 @@ jobs:
 
       - name: Clear the cargo caches
         run: |
-          cargo install cargo-cache --no-default-features --features ci-autoclean
+          which cargo-cache || cargo install cargo-cache --no-default-features --features ci-autoclean
           cargo-cache
diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml
index b729708bc..8295f20ae 100644
--- a/.github/workflows/macos.yml
+++ b/.github/workflows/macos.yml
@@ -28,18 +28,16 @@ jobs:
         uses: actions-rs/cargo@v1
         with:
           command: generate-lockfile
-      - name: Cache cargo registry
-        uses: actions/cache@v1
+      - name: Cache cargo dirs
+        uses: actions/cache@v2
         with:
-          path: ~/.cargo/registry
-          key: ${{ matrix.version }}-x86_64-apple-darwin-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
-      - name: Cache cargo index
-        uses: actions/cache@v1
-        with:
-          path: ~/.cargo/git
-          key: ${{ matrix.version }}-x86_64-apple-darwin-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
+          path:
+            ~/.cargo/registry
+            ~/.cargo/git
+            ~/.cargo/bin
+          key: ${{ matrix.version }}-x86_64-apple-darwin-gnu-cargo-trimmed-${{ hashFiles('**/Cargo.lock') }}
       - name: Cache cargo build
-        uses: actions/cache@v1
+        uses: actions/cache@v2
         with:
           path: target
           key: ${{ matrix.version }}-x86_64-apple-darwin-cargo-build-trimmed-${{ hashFiles('**/Cargo.lock') }}
@@ -62,5 +60,5 @@ jobs:
 
       - name: Clear the cargo caches
         run: |
-          cargo install cargo-cache --no-default-features --features ci-autoclean
+          which cargo-cache || cargo install cargo-cache --no-default-features --features ci-autoclean
           cargo-cache
diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml
index 0fb4065c0..1dcd6f962 100644
--- a/.github/workflows/windows.yml
+++ b/.github/workflows/windows.yml
@@ -32,18 +32,16 @@ jobs:
         uses: actions-rs/cargo@v1
         with:
           command: generate-lockfile
-      - name: Cache cargo registry
-        uses: actions/cache@v1
+      - name: Cache cargo dirs
+        uses: actions/cache@v2
         with:
-          path: ~/.cargo/registry
-          key: ${{ matrix.version }}-${{ matrix.target }}-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
-      - name: Cache cargo index
-        uses: actions/cache@v1
-        with:
-          path: ~/.cargo/git
-          key: ${{ matrix.version }}-${{ matrix.target }}-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
+          path:
+            ~/.cargo/registry
+            ~/.cargo/git
+            ~/.cargo/bin
+          key: ${{ matrix.version }}-${{ matrix.target }}-cargo-trimmed-${{ hashFiles('**/Cargo.lock') }}
       - name: Cache cargo build
-        uses: actions/cache@v1
+        uses: actions/cache@v2
         with:
           path: target
           key: ${{ matrix.version }}-${{ matrix.target }}-cargo-build-trimmed-${{ hashFiles('**/Cargo.lock') }}
@@ -66,5 +64,5 @@ jobs:
 
       - name: Clear the cargo caches
         run: |
-          cargo install cargo-cache --no-default-features --features ci-autoclean
+          which cargo-cache || cargo install cargo-cache --no-default-features --features ci-autoclean
           cargo-cache