From c89782f397059dfd70b7999c1f148996a1f3bd80 Mon Sep 17 00:00:00 2001 From: Alexander Fedotov Date: Sun, 14 Dec 2025 09:54:40 +0000 Subject: [PATCH 1/2] Add platform matrix test suite for `hashc` tests - Extract linting and formatting to a separate workflow. - Add linux and macos platform matrix to `test_and_build` workflow. --- .github/workflows/rust.yml | 121 +++++++++++++++++++++++++++++++------ 1 file changed, 103 insertions(+), 18 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index f0364fb73..2922d4215 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -3,52 +3,137 @@ 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 - # Link against libc++ which is required when LLVM is built with libc++ - RUSTFLAGS: "-C link-arg=-lc++ -C link-arg=-lc++abi" 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.distro }}"] - name: Build on ${{ matrix.distro }} ${{ matrix.arch }} + 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: - - arch: x64 - distro: ubuntu-latest + # 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 + - name: Cache LLVM (Linux) + if: runner.os == 'Linux' id: cache-llvm uses: actions/cache@v4 with: path: ./llvm - key: llvm-20 + key: llvm-20-${{ matrix.os }}-${{ matrix.arch }} - - name: Install LLVM + - 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 component add rustfmt --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: LLVM location + - 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: | @@ -57,14 +142,14 @@ jobs: # 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 - echo $LLVM_PATH + + - 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" + run: LLVM_SYS_201_PREFIX=$LLVM_PATH cargo test --all --verbose - - name: Run clippy - run: "LLVM_SYS_201_PREFIX=$LLVM_PATH cargo clippy --all -- -D warnings" - - - name: Check formatting - run: "cargo fmt --all -- --check" + - name: Run clippy (full check with LLVM) + run: LLVM_SYS_201_PREFIX=$LLVM_PATH cargo clippy --all -- -D warnings From a74cd45c2e12ea9acc4564c721eb07ba93fa0583 Mon Sep 17 00:00:00 2001 From: Alexander Fedotov Date: Mon, 15 Dec 2025 09:19:28 +0000 Subject: [PATCH 2/2] fix --- .github/workflows/rust.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 2922d4215..22fa69903 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -109,10 +109,6 @@ jobs: 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: |