diff --git a/.github/actions/cargo-cache/action.yml b/.github/actions/cargo-cache/action.yml new file mode 100644 index 0000000..ceffcc3 --- /dev/null +++ b/.github/actions/cargo-cache/action.yml @@ -0,0 +1,18 @@ +name: Cargo registry and build caches +runs: + using: composite + steps: + - name: Cache registry + uses: actions/cache@v3 + with: + path: ~/.cargo/registry/ + key: cargo-registry-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} + restore-keys: | + cargo-registry-${{ runner.os }} + - name: Cache build + uses: actions/cache@v3 + with: + path: ./target/ + key: target-${{ runner.os }}-${{ github.sha }} + restore-keys: | + target-${{ runner.os }} diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 82ecbee..f7c4c48 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -23,6 +23,7 @@ jobs: - uses: actions/checkout@v3 - run: rm -rf ~/.cargo/ - uses: cachix/install-nix-action@v22 + - uses: ./.github/actions/cargo-cache - run: nix develop -c cargo check test: @@ -32,6 +33,7 @@ jobs: - uses: actions/checkout@v3 - run: rm -rf ~/.cargo/ - uses: cachix/install-nix-action@v22 + - uses: ./.github/actions/cargo-cache - run: nix develop -c cargo test lint: @@ -41,6 +43,7 @@ jobs: - uses: actions/checkout@v3 - run: rm -rf ~/.cargo/ - uses: cachix/install-nix-action@v22 + - uses: ./.github/actions/cargo-cache # See: https://github.com/rust-lang/rust-clippy/issues/1209 - run: RUSTFLAGS="-D warnings" nix develop -c cargo clippy --all-targets diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index e61b18d..90758b9 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -76,6 +76,7 @@ jobs: - uses: actions/checkout@v3 - run: rm -rf ~/.cargo/ - uses: cachix/install-nix-action@v22 + - uses: ./.github/actions/cargo-cache - run: | nix develop -c cargo doc --no-deps rm ./target/doc/.lock