Move clippy lint configuration from CI to Cargo.toml #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 | |
| permissions: | |
| contents: read | |
| on: | |
| push: | |
| branches: | |
| - 'main' | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| # Pure Rust tests | |
| rust-tests: | |
| name: Rust Tests (${{ matrix.os }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: '0' | |
| - name: Download SPIRV-Headers | |
| run: python3 utils/git-sync-deps | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache Cargo | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/bin/ | |
| ~/.cargo/registry/index/ | |
| ~/.cargo/registry/cache/ | |
| ~/.cargo/git/db/ | |
| rust/target/ | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('rust/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo- | |
| - name: Build Rust workspace | |
| working-directory: rust | |
| # Exclude spirv-tools-ffi which requires C++ build (tested in rust-ffi-tests job) | |
| run: cargo build --workspace --exclude spirv-tools-ffi | |
| - name: Run Rust tests | |
| working-directory: rust | |
| # Exclude spirv-tools-ffi which requires C++ build (tested in rust-ffi-tests job) | |
| run: cargo test --workspace --exclude spirv-tools-ffi | |
| # Rust FFI pretending to be C++ - runs C++ test suite against Rust implementation | |
| rust-ffi-tests: | |
| name: Rust FFI C++ Tests (${{ matrix.os }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: '0' | |
| - name: Download dependencies | |
| run: python3 utils/git-sync-deps | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache Cargo | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/bin/ | |
| ~/.cargo/registry/index/ | |
| ~/.cargo/registry/cache/ | |
| ~/.cargo/git/db/ | |
| rust/target/ | |
| key: ${{ runner.os }}-cargo-ffi-${{ hashFiles('rust/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo-ffi- | |
| - name: Configure CMake (Unix) | |
| if: runner.os != 'Windows' | |
| run: | | |
| cmake -B build \ | |
| -DSPIRV_BUILD_FUZZER=OFF \ | |
| -DSPIRV_USE_RUST_FFI=ON \ | |
| -DCMAKE_BUILD_TYPE=Release | |
| - name: Configure CMake (Windows) | |
| if: runner.os == 'Windows' | |
| run: | | |
| cmake -B build -DSPIRV_BUILD_FUZZER=OFF -DSPIRV_USE_RUST_FFI=ON | |
| - name: Build C++ with Rust FFI (Unix) | |
| if: runner.os != 'Windows' | |
| run: cmake --build build --config Release -j $(nproc 2>/dev/null || sysctl -n hw.ncpu) | |
| - name: Build C++ with Rust FFI (Windows) | |
| if: runner.os == 'Windows' | |
| run: cmake --build build --config Release | |
| - name: Run C++ tests (Unix) | |
| if: runner.os != 'Windows' | |
| working-directory: build | |
| run: ctest --output-on-failure -C Release -j $(nproc 2>/dev/null || sysctl -n hw.ncpu) | |
| - name: Run C++ tests (Windows) | |
| if: runner.os == 'Windows' | |
| working-directory: build | |
| run: ctest --output-on-failure -C Release | |
| # Clippy and format checks | |
| rust-lint: | |
| name: Rust Lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: '0' | |
| - name: Download SPIRV-Headers | |
| run: python3 utils/git-sync-deps | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: clippy, rustfmt | |
| - name: Cache Cargo | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/bin/ | |
| ~/.cargo/registry/index/ | |
| ~/.cargo/registry/cache/ | |
| ~/.cargo/git/db/ | |
| rust/target/ | |
| key: ${{ runner.os }}-cargo-lint-${{ hashFiles('rust/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo-lint- | |
| - name: Check formatting | |
| working-directory: rust | |
| run: cargo fmt --all -- --check | |
| - name: Run Clippy | |
| working-directory: rust | |
| # Exclude spirv-tools-ffi which requires C++ build (tested in rust-ffi-tests job) | |
| # Lint configuration is in rust/Cargo.toml [workspace.lints.clippy] | |
| run: cargo clippy --workspace --exclude spirv-tools-ffi --all-targets -- -D warnings |