Skip to content

Run cargo fmt on entire workspace #2

Run cargo fmt on entire workspace

Run cargo fmt on entire workspace #2

Workflow file for this run

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
run: cargo build --workspace
- name: Run Rust tests
working-directory: rust
run: cargo test --workspace
# 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
# Allow some lints that would require significant refactoring
run: |
cargo clippy --workspace --all-targets -- \
-D warnings \
-A clippy::result_large_err \
-A clippy::too_many_arguments \
-A clippy::type_complexity \
-A clippy::collapsible_if \
-A clippy::manual_is_multiple_of \
-A clippy::derivable_impls