Make llvm not default for Rust #257
Workflow file for this run
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 test / linting | |
| env: | |
| TRIGGER_ON_PR_PUSH: true # Set to true to enable triggers on PR pushes | |
| RUSTFLAGS: -C debuginfo=0 | |
| RUST_BACKTRACE: 1 | |
| on: | |
| push: | |
| branches: [ "master", "development", "dev" ] | |
| paths: | |
| - 'crates/**' | |
| - 'examples/**' | |
| - 'julia/pecos-julia-ffi/**' | |
| - 'Cargo.toml' | |
| - '.github/workflows/rust-test.yml' | |
| - '.pre-commit-config.yaml' | |
| pull_request: | |
| branches: [ "master", "development", "dev" ] | |
| paths: | |
| - 'crates/**' | |
| - 'examples/**' | |
| - 'julia/pecos-julia-ffi/**' | |
| - 'Cargo.toml' | |
| - '.github/workflows/rust-test.yml' | |
| - '.pre-commit-config.yaml' | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| rust-lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust (for local testing) | |
| run: | | |
| curl https://sh.rustup.rs -sSf | sh -s -- -y | |
| echo "$HOME/.cargo/bin" >> $GITHUB_PATH | |
| export PATH="$HOME/.cargo/bin:$PATH" | |
| - name: Set up Rust | |
| run: rustup override set stable && rustup update | |
| - name: Cache Rust | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| save-if: ${{ github.ref_name == 'master' || github.ref_name == 'development' || github.ref_name == 'dev' }} | |
| - name: Install LLVM 14.0.6 using pecos-llvm | |
| run: | | |
| echo "Installing LLVM using pecos-llvm-utils..." | |
| cargo run -p pecos-llvm-utils --bin pecos-llvm --release -- install | |
| echo "Setting LLVM environment variables..." | |
| export PECOS_LLVM=$(cargo run -p pecos-llvm-utils --bin pecos-llvm --release -- find 2>/dev/null) | |
| export LLVM_SYS_140_PREFIX="$PECOS_LLVM" | |
| echo "PECOS_LLVM=$PECOS_LLVM" >> $GITHUB_ENV | |
| echo "LLVM_SYS_140_PREFIX=$LLVM_SYS_140_PREFIX" >> $GITHUB_ENV | |
| echo "Verifying LLVM installation..." | |
| cargo run -p pecos-llvm-utils --bin pecos-llvm --release -- check | |
| - name: Install rustfmt | |
| run: rustup component add rustfmt | |
| - name: Check formatting | |
| run: cargo fmt --all -- --check | |
| - name: Install clippy | |
| run: rustup component add clippy | |
| - name: Run clippy | |
| run: | | |
| echo "Running clippy with all features (including LLVM)..." | |
| cargo clippy --workspace --exclude pecos --exclude pecos-quest --all-targets --all-features -- -D warnings | |
| echo "Running clippy on pecos with all non-GPU features..." | |
| cargo clippy -p pecos --all-targets --features "llvm,selene,qasm,phir,all-simulators" -- -D warnings | |
| echo "Running clippy on pecos-quest with CPU features only..." | |
| cargo clippy -p pecos-quest --all-targets --features "cpu" -- -D warnings | |
| rust-lint-no-llvm: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust (for local testing) | |
| run: | | |
| curl https://sh.rustup.rs -sSf | sh -s -- -y | |
| echo "$HOME/.cargo/bin" >> $GITHUB_PATH | |
| export PATH="$HOME/.cargo/bin:$PATH" | |
| - name: Set up Rust | |
| run: rustup override set stable && rustup update | |
| - name: Cache Rust | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| save-if: ${{ github.ref_name == 'master' || github.ref_name == 'development' || github.ref_name == 'dev' }} | |
| - name: Install rustfmt | |
| run: rustup component add rustfmt | |
| - name: Check formatting | |
| run: cargo fmt --all -- --check | |
| - name: Install clippy | |
| run: rustup component add clippy | |
| - name: Run clippy without LLVM features | |
| run: | | |
| echo "Running clippy without LLVM features..." | |
| # Use --manifest-path to avoid workspace resolution pulling in LLVM dependencies | |
| echo "Testing pecos-core..." | |
| cd crates/pecos-core && cargo clippy --all-targets -- -D warnings && cd ../.. | |
| echo "Testing pecos-engines..." | |
| cd crates/pecos-engines && cargo clippy --all-targets -- -D warnings && cd ../.. | |
| echo "Testing pecos-qsim..." | |
| cd crates/pecos-qsim && cargo clippy --all-targets -- -D warnings && cd ../.. | |
| echo "Testing pecos-programs..." | |
| cd crates/pecos-programs && cargo clippy --all-targets -- -D warnings && cd ../.. | |
| echo "Testing pecos-rng..." | |
| cd crates/pecos-rng && cargo clippy --all-targets -- -D warnings && cd ../.. | |
| echo "Testing pecos-qasm..." | |
| cd crates/pecos-qasm && cargo clippy --all-targets -- -D warnings && cd ../.. | |
| echo "Testing pecos-phir-json..." | |
| cd crates/pecos-phir-json && cargo clippy --all-targets -- -D warnings && cd ../.. | |
| echo "Testing pecos-qis-ffi-types..." | |
| cd crates/pecos-qis-ffi-types && cargo clippy --all-targets -- -D warnings && cd ../.. | |
| # Test the main pecos crate without default features | |
| echo "Testing pecos without default features..." | |
| cd crates/pecos && cargo clippy --all-targets --no-default-features -- -D warnings && cd ../.. | |
| # Note: Skipping crates that require LLVM: | |
| # - pecos-hugr-qis (HUGR to LLVM compiler) | |
| # - pecos-qis-core (has inkwell dependency) | |
| # - pecos-qis-selene (depends on pecos-qis-core with llvm feature) | |
| # - pecos-phir (when hugr feature is enabled, depends on tket-qsystem which pulls in LLVM) | |
| echo "Successfully tested core crates without LLVM!" | |
| pre-commit: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.x' | |
| - name: Install pre-commit | |
| run: pip install pre-commit | |
| - name: Run pre-commit | |
| run: pre-commit run --all-files --show-diff-on-failure | |
| rust-test: | |
| needs: [pre-commit, rust-lint] | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust (for local testing) | |
| if: matrix.os == 'windows-latest' | |
| run: | | |
| curl -sSf -o rustup-init.exe https://win.rustup.rs | |
| ./rustup-init.exe -y --default-toolchain stable --profile minimal | |
| echo "$HOME\.cargo\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | |
| $env:Path += ";$HOME\.cargo\bin" | |
| - name: Install Rust (for local testing) | |
| if: matrix.os != 'windows-latest' | |
| run: | | |
| curl https://sh.rustup.rs -sSf | sh -s -- -y | |
| echo "$HOME/.cargo/bin" >> $GITHUB_PATH | |
| export PATH="$HOME/.cargo/bin:$PATH" | |
| - name: Set up Rust | |
| run: rustup show | |
| - name: Cache Rust | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| save-if: ${{ github.ref_name == 'master' || github.ref_name == 'development' || github.ref_name == 'dev' }} | |
| - name: Install LLVM 14.0.6 using pecos-llvm (Unix) | |
| if: matrix.os != 'windows-latest' | |
| run: | | |
| echo "Installing LLVM using pecos-llvm-utils..." | |
| cargo run -p pecos-llvm-utils --bin pecos-llvm --release -- install | |
| echo "Setting LLVM environment variables..." | |
| export PECOS_LLVM=$(cargo run -p pecos-llvm-utils --bin pecos-llvm --release -- find 2>/dev/null) | |
| export LLVM_SYS_140_PREFIX="$PECOS_LLVM" | |
| echo "PECOS_LLVM=$PECOS_LLVM" >> $GITHUB_ENV | |
| echo "LLVM_SYS_140_PREFIX=$LLVM_SYS_140_PREFIX" >> $GITHUB_ENV | |
| echo "Verifying LLVM installation..." | |
| cargo run -p pecos-llvm-utils --bin pecos-llvm --release -- check | |
| - name: Install LLVM 14.0.6 using pecos-llvm (Windows) | |
| if: matrix.os == 'windows-latest' | |
| shell: pwsh | |
| run: | | |
| Write-Host "Installing LLVM using pecos-llvm-utils..." | |
| cargo run -p pecos-llvm-utils --bin pecos-llvm --release -- install | |
| Write-Host "Setting LLVM environment variables..." | |
| $env:PECOS_LLVM = (cargo run -p pecos-llvm-utils --bin pecos-llvm --release -- find 2>$null) | |
| $env:LLVM_SYS_140_PREFIX = $env:PECOS_LLVM | |
| "PECOS_LLVM=$env:PECOS_LLVM" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
| "LLVM_SYS_140_PREFIX=$env:LLVM_SYS_140_PREFIX" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
| Write-Host "Verifying LLVM installation..." | |
| cargo run -p pecos-llvm-utils --bin pecos-llvm --release -- check | |
| - name: Set up Visual Studio environment on Windows | |
| if: matrix.os == 'windows-latest' | |
| uses: ilammy/msvc-dev-cmd@v1 | |
| with: | |
| arch: x64 | |
| - name: Compile tests (macOS) | |
| if: matrix.os == 'macos-latest' | |
| run: | | |
| # CRITICAL: Prevent Homebrew library paths from being used during linking | |
| # This fixes the "@rpath/libunwind.1.dylib" runtime error on macOS | |
| # Reference: https://github.com/rust-lang/rust/issues/135372 | |
| unset LIBRARY_PATH | |
| unset LD_LIBRARY_PATH | |
| unset DYLD_LIBRARY_PATH | |
| unset DYLD_FALLBACK_LIBRARY_PATH | |
| unset PKG_CONFIG_PATH | |
| export LIBRARY_PATH=/usr/lib | |
| echo "RUSTFLAGS: $RUSTFLAGS" | |
| cargo test --no-run --workspace --exclude pecos-quest --exclude pecos-decoders --features llvm | |
| cargo test --no-run -p pecos-quest --features cpu | |
| cargo test --no-run -p pecos-decoders --all-features | |
| - name: Compile tests (Linux/Windows) | |
| if: matrix.os != 'macos-latest' | |
| run: | | |
| cargo test --no-run --workspace --exclude pecos-quest --exclude pecos-decoders --features llvm | |
| cargo test --no-run -p pecos-quest --features cpu | |
| cargo test --no-run -p pecos-decoders --all-features | |
| - name: Run tests (macOS) | |
| if: matrix.os == 'macos-latest' | |
| run: | | |
| # CRITICAL: Prevent Homebrew library paths from being used during linking | |
| # This fixes the "@rpath/libunwind.1.dylib" runtime error on macOS | |
| # Reference: https://github.com/rust-lang/rust/issues/135372 | |
| unset LIBRARY_PATH | |
| unset LD_LIBRARY_PATH | |
| unset DYLD_LIBRARY_PATH | |
| unset DYLD_FALLBACK_LIBRARY_PATH | |
| unset PKG_CONFIG_PATH | |
| export LIBRARY_PATH=/usr/lib | |
| cargo test --workspace --exclude pecos-quest --exclude pecos-decoders --features llvm | |
| cargo test -p pecos-quest --features cpu | |
| cargo test -p pecos-decoders --all-features | |
| - name: Run tests (Linux) | |
| if: matrix.os == 'ubuntu-latest' | |
| run: | | |
| cargo test --workspace --exclude pecos-quest --exclude pecos-decoders --features llvm | |
| cargo test -p pecos-quest --features cpu | |
| cargo test -p pecos-decoders --all-features | |
| - name: Run tests (Windows) | |
| if: matrix.os == 'windows-latest' | |
| run: | | |
| # Run all non-doctest tests | |
| cargo test --workspace --exclude pecos-quest --exclude pecos-decoders --exclude pecos-rslib --features llvm --lib --bins --tests --examples | |
| cargo test -p pecos-quest --features cpu --lib --bins --tests --examples | |
| cargo test -p pecos-decoders --all-features --lib --bins --tests --examples | |
| # For Windows, we need to run doctests for the pecos crate specially | |
| # to ensure they run from the crate directory | |
| cd crates/pecos | |
| cargo test --doc --features llvm | |
| cd ../.. | |
| # Run doctests for other crates normally | |
| cargo test --workspace --exclude pecos-quest --exclude pecos-decoders --exclude pecos-rslib --exclude pecos --features llvm --doc | |
| cargo test -p pecos-quest --doc | |
| cargo test -p pecos-decoders --all-features --doc |