Skip to content

Commit

Permalink
chore: improve cache utility (#2540)
Browse files Browse the repository at this point in the history
  • Loading branch information
tychoish committed Feb 1, 2024
1 parent 075aaeb commit 4ed93b5
Showing 1 changed file with 34 additions and 50 deletions.
84 changes: 34 additions & 50 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ jobs:
name: toolchain cache
with:
path: ~/.rustup/toolchains/
key: ${{ runner.os }}-toolchain-${{ hashFiles('**/rust-toolchain.toml') }}
key: ${{ runner.os }}-toolchain-build-${{ hashFiles('**/rust-toolchain.toml') }}
- uses: actions/cache@v4
name: cargo cache
with:
path: ~/.cargo/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
key: ${{ runner.os }}-cargo-pkg-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-pkg-build-
- uses: actions/cache@v4
name: build cache
with:
Expand Down Expand Up @@ -69,11 +70,14 @@ jobs:
just-version: "1.23.0"
- uses: actions/cache@v4
name: nightly toolchain cache
id: lint-toolchain
with:
path: ~/.rustup/toolchains/
key: ${{ runner.os }}-toolchain-${{ hashFiles('**/rustfmt.toml') }}
key: ${{ runner.os }}-toolchain-lint-${{ hashFiles('**/rustfmt.toml') }}
- run: rustup install nightly
if: ${{ steps.lint-toolchain.outputs.cache-hit != 'true' }}
- run: rustup component add rustfmt --toolchain nightly
if: ${{ steps.lint-toolchain.outputs.cache-hit != 'true' }}
- run: just fmt-check


Expand All @@ -88,16 +92,20 @@ jobs:
- uses: extractions/setup-just@v1
with:
just-version: "1.23.0"
- uses: actions/cache/restore@v4
- uses: actions/cache@v4
name: toolchain cache
with:
path: ~/.rustup/toolchains/
key: ${{ runner.os }}-toolchain-${{ hashFiles('**/rust-toolchain.toml') }}
- uses: actions/cache/restore@v4
key: ${{ runner.os }}-toolchain-build-${{ hashFiles('**/rust-toolchain.toml') }}
- uses: actions/cache@v4
name: cargo cache
with:
path: ~/.cargo/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
key: ${{ runner.os }}-cargo-pkg-lint-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-pkg-build-${{ hashFiles('**/Cargo.lock') }}
${{ runner.os }}-cargo-pkg-lint-
${{ runner.os }}-cargo-pkg-build-
- uses: actions/cache/restore@v4
name: build cache
with:
Expand All @@ -123,12 +131,16 @@ jobs:
name: toolchain cache
with:
path: ~/.rustup/toolchains/
key: ${{ runner.os }}-toolchain-${{ hashFiles('**/rust-toolchain.toml') }}
key: ${{ runner.os }}-toolchain-build-${{ hashFiles('**/rust-toolchain.toml') }}
- uses: actions/cache@v4
name: cargo cache
with:
path: ~/.cargo/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
key: ${{ runner.os }}-cargo-pkg-python-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-pkg-build-${{ hashFiles('**/Cargo.lock') }}
${{ runner.os }}-cargo-pkg-python-
${{ runner.os }}-cargo-pkg-build-
- uses: actions/cache@v4
name: build cache
with:
Expand Down Expand Up @@ -157,14 +169,14 @@ jobs:
name: toolchain cache
with:
path: |
~/.rustup/toolchains/
key: ${{ runner.os }}-toolchain-${{ hashFiles('**/rust-toolchain.toml') }}
- uses: actions/cache/restore@v4
~/.rustup/toolchains/
key: ${{ runner.os }}-toolchain-build-${{ hashFiles('**/rust-toolchain.toml') }}
- uses: actions/cache@v4
name: cargo cache
with:
path: |
~/.cargo/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
path: ~/.cargo/
key: ${{ runner.os }}-cargo-pkg-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-pkg-build-
- uses: actions/cache/restore@v4
name: build cache
with:
Expand All @@ -191,13 +203,17 @@ jobs:
name: toolchain cache
with:
path: ~/.rustup/toolchains/
key: ${{ runner.os }}-toolchain-${{ hashFiles('**/rust-toolchain.toml') }}
key: ${{ runner.os }}-toolchain-build-${{ hashFiles('**/rust-toolchain.toml') }}
- uses: actions/cache@v4
name: cargo cache
with:
path: ~/.cargo/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: actions/cache@v4
key: ${{ runner.os }}-cargo-pkg-unit-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-pkg-build-${{ hashFiles('**/Cargo.lock') }}
${{ runner.os }}-cargo-pkg-unit-
${{ runner.os }}-cargo-pkg-build-
- uses: actions/cache/restore@v4
name: build cache
with:
path: |
Expand All @@ -213,33 +229,6 @@ jobs:
- run: just unit-tests


cache:
# update a cache that can be used between builds, but do it
# outside of the hot path.
name: cache helper
needs: ["build", "python-binding-tests", "unit-tests"]
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- uses: actions/cache/restore@v4
name: build cache
with:
path: |
target/
!target/**/glaredb
!target/**/pgprototest
key: ${{ runner.os }}-cargo-glaredb-build-${{ github.ref_name }}
- uses: actions/cache/save@v4
name: build cache
with:
path: |
target/
!target/**/glaredb
!target/**/pgprototest
key: ${{ runner.os }}-cargo-glaredb-build-${{ hashFiles('**/Cargo.lock') }}


pg-protocol:
name: PG Protocol Tests
runs-on: ubuntu-latest
Expand Down Expand Up @@ -323,11 +312,6 @@ jobs:
with:
path: target/debug/glaredb
key: ${{ runner.os }}-glaredb-bin-${{ github.run_id }}
- uses: actions/cache@v4
name: py cache
with:
path: tests/.venv/
key: ${{ runner.os }}-poetry-${{ hashFiles('tests/poetry.lock') }}
- run: just venv
- run: just pytest

Expand Down

0 comments on commit 4ed93b5

Please sign in to comment.