From 4a4878f4a61364ca8aa3728548a2a065644c7fbc Mon Sep 17 00:00:00 2001 From: Matt Mastracci Date: Mon, 12 Jun 2023 15:59:34 -0600 Subject: [PATCH] chore: No longer need a sparse checkout thanks to cargo sparse index (#19423) `cargo`'s sparse index showed up in 1.68 --- .github/workflows/ci.generate.ts | 23 ++++------------------- .github/workflows/ci.yml | 17 ++++------------- 2 files changed, 8 insertions(+), 32 deletions(-) diff --git a/.github/workflows/ci.generate.ts b/.github/workflows/ci.generate.ts index e6a5b12896..4b595d7f68 100755 --- a/.github/workflows/ci.generate.ts +++ b/.github/workflows/ci.generate.ts @@ -5,7 +5,7 @@ import * as yaml from "https://deno.land/std@0.173.0/encoding/yaml.ts"; // Bump this number when you want to purge the cache. // Note: the tools/release/01_bump_crate_versions.ts script will update this version // automatically via regex, so ensure that this line maintains this format. -const cacheVersion = 38; +const cacheVersion = 39; const Runners = (() => { const ubuntuRunner = "ubuntu-22.04"; @@ -488,13 +488,15 @@ const ci = { uses: "actions/cache@v3", with: { // See https://doc.rust-lang.org/cargo/guide/cargo-home.html#caching-the-cargo-home-in-ci + // Note that with the new sparse registry format, we no longer have to cache a `.git` dir path: [ "~/.cargo/registry/index", "~/.cargo/registry/cache", - "~/.cargo/git/db", ].join("\n"), key: `${cacheVersion}-cargo-home-\${{ matrix.os }}-\${{ hashFiles('Cargo.lock') }}`, + // We will try to restore from the closest cargo-home we can find + "restore-keys": `${cacheVersion}-cargo-home-\${{ matrix.os }}`, }, }, { @@ -522,23 +524,6 @@ const ci = { "cache-path": "./target", }, }, - { - // Shallow the cloning the crates.io index makes CI faster because it - // obviates the need for Cargo to clone the index. If we don't do this - // Cargo will `git clone` the github repository that contains the entire - // history of the crates.io index from github. We don't believe the - // identifier '1ecc6299db9ec823' will ever change, but if it does then this - // command must be updated. - name: "Shallow clone crates.io index", - run: [ - "if [ ! -d ~/.cargo/registry/index/github.com-1ecc6299db9ec823/.git ]", - "then", - " git clone --depth 1 --no-checkout \\", - " https://github.com/rust-lang/crates.io-index \\", - " ~/.cargo/registry/index/github.com-1ecc6299db9ec823", - "fi", - ].join("\n"), - }, { name: "test_format.js", if: "matrix.job == 'lint'", diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e631544179..392d427d78 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -298,8 +298,8 @@ jobs: path: |- ~/.cargo/registry/index ~/.cargo/registry/cache - ~/.cargo/git/db - key: '38-cargo-home-${{ matrix.os }}-${{ hashFiles(''Cargo.lock'') }}' + key: '39-cargo-home-${{ matrix.os }}-${{ hashFiles(''Cargo.lock'') }}' + restore-keys: '39-cargo-home-${{ matrix.os }}' if: '!(github.event_name == ''pull_request'' && matrix.skip_pr)' - name: Restore cache build output (PR) uses: actions/cache/restore@v3 @@ -311,21 +311,12 @@ jobs: !./target/*/*.zip !./target/*/*.tar.gz key: never_saved - restore-keys: '38-cargo-target-${{ matrix.os }}-${{ matrix.profile }}-${{ matrix.job }}-' + restore-keys: '39-cargo-target-${{ matrix.os }}-${{ matrix.profile }}-${{ matrix.job }}-' - name: Apply and update mtime cache if: '!(github.event_name == ''pull_request'' && matrix.skip_pr) && (!startsWith(github.ref, ''refs/tags/''))' uses: ./.github/mtime_cache with: cache-path: ./target - - name: Shallow clone crates.io index - run: |- - if [ ! -d ~/.cargo/registry/index/github.com-1ecc6299db9ec823/.git ] - then - git clone --depth 1 --no-checkout \ - https://github.com/rust-lang/crates.io-index \ - ~/.cargo/registry/index/github.com-1ecc6299db9ec823 - fi - if: '!(github.event_name == ''pull_request'' && matrix.skip_pr)' - name: test_format.js if: '!(github.event_name == ''pull_request'' && matrix.skip_pr) && (matrix.job == ''lint'')' run: deno run --unstable --allow-write --allow-read --allow-run ./tools/format.js --check @@ -601,7 +592,7 @@ jobs: !./target/*/gn_out !./target/*/*.zip !./target/*/*.tar.gz - key: '38-cargo-target-${{ matrix.os }}-${{ matrix.profile }}-${{ matrix.job }}-${{ github.sha }}' + key: '39-cargo-target-${{ matrix.os }}-${{ matrix.profile }}-${{ matrix.job }}-${{ github.sha }}' publish-canary: name: publish canary runs-on: ubuntu-22.04