From 201ccc83b1e4f736725a717f9e698d8c25a49dc9 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Wed, 10 Aug 2022 16:41:46 -0400 Subject: [PATCH] Cache Cargo registry on GitHub Actions (#3) --- .github/workflows/ci.yaml | 48 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f13da23ba8..cca91d3c15 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -15,6 +15,18 @@ jobs: - uses: actions-rs/toolchain@v1 with: toolchain: stable + - uses: actions/cache@v3 + env: + cache-name: cache-cargo + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- - run: cargo build --bin rust_python_linter --release cargo_fmt: @@ -25,6 +37,18 @@ jobs: - uses: actions-rs/toolchain@v1 with: toolchain: stable + - uses: actions/cache@v3 + env: + cache-name: cache-cargo + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- - run: cargo fmt --check cargo_clippy: @@ -35,6 +59,18 @@ jobs: - uses: actions-rs/toolchain@v1 with: toolchain: stable + - uses: actions/cache@v3 + env: + cache-name: cache-cargo + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- - run: cargo clippy -- -D warnings maturin_build: @@ -49,4 +85,16 @@ jobs: with: python-version: '3.10' - run: pip install maturin + - uses: actions/cache@v3 + env: + cache-name: cache-cargo + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- - run: maturin build -b bin