Skip to content

Commit

Permalink
Share the Rust cache across jobs. (#145)
Browse files Browse the repository at this point in the history
### What

Apparently we are generating a new Rust cache per job. This grows really
fast.

Let's not do this.

### How

By setting a "shared key", we can ensure that all jobs share the same
cache.

I have chosen the name arbitrarily.
  • Loading branch information
SamirTalwar authored Nov 3, 2023
1 parent 4be0b1d commit 93904e0
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/cargo-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
rustup show
- uses: Swatinem/rust-cache@v2
with:
shared-key: "build" # share the cache across jobs

- name: build crates
run: |
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/cargo-machete.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ jobs:
cargo install cargo-machete
- uses: Swatinem/rust-cache@v2
with:
shared-key: "build" # share the cache across jobs

- name: find unused dependencies
run: |
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/cargo-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ jobs:
curl -LsSf https://get.nexte.st/latest/linux | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin
- uses: Swatinem/rust-cache@v2
with:
shared-key: "build" # share the cache across jobs

- name: run tests
run: |
Expand Down Expand Up @@ -64,6 +66,8 @@ jobs:
curl -LsSf https://get.nexte.st/latest/linux | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin
- uses: Swatinem/rust-cache@v2
with:
shared-key: "build" # share the cache across jobs

- id: configuration
name: extract job configuration
Expand Down Expand Up @@ -132,6 +136,8 @@ jobs:
curl -LsSf https://get.nexte.st/latest/linux | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin
- uses: Swatinem/rust-cache@v2
with:
shared-key: "build" # share the cache across jobs

- name: run tests
run: |
Expand Down Expand Up @@ -181,6 +187,8 @@ jobs:
curl -LsSf https://get.nexte.st/latest/linux | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin
- uses: Swatinem/rust-cache@v2
with:
shared-key: "build" # share the cache across jobs

- name: start dependencies
uses: isbang/[email protected]
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/check-format.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ jobs:
rustup show
- uses: Swatinem/rust-cache@v2
with:
shared-key: "build" # share the cache across jobs

- name: check formatting
run: |
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/schema-definitions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
run: rustup show

- uses: Swatinem/rust-cache@v2
with:
shared-key: "build" # share the cache across jobs

- name: OpenAPI Definitions
run: cargo test --bin openapi-generator

0 comments on commit 93904e0

Please sign in to comment.