Skip to content

Commit

Permalink
chore(ci): setup cargo cache to speed up cicd
Browse files Browse the repository at this point in the history
Signed-off-by: Chawye Hsu <[email protected]>
  • Loading branch information
chawyehsu committed Jul 25, 2023
1 parent a9c192b commit df42261
Showing 1 changed file with 40 additions and 18 deletions.
58 changes: 40 additions & 18 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ permissions:
contents: write
pull-requests: write
jobs:
# Check code style
check_cargo_style:
# Check code style and tests
check_cargo_base:
name: Check Code Style
runs-on: windows-latest
steps:
Expand All @@ -20,36 +20,34 @@ jobs:
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: stable
components: clippy, rustfmt

- name: Setup Cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Format Check
run: cargo fmt -- --check

- name: Clippy Check
run: cargo clippy

# Check tests
check_cargo_test:
name: Check Tests
needs: check_cargo_style
runs-on: windows-latest
steps:
- name: Checkout Source
uses: actions/checkout@v3

- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable

- name: Test Check
- name: Tests Check
run: cargo test --workspace

# Check build
check_cargo_build:
name: Check Dev Build
needs: check_cargo_test
needs: check_cargo_base
strategy:
fail-fast: false
matrix:
Expand All @@ -65,9 +63,21 @@ jobs:
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: stable
target: ${{ matrix.target }}

- name: Setup Cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Build Check
run: cargo build --locked --target ${{ matrix.target }}

Expand Down Expand Up @@ -118,9 +128,21 @@ jobs:
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: stable
target: ${{ matrix.target }}

- name: Setup Cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Build
uses: actions-rs/[email protected]
with:
Expand Down

0 comments on commit df42261

Please sign in to comment.