diff --git a/.github/workflows/rust-ci.yml b/.github/workflows/rust-ci.yml index f9a6d5bd5..8edb432bb 100644 --- a/.github/workflows/rust-ci.yml +++ b/.github/workflows/rust-ci.yml @@ -3,7 +3,9 @@ name: Rust CI on: push: branches: - - '**' + - master + - main + - llvm18 pull_request: branches: - '**' @@ -26,6 +28,7 @@ jobs: - name: Setup sccache if: github.event_name != 'release' && github.event_name != 'workflow_dispatch' uses: mozilla-actions/sccache-action@v0.0.9 + - name: Configure sccache if: github.event_name != 'release' && github.event_name != 'workflow_dispatch' run: | @@ -33,10 +36,13 @@ jobs: echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - uses: actions/checkout@v4 + - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable + - name: Install cargo-machete run: cargo install cargo-machete + - name: Run cargo machete run: cargo machete @@ -45,19 +51,37 @@ jobs: needs: [format, machete] steps: - uses: actions/checkout@v4 + - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable with: components: clippy targets: x86_64-pc-windows-gnu + - name: Setup sccache if: github.event_name != 'release' && github.event_name != 'workflow_dispatch' uses: mozilla-actions/sccache-action@v0.0.9 + - name: Configure sccache if: github.event_name != 'release' && github.event_name != 'workflow_dispatch' run: | echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV + + - name: "Cache cargo" + id: cache-cargo + uses: "actions/cache@v4" + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + save-always: true + key: ${{ runner.os }}-${{runner.arch}}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: ${{ runner.os }}-${{runner.arch}}-cargo- + - name: Install LLVM 18 and Windows cross-compilation tools run: | wget https://apt.llvm.org/llvm.sh @@ -74,18 +98,22 @@ jobs: # Verify installation which llvm-lib llvm-lib --version + - name: Set LLVM environment variables run: | echo "LLVM_SYS_181_PREFIX=/usr/lib/llvm-18" >> $GITHUB_ENV echo "CLANG_PATH=/usr/lib/llvm-18/bin/clang" >> $GITHUB_ENV echo "PATH=/usr/lib/llvm-18/bin:$PATH" >> $GITHUB_ENV echo "RUST_BACKTRACE=1" >> $GITHUB_ENV + - name: Install build dependencies run: | sudo apt-get update sudo apt-get install -y build-essential + - name: Build run: cargo build --release + - name: Show sccache stats if: github.event_name != 'release' && github.event_name != 'workflow_dispatch' shell: bash @@ -93,6 +121,7 @@ jobs: # someone has to fix the errors # - name: Run Clippy # run: cargo clippy -- -D warnings + - name: Run tests run: cargo test --release @@ -129,19 +158,36 @@ jobs: mkdir -p .cargo echo '[net]' > .cargo/config.toml echo 'git-fetch-with-cli = true' >> .cargo/config.toml + - name: Cache sccache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.cache/sccache - key: ${{ runner.os }}-sccache-${{ hashFiles('**/Cargo.lock') }} + key: ${{ runner.os }}-${{runner.arch}}-sccache-${{ hashFiles('**/Cargo.lock') }} restore-keys: | - ${{ runner.os }}-sccache- + ${{ runner.os }}-${{runner.arch}}-sccache- + - name: Locate and configure sccache shell: msys2 {0} run: | # export SCCACHE_PATH=$(which sccache) # echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV echo "RUSTC_WRAPPER=${SCCACHE_PATH}" >> $GITHUB_ENV + + - name: "Cache cargo" + id: cache-cargo + uses: "actions/cache@v4" + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + save-always: true + key: ${{ runner.os }}-${{runner.arch}}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: ${{ runner.os }}-${{runner.arch}}-cargo- + - name: Run cargo shell: msys2 {0} run: cargo build --release @@ -149,6 +195,7 @@ jobs: # if: github.event_name != 'release' && github.event_name != 'workflow_dispatch' # shell: msys2 {0} # run: $SCCACHE_PATH --show-stats + - name: Run tests shell: msys2 {0} run: cargo test --release @@ -158,25 +205,50 @@ jobs: fail-fast: false matrix: include: - - arch: arm64 - macos: 13 - - arch: x86_64 - macos: 13 - runs-on: macos-${{ matrix.macos }} + # Intel + - image: macos-15-intel + # ARM64 + - image: macos-15 + - image: macos-14 + + runs-on: ${{ matrix.image }} + needs: [format, machete] steps: - name: Checkout uses: actions/checkout@v4 - - name: Install pkg-config with Homebrew + - name: Install dependencies with Homebrew + uses: tecolicom/actions-use-homebrew-tools@v1 + with: + tools: pkg-config sccache llvm@18 + cache: yes + + - name: Set LLVM environment variables run: | - brew install pkg-config mingw-w64 sccache llvm - echo "$(brew --prefix llvm)/bin" >> $GITHUB_PATH + echo "$(brew --prefix llvm@18)/bin" >> $GITHUB_PATH + echo "LLVM_SYS_181_PREFIX=$(brew --prefix llvm@18)" >> $GITHUB_ENV + echo "RUST_BACKTRACE=1" >> $GITHUB_ENV + echo "RUN_DEV_TESTS=1" >> $GITHUB_ENV + - name: sccache setup run: | # echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV echo "RUSTC_WRAPPER=$(which sccache)" >> $GITHUB_ENV - + - name: "Cache cargo" + id: cache-cargo + uses: "actions/cache@v4" + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + save-always: true + key: ${{ runner.os }}-${{runner.arch}}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: ${{ runner.os }}-${{runner.arch}}}-cargo- + - name: Build run: cargo build --release