Browse Source

feat(ci): simplify cache (#3448)

Lucas Fernandes Nogueira 3 years ago
parent
commit
49955ea1aa

+ 32 - 25
.github/workflows/artifacts-updater.yml

@@ -16,6 +16,11 @@ on:
       - 'tooling/bundler/**'
       - 'examples/updater/**'
 
+env:
+  RUST_BACKTRACE: 1
+  CARGO_INCREMENTAL: 0 # This is set to 0 by the https://github.com/Swatinem/rust-cache
+  CARGO_PROFILE_DEV_DEBUG: 0 # This would add unnecessary bloat to the target folder, decreasing cache efficiency.
+
 jobs:
   build-artifacs:
     runs-on: ${{ matrix.platform }}
@@ -46,49 +51,51 @@ jobs:
         if: matrix.platform == 'windows-latest'
         run: echo "CURRENT_DATE=$(Get-Date -Format "yyyy-MM-dd")" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
 
-      - name: Cache cargo registry
-        uses: actions/cache@v2.1.4
-        with:
-          path: ~/.cargo/registry
-          # Add date to the cache to keep it up to date
-          key: ${{ matrix.platform }}-stable-cargo-registry-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
-          # Restore from outdated cache for speed
-          restore-keys: |
-            ${{ matrix.platform }}-stable-cargo-registry-${{ hashFiles('**/Cargo.toml') }}
-            ${{ matrix.platform }}-stable-cargo-registry-
-
-      - name: Cache cargo index
-        uses: actions/cache@v2.1.4
+      - name: Cache cargo state
+        uses: actions/cache@v2
+        env:
+          cache-name: cargo-state
         with:
-          path: ~/.cargo/git
-          # Add date to the cache to keep it up to date
-          key: ${{ matrix.platform }}-stable-cargo-index-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
-          # Restore from outdated cache for speed
+          path: |
+            ~/.cargo/registry
+            ~/.cargo/git
+            ~/.cargo/bin
+          key: ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
           restore-keys: |
-            ${{ matrix.platform }}-stable-cargo-index-${{ hashFiles('**/Cargo.toml') }}
-            ${{ matrix.platform }}-stable-cargo-index-
+            ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-
+            ${{ matrix.platform }}-stable-${{ env.cache-name }}-
+            ${{ matrix.platform }}-stable-
+            ${{ matrix.platform }}-
 
       - name: Cache core cargo target
         uses: actions/cache@v2
+        env:
+          cache-name: cargo-core
         with:
           path: target
           # Add date to the cache to keep it up to date
-          key: ${{ matrix.platform }}-stable-cargo-core-${{ hashFiles('core/**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
+          key: ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('core/**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
           # Restore from outdated cache for speed
           restore-keys: |
-            ${{ matrix.platform }}-stable-cargo-core-${{ hashFiles('core/**/Cargo.toml') }}
-            ${{ matrix.platform }}-stable-cargo-core-
+            ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('core/**/Cargo.toml') }}
+            ${{ matrix.platform }}-stable-${{ env.cache-name }}-
+            ${{ matrix.platform }}-stable-
+            ${{ matrix.platform }}-
 
       - name: Cache CLI cargo target
         uses: actions/cache@v2
+        env:
+          cache-name: cargo-cli
         with:
           path: tooling/cli/target
           # Add date to the cache to keep it up to date
-          key: ${{ matrix.platform }}-stable-cargo-cli-${{ hashFiles('tooling/cli/Cargo.lock') }}-${{ env.CURRENT_DATE }}
+          key: ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('tooling/cli/Cargo.lock') }}-${{ env.CURRENT_DATE }}
           # Restore from outdated cache for speed
           restore-keys: |
-            ${{ matrix.platform }}-stable-cargo-cli-${{ hashFiles('tooling/cli/Cargo.lock') }}
-            ${{ matrix.platform }}-stable-cargo-cli-
+            ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('tooling/cli/Cargo.lock') }}
+            ${{ matrix.platform }}-stable-${{ env.cache-name }}-
+            ${{ matrix.platform }}-stable-
+            ${{ matrix.platform }}-
 
       - name: build and install cli.rs
         run: cargo install --path tooling/cli

+ 40 - 33
.github/workflows/bench.yml

@@ -7,12 +7,17 @@ on:
       - next
   workflow_dispatch:
 
+env:
+  RUST_BACKTRACE: 1
+  CARGO_INCREMENTAL: 0 # This is set to 0 by the https://github.com/Swatinem/rust-cache
+  CARGO_PROFILE_DEV_DEBUG: 0 # This would add unnecessary bloat to the target folder, decreasing cache efficiency.
+
 jobs:
   bench:
     strategy:
       fail-fast: false
       matrix:
-        rust_version: [stable]
+        rust: [nightly]
         platform:
           - { target: x86_64-unknown-linux-gnu, os: ubuntu-latest }
 
@@ -20,10 +25,10 @@ jobs:
 
     steps:
       - uses: actions/checkout@v2
-      - name: install nightly
+      - name: install ${{ matrix.rust }}
         uses: actions-rs/toolchain@v1
         with:
-          toolchain: nightly
+          toolchain: ${{ matrix.rust }}
           override: true
           components: rust-src
           target: ${{ matrix.platform.target }}
@@ -31,7 +36,7 @@ jobs:
       - name: setup python
         uses: actions/setup-python@v2
         with:
-          python-version: "3.x"
+          python-version: '3.x'
           architecture: x64
 
       - name: install depedencies
@@ -46,57 +51,59 @@ jobs:
       - name: Get current date
         run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
 
-      - name: Cache cargo registry
-        uses: actions/cache@v2.1.4
-        with:
-          path: ~/.cargo/registry
-          # Add date to the cache to keep it up to date
-          key: ${{ matrix.platform }}-nightly-cargo-registry-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
-          # Restore from outdated cache for speed
-          restore-keys: |
-            ${{ matrix.platform }}-nightly-cargo-registry-${{ hashFiles('**/Cargo.toml') }}
-            ${{ matrix.platform }}-nightly-cargo-registry-
-
-      - name: Cache cargo index
-        uses: actions/cache@v2.1.4
+      - name: Cache cargo state
+        uses: actions/cache@v2
+        env:
+          cache-name: cargo-state
         with:
-          path: ~/.cargo/git
-          # Add date to the cache to keep it up to date
-          key: ${{ matrix.platform }}-nightly-cargo-index-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
-          # Restore from outdated cache for speed
+          path: |
+            ~/.cargo/registry
+            ~/.cargo/git
+            ~/.cargo/bin
+          key: ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
           restore-keys: |
-            ${{ matrix.platform }}-nightly-cargo-index-${{ hashFiles('**/Cargo.toml') }}
-            ${{ matrix.platform }}-nightly-cargo-index-
+            ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-
+            ${{ matrix.platform }}-stable-${{ env.cache-name }}-
+            ${{ matrix.platform }}-stable-
+            ${{ matrix.platform }}-
 
       - name: Cache core cargo target
         uses: actions/cache@v2
+        env:
+          cache-name: cargo-core
         with:
           path: target
           # Add date to the cache to keep it up to date
-          key: ${{ matrix.platform }}-nightly-cargo-core-${{ hashFiles('core/**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
+          key: ${{ matrix.platform }}-${{ matrix.rust }}-${{ env.cache-name }}-${{ hashFiles('core/**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
           # Restore from outdated cache for speed
           restore-keys: |
-            ${{ matrix.platform }}-nightly-cargo-core-${{ hashFiles('core/**/Cargo.toml') }}
-            ${{ matrix.platform }}-nightly-cargo-core-
+            ${{ matrix.platform }}-${{ matrix.rust }}-${{ env.cache-name }}-${{ hashFiles('core/**/Cargo.toml') }}
+            ${{ matrix.platform }}-${{ matrix.rust }}-${{ env.cache-name }}-
+            ${{ matrix.platform }}-${{ matrix.rust }}-
+            ${{ matrix.platform }}-
 
       - name: cache cargo `tooling/bench/tests` target
         uses: actions/cache@v2
+        env:
+          cache-name: cargo-benches
         with:
           path: tooling/bench/tests/target
           # Add date to the cache to keep it up to date
-          key: ${{ matrix.platform }}-nightly-cargo-benches-${{ hashFiles('tooling/bench/tests/Cargo.lock') }}-${{ env.CURRENT_DATE }}
+          key: ${{ matrix.platform }}-${{ matrix.rust }}-${{ env.cache-name }}-${{ hashFiles('tooling/bench/tests/Cargo.lock') }}-${{ env.CURRENT_DATE }}
           # Restore from outdated cache for speed
           restore-keys: |
-            ${{ matrix.platform }}-nightly-cargo-benches-${{ hashFiles('tooling/bench/tests/Cargo.lock') }}
-            ${{ matrix.platform }}-nightly-cargo-benches-
- 
+            ${{ matrix.platform }}-${{ matrix.rust }}-${{ env.cache-name }}-${{ hashFiles('tooling/bench/tests/Cargo.lock') }}
+            ${{ matrix.platform }}-${{ matrix.rust }}-${{ env.cache-name }}-
+            ${{ matrix.platform }}-${{ matrix.rust }}-
+            ${{ matrix.platform }}-
+
       - name: run benchmarks
         run: |
-          cargo +nightly build --release -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort --target ${{ matrix.platform.target }} --manifest-path tooling/bench/tests/Cargo.toml
+          cargo build --release -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort --target ${{ matrix.platform.target }} --manifest-path tooling/bench/tests/Cargo.toml
           xvfb-run --auto-servernum cargo run --manifest-path tooling/bench/Cargo.toml --bin run_benchmark
 
       - name: clone benchmarks_results
-        if:  github.repository == 'tauri-apps/tauri' && github.ref == 'refs/heads/dev'
+        if: github.repository == 'tauri-apps/tauri' && github.ref == 'refs/heads/dev'
         uses: actions/checkout@v2
         with:
           token: ${{ secrets.BENCH_PAT }}
@@ -104,7 +111,7 @@ jobs:
           repository: tauri-apps/benchmark_results
 
       - name: push new benchmarks
-        if:  github.repository == 'tauri-apps/tauri' && github.ref == 'refs/heads/dev'
+        if: github.repository == 'tauri-apps/tauri' && github.ref == 'refs/heads/dev'
         run: |
           cargo run --manifest-path tooling/bench/Cargo.toml --bin build_benchmark_jsons
           cd gh-pages

+ 26 - 23
.github/workflows/lint-fmt-cli.yml

@@ -14,13 +14,18 @@ on:
       - '.github/workflows/lint-fmt-cli.yml'
       - 'tooling/cli/**'
 
+env:
+  RUST_BACKTRACE: 1
+  CARGO_INCREMENTAL: 0 # This is set to 0 by the https://github.com/Swatinem/rust-cache
+  CARGO_PROFILE_DEV_DEBUG: 0 # This would add unnecessary bloat to the target folder, decreasing cache efficiency.
+
 jobs:
   fmt_check:
     runs-on: ubuntu-latest
 
     steps:
       - uses: actions/checkout@v2
-      
+
       - uses: actions-rs/toolchain@v1
         with:
           profile: minimal
@@ -49,38 +54,36 @@ jobs:
       - name: Get current date
         run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
 
-      - name: Cache cargo registry
-        uses: actions/cache@v2.1.4
-        with:
-          path: ~/.cargo/registry
-          # Add date to the cache to keep it up to date
-          key: ubuntu-latest-stable-cargo-registry-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
-          # Restore from outdated cache for speed
-          restore-keys: |
-            ubuntu-latest-stable-cargo-registry-${{ hashFiles('**/Cargo.toml') }}
-            ubuntu-latest-stable-cargo-registry-
-
-      - name: Cache cargo index
-        uses: actions/cache@v2.1.4
+      - name: Cache cargo state
+        uses: actions/cache@v2
+        env:
+          cache-name: cargo-state
         with:
-          path: ~/.cargo/git
-          # Add date to the cache to keep it up to date
-          key: ubuntu-latest-stable-cargo-index-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
-          # Restore from outdated cache for speed
+          path: |
+            ~/.cargo/registry
+            ~/.cargo/git
+            ~/.cargo/bin
+          key: ubuntu-latest-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
           restore-keys: |
-            ubuntu-latest-stable-cargo-index-${{ hashFiles('**/Cargo.toml') }}
-            ubuntu-latest-stable-cargo-index-
+            ubuntu-latest-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-
+            ubuntu-latest-stable-${{ env.cache-name }}-
+            ubuntu-latest-stable-
+            ubuntu-latest-
 
       - name: Cache CLI cargo target
         uses: actions/cache@v2
+        env:
+          cache-name: cargo-cli
         with:
           path: tooling/cli/target
           # Add date to the cache to keep it up to date
-          key: ubuntu-latest-stable-cargo-cli-${{ hashFiles('tooling/cli/Cargo.lock') }}-${{ env.CURRENT_DATE }}
+          key: ubuntu-latest-stable-${{ env.cache-name }}-${{ hashFiles('tooling/cli/Cargo.lock') }}-${{ env.CURRENT_DATE }}
           # Restore from outdated cache for speed
           restore-keys: |
-            ubuntu-latest-stable-cargo-cli-${{ hashFiles('tooling/cli/Cargo.lock') }}
-            ubuntu-latest-stable-cargo-cli-
+            ubuntu-latest-stable-${{ env.cache-name }}-${{ hashFiles('tooling/cli/Cargo.lock') }}
+            ubuntu-latest-stable-${{ env.cache-name }}-
+            ubuntu-latest-stable-
+            ubuntu-latest-
 
       - uses: actions-rs/clippy-check@v1
         with:

+ 30 - 24
.github/workflows/lint-fmt-core.yml

@@ -15,13 +15,18 @@ on:
       - 'core/**'
       - 'examples/**'
 
+env:
+  RUST_BACKTRACE: 1
+  CARGO_INCREMENTAL: 0 # This is set to 0 by the https://github.com/Swatinem/rust-cache
+  CARGO_PROFILE_DEV_DEBUG: 0 # This would add unnecessary bloat to the target folder, decreasing cache efficiency.
+
 jobs:
   fmt_check:
     runs-on: ubuntu-latest
 
     steps:
       - uses: actions/checkout@v2
-      
+
       - uses: actions-rs/toolchain@v1
         with:
           profile: minimal
@@ -40,7 +45,10 @@ jobs:
       matrix:
         clippy:
           - { args: '', key: 'empty' }
-          - { args: '--features compression,wry,isolation,custom-protocol,api-all,cli,updater,system-tray', key: 'all' }
+          - {
+              args: '--features compression,wry,isolation,custom-protocol,api-all,cli,updater,system-tray',
+              key: 'all'
+            }
           - { args: '--no-default-features', key: 'no-default' }
           - { args: '--features custom-protocol', key: 'custom-protocol' }
           - { args: '--features api-all', key: 'api-all' }
@@ -67,38 +75,36 @@ jobs:
         if: matrix.platform == 'windows-latest'
         run: echo "CURRENT_DATE=$(Get-Date -Format "yyyy-MM-dd")" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
 
-      - name: Cache cargo registry
-        uses: actions/cache@v2.1.4
-        with:
-          path: ~/.cargo/registry
-          # Add date to the cache to keep it up to date
-          key: ubuntu-latest-stable-cargo-registry-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
-          # Restore from outdated cache for speed
-          restore-keys: |
-            ubuntu-latest-stable-cargo-registry-${{ hashFiles('**/Cargo.toml') }}
-            ubuntu-latest-stable-cargo-registry-
-
-      - name: Cache cargo index
-        uses: actions/cache@v2.1.4
+      - name: Cache cargo state
+        uses: actions/cache@v2
+        env:
+          cache-name: cargo-state
         with:
-          path: ~/.cargo/git
-          # Add date to the cache to keep it up to date
-          key: ubuntu-latest-stable-cargo-index-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
-          # Restore from outdated cache for speed
+          path: |
+            ~/.cargo/registry
+            ~/.cargo/git
+            ~/.cargo/bin
+          key: ubuntu-latest-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
           restore-keys: |
-            ubuntu-latest-stable-cargo-index-${{ hashFiles('**/Cargo.toml') }}
-            ubuntu-latest-stable-cargo-index-
+            ubuntu-latest-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-
+            ubuntu-latest-stable-${{ env.cache-name }}-
+            ubuntu-latest-stable-
+            ubuntu-latest-
 
       - name: Cache core cargo target
         uses: actions/cache@v2
+        env:
+          cache-name: cargo-core
         with:
           path: target
           # Add date to the cache to keep it up to date
-          key: ubuntu-latest-stable-cargo-core-${{ hashFiles('core/**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
+          key: ubuntu-latest-stable-${{ env.cache-name }}-${{ hashFiles('core/**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
           # Restore from outdated cache for speed
           restore-keys: |
-            ubuntu-latest-stable-cargo-core-${{ hashFiles('core/**/Cargo.toml') }}
-            ubuntu-latest-stable-cargo-core-
+            ubuntu-latest-stable-${{ env.cache-name }}-${{ hashFiles('core/**/Cargo.toml') }}
+            ubuntu-latest-stable-${{ env.cache-name }}-
+            ubuntu-latest-stable-
+            ubuntu-latest-
 
       - uses: actions-rs/clippy-check@v1
         with:

+ 43 - 44
.github/workflows/test-bundler.yml

@@ -13,8 +13,11 @@ on:
     paths:
       - '.github/workflows/test-bundler.yml'
       - 'tooling/bundler/**'
+
 env:
   RUST_BACKTRACE: 1
+  CARGO_INCREMENTAL: 0 # This is set to 0 by the https://github.com/Swatinem/rust-cache
+  CARGO_PROFILE_DEV_DEBUG: 0 # This would add unnecessary bloat to the target folder, decreasing cache efficiency.
 
 jobs:
   build-tauri-bundler:
@@ -40,38 +43,36 @@ jobs:
         if: matrix.platform == 'windows-latest'
         run: echo "CURRENT_DATE=$(Get-Date -Format "yyyy-MM-dd")" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
 
-      - name: Cache cargo registry
-        uses: actions/cache@v2.1.4
-        with:
-          path: ~/.cargo/registry
-          # Add date to the cache to keep it up to date
-          key: ${{ matrix.platform }}-stable-cargo-registry-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
-          # Restore from outdated cache for speed
-          restore-keys: |
-            ${{ matrix.platform }}-stable-cargo-registry-${{ hashFiles('**/Cargo.toml') }}
-            ${{ matrix.platform }}-stable-cargo-registry-
-
-      - name: Cache cargo index
-        uses: actions/cache@v2.1.4
+      - name: Cache cargo state
+        uses: actions/cache@v2
+        env:
+          cache-name: cargo-state
         with:
-          path: ~/.cargo/git
-          # Add date to the cache to keep it up to date
-          key: ${{ matrix.platform }}-stable-cargo-index-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
-          # Restore from outdated cache for speed
+          path: |
+            ~/.cargo/registry
+            ~/.cargo/git
+            ~/.cargo/bin
+          key: ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
           restore-keys: |
-            ${{ matrix.platform }}-stable-cargo-index-${{ hashFiles('**/Cargo.toml') }}
-            ${{ matrix.platform }}-stable-cargo-index-
+            ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-
+            ${{ matrix.platform }}-stable-${{ env.cache-name }}-
+            ${{ matrix.platform }}-stable-
+            ${{ matrix.platform }}-
 
       - name: Cache bundler cargo target
         uses: actions/cache@v2
+        env:
+          cache-name: cargo-bundler
         with:
           path: tooling/bundler/target
           # Add date to the cache to keep it up to date
-          key: ${{ matrix.platform }}-stable-cargo-bundler-${{ hashFiles('tooling/bundler/Cargo.lock') }}-${{ env.CURRENT_DATE }}
+          key: ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('tooling/bundler/Cargo.lock') }}-${{ env.CURRENT_DATE }}
           # Restore from outdated cache for speed
           restore-keys: |
-            ${{ matrix.platform }}-stable-cargo-bundler-${{ hashFiles('tooling/bundler/Cargo.lock') }}
-            ${{ matrix.platform }}-stable-cargo-bundler-
+            ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('tooling/bundler/Cargo.lock') }}
+            ${{ matrix.platform }}-stable-${{ env.cache-name }}-
+            ${{ matrix.platform }}-stable-
+            ${{ matrix.platform }}-
 
       - name: test
         run: |
@@ -117,38 +118,36 @@ jobs:
         if: matrix.platform == 'windows-latest'
         run: echo "CURRENT_DATE=$(Get-Date -Format "yyyy-MM-dd")" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
 
-      - name: Cache cargo registry
-        uses: actions/cache@v2.1.4
-        with:
-          path: ~/.cargo/registry
-          # Add date to the cache to keep it up to date
-          key: ${{ matrix.platform }}-stable-cargo-registry-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
-          # Restore from outdated cache for speed
-          restore-keys: |
-            ${{ matrix.platform }}-stable-cargo-registry-${{ hashFiles('**/Cargo.toml') }}
-            ${{ matrix.platform }}-stable-cargo-registry-
-
-      - name: Cache cargo index
-        uses: actions/cache@v2.1.4
+      - name: Cache cargo state
+        uses: actions/cache@v2
+        env:
+          cache-name: cargo-state
         with:
-          path: ~/.cargo/git
-          # Add date to the cache to keep it up to date
-          key: ${{ matrix.platform }}-stable-cargo-index-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
-          # Restore from outdated cache for speed
+          path: |
+            ~/.cargo/registry
+            ~/.cargo/git
+            ~/.cargo/bin
+          key: ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
           restore-keys: |
-            ${{ matrix.platform }}-stable-cargo-index-${{ hashFiles('**/Cargo.toml') }}
-            ${{ matrix.platform }}-stable-cargo-index-
+            ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-
+            ${{ matrix.platform }}-stable-${{ env.cache-name }}-
+            ${{ matrix.platform }}-stable-
+            ${{ matrix.platform }}-
 
       - name: Cache bundler cargo target
         uses: actions/cache@v2
+        env:
+          cache-name: cargo-bundler
         with:
           path: tooling/bundler/target
           # Add date to the cache to keep it up to date
-          key: ${{ matrix.platform }}-stable-cargo-bundler-${{ hashFiles('tooling/bundler/Cargo.lock') }}-${{ env.CURRENT_DATE }}
+          key: ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('tooling/bundler/Cargo.lock') }}-${{ env.CURRENT_DATE }}
           # Restore from outdated cache for speed
           restore-keys: |
-            ${{ matrix.platform }}-stable-cargo-bundler-${{ hashFiles('tooling/bundler/Cargo.lock') }}
-            ${{ matrix.platform }}-stable-cargo-bundler-
+            ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('tooling/bundler/Cargo.lock') }}
+            ${{ matrix.platform }}-stable-${{ env.cache-name }}-
+            ${{ matrix.platform }}-stable-
+            ${{ matrix.platform }}-
 
       - name: clippy check
         uses: actions-rs/clippy-check@v1

+ 49 - 47
.github/workflows/test-cli.yml

@@ -16,6 +16,8 @@ on:
 
 env:
   RUST_BACKTRACE: 1
+  CARGO_INCREMENTAL: 0 # This is set to 0 by the https://github.com/Swatinem/rust-cache
+  CARGO_PROFILE_DEV_DEBUG: 0 # This would add unnecessary bloat to the target folder, decreasing cache efficiency.
 
 jobs:
   test-tauri-cli:
@@ -42,38 +44,36 @@ jobs:
         if: matrix.platform == 'windows-latest'
         run: echo "CURRENT_DATE=$(Get-Date -Format "yyyy-MM-dd")" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
 
-      - name: Cache cargo registry
-        uses: actions/cache@v2.1.4
-        with:
-          path: ~/.cargo/registry
-          # Add date to the cache to keep it up to date
-          key: ${{ matrix.platform }}-stable-cargo-registry-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
-          # Restore from outdated cache for speed
-          restore-keys: |
-            ${{ matrix.platform }}-stable-cargo-registry-${{ hashFiles('**/Cargo.toml') }}
-            ${{ matrix.platform }}-stable-cargo-registry-
-
-      - name: Cache cargo index
-        uses: actions/cache@v2.1.4
+      - name: Cache cargo state
+        uses: actions/cache@v2
+        env:
+          cache-name: cargo-state
         with:
-          path: ~/.cargo/git
-          # Add date to the cache to keep it up to date
-          key: ${{ matrix.platform }}-stable-cargo-index-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
-          # Restore from outdated cache for speed
+          path: |
+            ~/.cargo/registry
+            ~/.cargo/git
+            ~/.cargo/bin
+          key: ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
           restore-keys: |
-            ${{ matrix.platform }}-stable-cargo-index-${{ hashFiles('**/Cargo.toml') }}
-            ${{ matrix.platform }}-stable-cargo-index-
+            ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-
+            ${{ matrix.platform }}-stable-${{ env.cache-name }}-
+            ${{ matrix.platform }}-stable-
+            ${{ matrix.platform }}-
 
       - name: Cache CLI cargo target
         uses: actions/cache@v2
+        env:
+          cache-name: cargo-cli
         with:
           path: tooling/cli/target
           # Add date to the cache to keep it up to date
-          key: ${{ matrix.platform }}-stable-cargo-cli-${{ hashFiles('tooling/cli/Cargo.lock') }}-${{ env.CURRENT_DATE }}
+          key: ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('tooling/cli/Cargo.lock') }}-${{ env.CURRENT_DATE }}
           # Restore from outdated cache for speed
           restore-keys: |
-            ${{ matrix.platform }}-stable-cargo-cli-${{ hashFiles('tooling/cli/Cargo.lock') }}
-            ${{ matrix.platform }}-stable-cargo-cli-
+            ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('tooling/cli/Cargo.lock') }}
+            ${{ matrix.platform }}-stable-${{ env.cache-name }}-
+            ${{ matrix.platform }}-stable-
+            ${{ matrix.platform }}-
 
       - name: build CLI
         uses: actions-rs/cargo@v1
@@ -116,49 +116,51 @@ jobs:
         if: matrix.platform == 'windows-latest'
         run: echo "CURRENT_DATE=$(Get-Date -Format "yyyy-MM-dd")" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
 
-      - name: Cache cargo registry
-        uses: actions/cache@v2.1.4
-        with:
-          path: ~/.cargo/registry
-          # Add date to the cache to keep it up to date
-          key: ${{ matrix.platform }}-stable-cargo-registry-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
-          # Restore from outdated cache for speed
-          restore-keys: |
-            ${{ matrix.platform }}-stable-cargo-registry-${{ hashFiles('**/Cargo.toml') }}
-            ${{ matrix.platform }}-stable-cargo-registry-
-
-      - name: Cache cargo index
-        uses: actions/cache@v2.1.4
+      - name: Cache cargo state
+        uses: actions/cache@v2
+        env:
+          cache-name: cargo-state
         with:
-          path: ~/.cargo/git
-          # Add date to the cache to keep it up to date
-          key: ${{ matrix.platform }}-stable-cargo-index-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
-          # Restore from outdated cache for speed
+          path: |
+            ~/.cargo/registry
+            ~/.cargo/git
+            ~/.cargo/bin
+          key: ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
           restore-keys: |
-            ${{ matrix.platform }}-stable-cargo-index-${{ hashFiles('**/Cargo.toml') }}
-            ${{ matrix.platform }}-stable-cargo-index-
+            ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-
+            ${{ matrix.platform }}-stable-${{ env.cache-name }}-
+            ${{ matrix.platform }}-stable-
+            ${{ matrix.platform }}-
 
       - name: Cache CLI cargo target
         uses: actions/cache@v2
+        env:
+          cache-name: cargo-cli
         with:
           path: tooling/cli/target
           # Add date to the cache to keep it up to date
-          key: ${{ matrix.platform }}-stable-cargo-cli-${{ hashFiles('tooling/cli/Cargo.lock') }}-${{ env.CURRENT_DATE }}
+          key: ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('tooling/cli/Cargo.lock') }}-${{ env.CURRENT_DATE }}
           # Restore from outdated cache for speed
           restore-keys: |
-            ${{ matrix.platform }}-stable-cargo-cli-${{ hashFiles('tooling/cli/Cargo.lock') }}
-            ${{ matrix.platform }}-stable-cargo-cli-
+            ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('tooling/cli/Cargo.lock') }}
+            ${{ matrix.platform }}-stable-${{ env.cache-name }}-
+            ${{ matrix.platform }}-stable-
+            ${{ matrix.platform }}-
 
       - name: Cache template cargo target
         uses: actions/cache@v2
+        env:
+          cache-name: cargo-template
         with:
           path: tooling/cli/node/test/jest/fixtures/empty/src-tauri/target
           # Add date to the cache to keep it up to date
-          key: ${{ matrix.platform }}-stable-template-${{ hashFiles('tooling/cli/templates/app/**') }}-${{ env.CURRENT_DATE }}
+          key: ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('tooling/cli/templates/app/**') }}-${{ env.CURRENT_DATE }}
           # Restore from outdated cache for speed
           restore-keys: |
-            ${{ matrix.platform }}-stable-template-${{ hashFiles('tooling/cli/templates/app/**') }}
-            ${{ matrix.platform }}-stable-template-
+            ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('tooling/cli/templates/app/**') }}
+            ${{ matrix.platform }}-stable-${{ env.cache-name }}-
+            ${{ matrix.platform }}-stable-
+            ${{ matrix.platform }}-
 
       - name: test
         timeout-minutes: 30

+ 22 - 22
.github/workflows/test-core.yml

@@ -18,6 +18,8 @@ on:
 
 env:
   RUST_BACKTRACE: 1
+  CARGO_INCREMENTAL: 0 # This is set to 0 by the https://github.com/Swatinem/rust-cache
+  CARGO_PROFILE_DEV_DEBUG: 0 # This would add unnecessary bloat to the target folder, decreasing cache efficiency.
 
 jobs:
   test-tauri-core:
@@ -48,38 +50,36 @@ jobs:
         if: matrix.platform == 'windows-latest'
         run: echo "CURRENT_DATE=$(Get-Date -Format "yyyy-MM-dd")" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
 
-      - name: Cache cargo registry
-        uses: actions/cache@v2.1.4
-        with:
-          path: ~/.cargo/registry
-          # Add date to the cache to keep it up to date
-          key: ${{ matrix.platform }}-stable-cargo-registry-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
-          # Restore from outdated cache for speed
-          restore-keys: |
-            ${{ matrix.platform }}-stable-cargo-registry-${{ hashFiles('**/Cargo.toml') }}
-            ${{ matrix.platform }}-stable-cargo-registry-
-
-      - name: Cache cargo index
-        uses: actions/cache@v2.1.4
+      - name: Cache cargo state
+        uses: actions/cache@v2
+        env:
+          cache-name: cargo-state
         with:
-          path: ~/.cargo/git
-          # Add date to the cache to keep it up to date
-          key: ${{ matrix.platform }}-stable-cargo-index-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
-          # Restore from outdated cache for speed
+          path: |
+            ~/.cargo/registry
+            ~/.cargo/git
+            ~/.cargo/bin
+          key: ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
           restore-keys: |
-            ${{ matrix.platform }}-stable-cargo-index-${{ hashFiles('**/Cargo.toml') }}
-            ${{ matrix.platform }}-stable-cargo-index-
+            ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-
+            ${{ matrix.platform }}-stable-${{ env.cache-name }}-
+            ${{ matrix.platform }}-stable-
+            ${{ matrix.platform }}-
 
       - name: Cache core cargo target
         uses: actions/cache@v2
+        env:
+          cache-name: cargo-core
         with:
           path: target
           # Add date to the cache to keep it up to date
-          key: ${{ matrix.platform }}-stable-cargo-core-${{ hashFiles('core/**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
+          key: ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('core/**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
           # Restore from outdated cache for speed
           restore-keys: |
-            ${{ matrix.platform }}-stable-cargo-core-${{ hashFiles('core/**/Cargo.toml') }}
-            ${{ matrix.platform }}-stable-cargo-core-
+            ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('core/**/Cargo.toml') }}
+            ${{ matrix.platform }}-stable-${{ env.cache-name }}-
+            ${{ matrix.platform }}-stable-
+            ${{ matrix.platform }}-
 
       - name: test
         run: |

+ 2 - 0
.github/workflows/test-cta.yml

@@ -5,6 +5,8 @@
 name: test create-tauri-app
 env:
   RUST_BACKTRACE: 1
+  CARGO_INCREMENTAL: 0 # This is set to 0 by the https://github.com/Swatinem/rust-cache
+  CARGO_PROFILE_DEV_DEBUG: 0 # This would add unnecessary bloat to the target folder, decreasing cache efficiency.
   TAURI_RECIPE: 'vanillajs,cra,vite,ngcli,solid'
 
 on:

+ 40 - 29
.github/workflows/udeps.yml

@@ -12,6 +12,11 @@ on:
       - 'tooling/bundler/**'
       - 'tooling/cli/**'
 
+env:
+  RUST_BACKTRACE: 1
+  CARGO_INCREMENTAL: 0 # This is set to 0 by the https://github.com/Swatinem/rust-cache
+  CARGO_PROFILE_DEV_DEBUG: 0 # This would add unnecessary bloat to the target folder, decreasing cache efficiency.
+
 jobs:
   udeps:
     runs-on: ubuntu-latest
@@ -27,65 +32,71 @@ jobs:
       - name: Get current date
         run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
 
-      - name: Cache cargo registry
-        uses: actions/cache@v2.1.4
-        with:
-          path: ~/.cargo/registry
-          # Add date to the cache to keep it up to date
-          key: ubuntu-latest-nightly-cargo-registry-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
-          # Restore from outdated cache for speed
-          restore-keys: |
-            ubuntu-latest-nightly-cargo-registry-${{ hashFiles('**/Cargo.toml') }}
-            ubuntu-latest-nightly-cargo-registry-
-
-      - name: Cache cargo index
-        uses: actions/cache@v2.1.4
+      - name: Cache cargo state
+        uses: actions/cache@v2
+        env:
+          cache-name: cargo-state
         with:
-          path: ~/.cargo/git
-          # Add date to the cache to keep it up to date
-          key: ubuntu-latest-nightly-cargo-index-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
-          # Restore from outdated cache for speed
+          path: |
+            ~/.cargo/registry
+            ~/.cargo/git
+            ~/.cargo/bin
+          key: ubuntu-latest-nightly-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
           restore-keys: |
-            ubuntu-latest-nightly-cargo-index-${{ hashFiles('**/Cargo.toml') }}
-            ubuntu-latest-nightly-cargo-index-
+            ubuntu-latest-nightly-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-
+            ubuntu-latest-nightly-${{ env.cache-name }}-
+            ubuntu-latest-nightly-
+            ubuntu-latest-
 
       - name: Cache core cargo target
         uses: actions/cache@v2
+        env:
+          cache-name: cargo-core
         with:
           path: target
           # Add date to the cache to keep it up to date
-          key: ubuntu-latest-nightly-cargo-core-${{ hashFiles('core/**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
+          key: ubuntu-latest-nightly-${{ env.cache-name }}-${{ hashFiles('core/**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
           # Restore from outdated cache for speed
           restore-keys: |
-            ubuntu-latest-nightly-cargo-core-${{ hashFiles('core/**/Cargo.toml') }}
-            ubuntu-latest-nightly-cargo-core-
+            ubuntu-latest-nightly-${{ env.cache-name }}-${{ hashFiles('core/**/Cargo.toml') }}
+            ubuntu-latest-nightly-${{ env.cache-name }}-
+            ubuntu-latest-nightly-
+            ubuntu-latest-
 
       - name: Cache bundler cargo target
         uses: actions/cache@v2
+        env:
+          cache-name: cargo-bundler
         with:
           path: tooling/bundler/target
           # Add date to the cache to keep it up to date
-          key: ubuntu-latest-nightly-cargo-bundler-${{ hashFiles('tooling/bundler/Cargo.lock') }}-${{ env.CURRENT_DATE }}
+          key: ubuntu-latest-nightly-${{ env.cache-name }}-${{ hashFiles('tooling/bundler/Cargo.lock') }}-${{ env.CURRENT_DATE }}
           # Restore from outdated cache for speed
           restore-keys: |
-            ubuntu-latest-nightly-cargo-bundler-${{ hashFiles('tooling/bundler/Cargo.lock') }}
-            ubuntu-latest-nightly-cargo-bundler-
+            ubuntu-latest-nightly-${{ env.cache-name }}-${{ hashFiles('tooling/bundler/Cargo.lock') }}
+            ubuntu-latest-nightly-${{ env.cache-name }}-
+            ubuntu-latest-nightly-
+            ubuntu-latest-
 
       - name: Cache CLI cargo target
         uses: actions/cache@v2
+        env:
+          cache-name: cargo-cli
         with:
           path: tooling/cli/target
           # Add date to the cache to keep it up to date
-          key: ubuntu-latest-nightly-cargo-cli-${{ hashFiles('tooling/cli/Cargo.lock') }}-${{ env.CURRENT_DATE }}
+          key: ubuntu-latest-nightly-${{ env.cache-name }}-${{ hashFiles('tooling/cli/Cargo.lock') }}-${{ env.CURRENT_DATE }}
           # Restore from outdated cache for speed
           restore-keys: |
-            ubuntu-latest-nightly-cargo-cli-${{ hashFiles('tooling/cli/Cargo.lock') }}
-            ubuntu-latest-nightly-cargo-cli-
+            ubuntu-latest-nightly-${{ env.cache-name }}-${{ hashFiles('tooling/cli/Cargo.lock') }}
+            ubuntu-latest-nightly-${{ env.cache-name }}-
+            ubuntu-latest-nightly-
+            ubuntu-latest-
 
       - uses: actions-rs/cargo@v1
         with:
           command: install
-          args: cargo-udeps --locked
+          args: cargo-udeps --locked --force
 
       - name: Install required packages
         run: |

+ 19 - 18
tooling/cli/templates/plugin/backend/.github/workflows/test.yml

@@ -44,35 +44,36 @@ jobs:
       if: matrix.os == 'windows-latest'
       run: echo "CURRENT_DATE=$(Get-Date -Format "yyyy-MM-dd")" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
 
-    - name: Cache cargo registry
+    - name: Cache cargo state
       uses: actions/cache@v2
+      env:
+        cache-name: cargo-state
       with:
-        path: ~/.cargo/registry
-        # Add date to the cache to keep it up to date
-        key: ${{ matrix.os }}-${{ matrix.rust }}-cargo-registry-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
-        # Restore from outdated cache for speed
-        restore-keys: |
-          ${{ matrix.os }}-${{ matrix.rust }}-cargo-registry-${{ hashFiles('**/Cargo.toml') }}
-
-    - name: Cache cargo index
-      uses: actions/cache@v2
-      with:
-        path: ~/.cargo/git
-        # Add date to the cache to keep it up to date
-        key: ${{ matrix.os }}-${{ matrix.rust }}-cargo-index-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
-        # Restore from outdated cache for speed
+        path: |
+          ~/.cargo/registry
+          ~/.cargo/git
+          ~/.cargo/bin
+        key: ${{ matrix.os }}-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
         restore-keys: |
-          ${{ matrix.os }}-${{ matrix.rust }}-cargo-index-${{ hashFiles('**/Cargo.toml') }}
+          ${{ matrix.os }}-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-
+          ${{ matrix.os }}-stable-${{ env.cache-name }}-
+          ${{ matrix.os }}-stable-
+          ${{ matrix.os }}-
 
     - name: Cache cargo target
       uses: actions/cache@v2
+      env:
+          cache-name: cargo-build
       with:
         path: ${{ matrix.project}}/target
         # Add date to the cache to keep it up to date
-        key: ${{ matrix.os }}-${{ matrix.rust }}-cargo-build-target-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
+        key: ${{ matrix.os }}-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
         # Restore from outdated cache for speed
         restore-keys: |
-          ${{ matrix.os }}-${{ matrix.rust }}-cargo-build-target-${{ hashFiles('**/Cargo.toml') }}
+          ${{ matrix.os }}-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}
+          ${{ matrix.os }}-stable-${{ env.cache-name }}-
+          ${{ matrix.os }}-stable-
+          ${{ matrix.os }}-
 
     - name: Run tests 
       uses: actions-rs/cargo@v1

+ 19 - 18
tooling/cli/templates/plugin/with-api/.github/workflows/test.yml

@@ -44,35 +44,36 @@ jobs:
       if: matrix.os == 'windows-latest'
       run: echo "CURRENT_DATE=$(Get-Date -Format "yyyy-MM-dd")" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
 
-    - name: Cache cargo registry
+    - name: Cache cargo state
       uses: actions/cache@v2
+      env:
+        cache-name: cargo-state
       with:
-        path: ~/.cargo/registry
-        # Add date to the cache to keep it up to date
-        key: ${{ matrix.os }}-${{ matrix.rust }}-cargo-registry-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
-        # Restore from outdated cache for speed
-        restore-keys: |
-          ${{ matrix.os }}-${{ matrix.rust }}-cargo-registry-${{ hashFiles('**/Cargo.toml') }}
-
-    - name: Cache cargo index
-      uses: actions/cache@v2
-      with:
-        path: ~/.cargo/git
-        # Add date to the cache to keep it up to date
-        key: ${{ matrix.os }}-${{ matrix.rust }}-cargo-index-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
-        # Restore from outdated cache for speed
+        path: |
+          ~/.cargo/registry
+          ~/.cargo/git
+          ~/.cargo/bin
+        key: ${{ matrix.os }}-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
         restore-keys: |
-          ${{ matrix.os }}-${{ matrix.rust }}-cargo-index-${{ hashFiles('**/Cargo.toml') }}
+          ${{ matrix.os }}-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-
+          ${{ matrix.os }}-stable-${{ env.cache-name }}-
+          ${{ matrix.os }}-stable-
+          ${{ matrix.os }}-
 
     - name: Cache cargo target
       uses: actions/cache@v2
+      env:
+          cache-name: cargo-build
       with:
         path: ${{ matrix.project}}/target
         # Add date to the cache to keep it up to date
-        key: ${{ matrix.os }}-${{ matrix.rust }}-cargo-build-target-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
+        key: ${{ matrix.os }}-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
         # Restore from outdated cache for speed
         restore-keys: |
-          ${{ matrix.os }}-${{ matrix.rust }}-cargo-build-target-${{ hashFiles('**/Cargo.toml') }}
+          ${{ matrix.os }}-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}
+          ${{ matrix.os }}-stable-${{ env.cache-name }}-
+          ${{ matrix.os }}-stable-
+          ${{ matrix.os }}-
 
     - name: Run tests 
       uses: actions-rs/cargo@v1