Add platform matrix test suite for hashc tests
#1991
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 | ||
| on: | ||
| push: | ||
| branches: [main] | ||
| paths: | ||
| - "**.rs" | ||
| - "**/Cargo.toml" | ||
| - "**/Cargo.lock" | ||
| - ".github/workflows/rust.yml" | ||
| - "rust-toolchain.toml" | ||
| pull_request: | ||
| branches: [main] | ||
| paths: | ||
| - "**.rs" | ||
| - "**/Cargo.toml" | ||
| - "**/Cargo.lock" | ||
| - ".github/workflows/rust.yml" | ||
| - "rust-toolchain.toml" | ||
| env: | ||
| CARGO_TERM_COLOR: always | ||
| jobs: | ||
| # Fast checks that don't require LLVM (run first for quick feedback) | ||
| format_and_lint: | ||
| runs-on: ubuntu-latest | ||
| name: Format and Clippy (quick check) | ||
| steps: | ||
| - name: Checkout source code | ||
| uses: actions/checkout@v4 | ||
| - name: Install Rust nightly | ||
| run: | | ||
| rustup toolchain install nightly | ||
| rustup component add clippy --toolchain nightly | ||
| rustup component add rustfmt --toolchain nightly | ||
| rustup default nightly | ||
| - name: Dependency caching | ||
| uses: Swatinem/rust-cache@v2 | ||
| with: | ||
| # Use separate cache for quick checks | ||
| shared-key: "format-lint" | ||
| - name: Check formatting | ||
| run: cargo fmt --all -- --check | ||
| - name: Run clippy (without LLVM features) | ||
| # This runs clippy without building LLVM-dependent code for fast feedback | ||
| # Full clippy with LLVM runs in the test job | ||
| run: cargo clippy --all --no-deps -- -D warnings | ||
| continue-on-error: true | ||
| # Full build and test matrix across platforms | ||
| build_and_test: | ||
| runs-on: ${{ matrix.os }} | ||
| name: Test on ${{ matrix.os }} (${{ matrix.arch }}) | ||
| # Only run tests after formatting passes | ||
| needs: format_and_lint | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| # Linux x64 | ||
| - os: ubuntu-latest | ||
| arch: x64 | ||
| target: x86_64-unknown-linux-gnu | ||
| rustflags: "-C link-arg=-lc++ -C link-arg=-lc++abi" | ||
| # Linux ARM64 | ||
| - os: ubuntu-latest-arm64 | ||
| arch: arm64 | ||
| target: aarch64-unknown-linux-gnu | ||
| rustflags: "-C link-arg=-lc++ -C link-arg=-lc++abi" | ||
| # macOS x64 (Intel) | ||
| - os: macos-13 | ||
| arch: x64 | ||
| target: x86_64-apple-darwin | ||
| rustflags: "-C link-arg=-lc++" | ||
| # macOS ARM64 (Apple Silicon) | ||
| - os: macos-latest | ||
| arch: arm64 | ||
| target: aarch64-apple-darwin | ||
| rustflags: "-C link-arg=-lc++" | ||
| env: | ||
| RUSTFLAGS: ${{ matrix.rustflags }} | ||
| steps: | ||
| - name: Checkout source code | ||
| uses: actions/checkout@v4 | ||
| - name: Cache LLVM (Linux) | ||
| if: runner.os == 'Linux' | ||
| id: cache-llvm | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: ./llvm | ||
| key: llvm-20-${{ matrix.os }}-${{ matrix.arch }} | ||
| - name: Install LLVM (Linux) | ||
| if: runner.os == 'Linux' | ||
| uses: KyleMayes/install-llvm-action@v2.0.8 | ||
| with: | ||
| version: "20.1.8" | ||
| cached: ${{ steps.cache-llvm.outputs.cache-hit }} | ||
| - name: Set LLVM_PATH (Linux) | ||
| if: runner.os == 'Linux' | ||
| run: echo "LLVM_PATH is already set by install-llvm-action: $LLVM_PATH" | ||
| - name: Install LLVM (macOS) | ||
| if: runner.os == 'macOS' | ||
| run: | | ||
| brew install llvm@20 | ||
| echo "LLVM_PATH=$(brew --prefix llvm@20)" >> $GITHUB_ENV | ||
| - name: Install Rust nightly | ||
| run: | | ||
| rustup toolchain install nightly | ||
| rustup component add clippy --toolchain nightly | ||
| rustup default nightly | ||
| rustup target add ${{ matrix.target }} | ||
| - name: Dependency caching | ||
| uses: Swatinem/rust-cache@v2 | ||
| with: | ||
| # Separate cache per platform | ||
| shared-key: ${{ matrix.os }}-${{ matrix.arch }} | ||
| - name: Install dependencies (Ubuntu) | ||
| if: runner.os == 'Linux' | ||
| # @@Dumbness: we need to install `libtinfo5` because of: | ||
| # - https://github.com/hash-org/hashc/actions/runs/9634436024/job/26570084536 | ||
| run: | | ||
| wget http://security.ubuntu.com/ubuntu/pool/universe/n/ncurses/libtinfo5_6.3-2ubuntu0.1_amd64.deb | ||
| sudo apt install -y ./libtinfo5_6.3-2ubuntu0.1_amd64.deb | ||
| # Install libc++ which is required when LLVM is built with libc++ | ||
| sudo apt-get update | ||
| sudo apt-get install -y libc++-dev libc++abi-dev | ||
| - name: Verify LLVM installation | ||
| run: | | ||
| echo "LLVM_PATH: $LLVM_PATH" | ||
| $LLVM_PATH/bin/llvm-config --version | ||
| - name: Run tests | ||
| run: LLVM_SYS_201_PREFIX=$LLVM_PATH cargo test --all --verbose | ||
| - name: Run clippy (full check with LLVM) | ||
| run: LLVM_SYS_201_PREFIX=$LLVM_PATH cargo clippy --all -- -D warnings | ||