use common actoin to setup rust with cargo cache enabled (#14)

* use common actoin to setup rust with cargo cache enabled

* hotfix for actions syntax

* hotfix actions syntax

* fix wrong action path

* aaa

* bbb

* ccc

* ddd
This commit is contained in:
Bo QIU 2024-01-29 16:25:04 +08:00 committed by GitHub
parent 19d9d31b0c
commit e7011b4657
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 37 additions and 65 deletions

21
.github/actions/setup-rust/action.yml vendored Normal file
View File

@ -0,0 +1,21 @@
name: Setup Rust (cache & toolchain)
runs:
using: composite
steps:
- 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 toolchain 1.75.0
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.75.0
components: rustfmt, clippy

View File

@ -15,25 +15,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- 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/
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
- name: Setup Rust (cache & toolchain)
uses: ./.github/actions/setup-rust
- name: Run unittest
run: cargo test --all-features --no-fail-fast

View File

@ -24,18 +24,13 @@ jobs:
uses: actions/checkout@v3
with:
submodules: recursive
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Setup Rust (cache & toolchain)
uses: ./.github/actions/setup-rust
- name: Run cargo check
uses: actions-rs/cargo@v1
with:
command: check
args: --release
test:
name: test
@ -45,25 +40,8 @@ jobs:
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
- name: Setup Rust (cache & toolchain)
uses: ./.github/actions/setup-rust
- name: Run cargo test
uses: actions-rs/cargo@v1
with:
@ -78,21 +56,13 @@ jobs:
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
- name: Setup Rust (cache & toolchain)
uses: ./.github/actions/setup-rust
- 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:

View File

@ -15,20 +15,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout sources
uses: actions/checkout@v3
with:
submodules: recursive
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: Setup Rust (cache & toolchain)
uses: ./.github/actions/setup-rust
- name: Build
run: cargo build --release --verbose