Skip to content

Commit

Permalink
Add caching dupe change (google#835)
Browse files Browse the repository at this point in the history
* fixed cache dupe call

* add shell

* Removed duplicate calls for caching in CI. Resolves google#340

* fixed multiple runs

* removed whitespace .github/workflows/ci.yml

Co-authored-by: Joshua Liebow-Feeser <[email protected]>

* removed whitespace .github/workflows/ci.yml

Co-authored-by: Joshua Liebow-Feeser <[email protected]>

* removed whitespace .github/workflows/ci.yml

Co-authored-by: Joshua Liebow-Feeser <[email protected]>

---------

Co-authored-by: Joshua Liebow-Feeser <[email protected]>
  • Loading branch information
dorryspears and joshlf committed Feb 20, 2024
1 parent 284bf83 commit bab960f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 33 deletions.
11 changes: 11 additions & 0 deletions .github/actions/cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Cache
description: 'Caches cargo dependencies'
runs:
using: composite
steps:
- uses: actions/cache@v3
with:
path: |
~/.cargo/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}

48 changes: 15 additions & 33 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,9 @@ jobs:
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
with:
path: |
~/.cargo/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}

- name: Populate cache
uses: ./.github/actions/cache

- name: Configure environment variables
run: |
set -eo pipefail
Expand Down Expand Up @@ -346,12 +343,9 @@ jobs:
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
with:
path: |
~/.cargo/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}

- name: Populate cache
uses: ./.github/actions/cache

- name: Check README.md
run: |
set -eo pipefail
Expand All @@ -370,13 +364,10 @@ jobs:
name: Check MSRVs match
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
with:
path: |
~/.cargo/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}


- name: Populate cache
uses: ./.github/actions/cache

# Make sure that the MSRV in zerocopy's and zerocopy-derive's `Cargo.toml`
# files are the same. In CI, we test with a single MSRV (the one indicated
# in zerocopy's `Cargo.toml`), so it's important that:
Expand Down Expand Up @@ -414,11 +405,8 @@ jobs:
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
with:
path: |
~/.cargo/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}
- name: Populate cache
uses: ./.github/actions/cache

# Make sure that both crates are at the same version, and that zerocopy
# depends exactly upon the current version of zerocopy-derive. See
Expand Down Expand Up @@ -485,20 +473,16 @@ jobs:
assert-match "$zerocopy_derive_dep_ver" "$zerocopy_derive_targeted_ver" \
"Same crate version ($zerocopy_derive_dep_ver) found for optional and targeted zerocopy-derive dependency." \
"Different crate versions found for optional ($zerocopy_derive_dep_ver) and targeted ($zerocopy_derive_targeted_ver) dependency."
generate_cache:
runs-on: ubuntu-latest
name: Generate cache
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
with:
path: |
~/.cargo/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}

- name: Populate cache
uses: ./.github/actions/cache

- name: Download dependencies
run: |
# Ensure all dependencies are downloaded - both for our crates and for
# tools we use in CI. We don't care about these tools succeeding for
Expand All @@ -519,7 +503,6 @@ jobs:
cargo install cargo-readme --version 3.2.0 &> /dev/null || true
cargo install --locked kani-verifier &> /dev/null || true
cargo kani setup &> /dev/null || true
check-all-toolchains-tested:
runs-on: ubuntu-latest
name: Check that all toolchains listed in Cargo.toml are tested in CI
Expand All @@ -544,7 +527,6 @@ jobs:
<(cargo metadata --format-version 1 | \
jq -r ".packages[] | select(.name == \"zerocopy\").metadata.\"build-rs\" | keys | .[]" | \
sort -u)
check-job-dependencies:
runs-on: ubuntu-latest
name: Check all-jobs-succeeded depends on all jobs
Expand Down

0 comments on commit bab960f

Please sign in to comment.