Skip to content

Commit

Permalink
use common actoin to setup rust with cargo cache enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
boqiu committed Jan 29, 2024
1 parent a4abe2b commit b9907f9
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 82 deletions.
20 changes: 1 addition & 19 deletions .github/workflows/cc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
submodules: recursive

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

- name: Install 1.71.0 toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: 1.71.0
override: true
- uses: .github/workflows/setup-rust.yml

- name: Run unittest
run: cargo test --all-features --no-fail-fast
Expand Down
53 changes: 4 additions & 49 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,50 +20,18 @@ jobs:
name: check
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
with:
submodules: recursive

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- uses: .github/workflows/setup-rust.yml
- name: Run cargo check
uses: actions-rs/cargo@v1
with:
command: check
args: --release

test:
name: test
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
with:
submodules: recursive

- name: Cargo 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: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- uses: .github/workflows/setup-rust.yml
- name: Run cargo test
uses: actions-rs/cargo@v1
with:
Expand All @@ -74,25 +42,12 @@ jobs:
name: lints
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
with:
submodules: recursive

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt, clippy

- uses: .github/workflows/setup-rust.yml
- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/setup-rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Setup Rust
runs:
using: composite
steps:
- name: Checkout sources
uses: actions/checkout@v3
with:
submodules: recursive

- name: Cargo 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: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: rustfmt, clippy
15 changes: 1 addition & 14 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Cargo 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') }}
- uses: .github/workflows/setup-rust.yml

- name: Build
run: cargo build --release --verbose
Expand Down

0 comments on commit b9907f9

Please sign in to comment.