Fix test #5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Rust SDK Tests | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: [ main, develop ] | |
| paths: | |
| - 'rust/**' | |
| - '.github/workflows/rust-test.yml' | |
| pull_request: | |
| branches: [ main, develop ] | |
| paths: | |
| - 'rust/**' | |
| - '.github/workflows/rust-test.yml' | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| test: | |
| name: Test Rust SDK | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| rust-version: ["1.70", "1.75", "stable", "beta", "nightly"] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Rust ${{ matrix.rust-version }} | |
| uses: dtolnay/rust-toolchain@master | |
| with: | |
| toolchain: ${{ matrix.rust-version }} | |
| components: rustfmt, clippy | |
| - name: Regenerate Cargo.lock for compatibility | |
| run: | | |
| # Remove existing lock file to regenerate with current toolchain | |
| rm -f Cargo.lock | |
| cargo generate-lockfile | |
| working-directory: rust | |
| - name: Cache cargo registry | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| key: ${{ runner.os }}-cargo-${{ matrix.rust-version }}-${{ hashFiles('rust/Cargo.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo-${{ matrix.rust-version }}- | |
| - name: Cache cargo build | |
| uses: actions/cache@v4 | |
| with: | |
| path: target | |
| key: ${{ runner.os }}-cargo-build-${{ matrix.rust-version }}-${{ hashFiles('rust/Cargo.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo-build-${{ matrix.rust-version }}- | |
| - name: Check formatting | |
| run: | | |
| cd rust | |
| cargo fmt --all -- --check | |
| - name: Run clippy | |
| run: | | |
| cd rust | |
| cargo clippy --all-targets --all-features -- -D warnings | |
| - name: Run tests | |
| run: | | |
| cd rust | |
| cargo test --verbose | |
| - name: Build documentation | |
| run: | | |
| cd rust | |
| cargo doc --no-deps --document-private-items | |
| - name: Upload test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: test-results-rust-${{ matrix.rust-version }} | |
| path: rust/target/test-results/ | |
| - name: Upload build logs | |
| uses: actions/upload-artifact@v4 | |
| if: failure() | |
| with: | |
| name: build-logs-rust-${{ matrix.rust-version }} | |
| path: rust/target/ | |
| - name: Upload documentation | |
| uses: actions/upload-artifact@v4 | |
| if: success() | |
| with: | |
| name: docs-rust-${{ matrix.rust-version }} | |
| path: rust/target/doc/ | |
| security: | |
| name: Security Audit | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@master | |
| with: | |
| toolchain: stable | |
| components: rustfmt, clippy | |
| - name: Install cargo-audit | |
| run: cargo install cargo-audit | |
| - name: Run security audit | |
| run: | | |
| cd rust | |
| cargo audit | |
| coverage: | |
| name: Code Coverage | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@master | |
| with: | |
| toolchain: stable | |
| components: rustfmt, clippy | |
| - name: Install cargo-tarpaulin | |
| run: cargo install cargo-tarpaulin | |
| - name: Run tests with coverage | |
| run: | | |
| cd rust | |
| cargo tarpaulin --out Html --output-dir coverage | |
| - name: Upload coverage report | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report-rust | |
| path: rust/coverage/ | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v3 | |
| with: | |
| file: rust/coverage/tarpaulin-report.html | |
| flags: rust | |
| name: rust-coverage |