diff --git a/.github/actions/setup-rust/action.yml b/.github/actions/setup-rust/action.yml new file mode 100644 index 0000000..f560363 --- /dev/null +++ b/.github/actions/setup-rust/action.yml @@ -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 \ No newline at end of file diff --git a/.github/workflows/cc.yml b/.github/workflows/cc.yml index 56b0915..5368b1c 100644 --- a/.github/workflows/cc.yml +++ b/.github/workflows/cc.yml @@ -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 diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 792c2c1..311d6cc 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -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: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7dc76f1..d73731c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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