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 runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - name: Checkout sources
uses: actions/checkout@v3
with: with:
submodules: recursive submodules: recursive
- name: Cargo cache - name: Setup Rust (cache & toolchain)
uses: actions/cache@v3 uses: ./.github/actions/setup-rust
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: Run unittest - name: Run unittest
run: cargo test --all-features --no-fail-fast run: cargo test --all-features --no-fail-fast

View File

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

View File

@ -15,20 +15,13 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - name: Checkout sources
uses: actions/checkout@v3
with: with:
submodules: recursive submodules: recursive
- name: Cargo cache - name: Setup Rust (cache & toolchain)
uses: actions/cache@v3 uses: ./.github/actions/setup-rust
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build - name: Build
run: cargo build --release --verbose run: cargo build --release --verbose