diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 9fd45e0..d1ca63b 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -2,21 +2,55 @@ name: Rust on: push: - branches: [ "main" ] + branches: [ main ] pull_request: - branches: [ "main" ] + branches: [ main ] env: CARGO_TERM_COLOR: always jobs: - build: - + build-and-test: + name: Build & Test runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - name: Build - run: cargo build --verbose - - name: Run tests + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install latest stable Rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt, clippy + + - name: Cache cargo registry & build artifacts + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo- + + - name: Check Format + run: cargo fmt -- --check + + - name: Build Release + run: cargo build --release --verbose + + - name: Run Tests run: cargo test --verbose + + - name: Run benchmarks (if any) + if: always() + run: cargo bench || true + + - name: Check for unused dependencies + run: cargo udeps || true + + # - uses: dtolnay/rust-toolchain@stable + # with: + # toolchain: 1.76 # укажи свою MSRV из Cargo.toml + # - run: cargo check --all-targets