From b917a36e6b8b2995e68bfb485e38a7c9cbbf8c2b Mon Sep 17 00:00:00 2001 From: beinan Date: Wed, 4 Mar 2026 00:23:13 +0000 Subject: [PATCH] ci: optimize build times with shared caching and streamlined workflows Apply learnings from lance-graph#143 to dramatically improve CI performance: 1. Shared Rust Cache - Use rust-cache@v2 with shared-key across all workflows to prevent duplicate compilation of dependencies 2. Remove Nightly Toolchain - Test only on stable to reduce CI time by ~50% and prevent nightly breakage from blocking PRs 3. Standardize CARGO_INCREMENTAL=0 - Add to all workflows for consistent CI environment and avoid wasted incremental artifacts 4. Remove CARGO_TARGET_DIR - Let rust-cache handle target directory management for better cache efficiency Expected impact: Faster builds through shared dependency cache, reduced test matrix, and optimized caching strategy. Co-Authored-By: Claude Opus 4.6 --- .github/workflows/python-test.yml | 30 +++++++++++------------------- .github/workflows/rust-test.yml | 16 +++++----------- .github/workflows/style.yml | 6 +++++- 3 files changed, 21 insertions(+), 31 deletions(-) diff --git a/.github/workflows/python-test.yml b/.github/workflows/python-test.yml index 606f51c..b3a0e16 100644 --- a/.github/workflows/python-test.yml +++ b/.github/workflows/python-test.yml @@ -16,7 +16,7 @@ concurrency: env: CARGO_TERM_COLOR: always RUSTFLAGS: "-C debuginfo=0 -C codegen-units=16" - CARGO_TARGET_DIR: ${{ github.workspace }}/.cargo-target + CARGO_INCREMENTAL: "0" jobs: build-wheel: @@ -32,16 +32,12 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1 with: cache: false - - name: Cache Rust build (shared) - uses: actions/cache@v4 + - uses: Swatinem/rust-cache@v2 with: - path: | - .cargo-target - ~/.cargo/registry - ~/.cargo/git - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-cargo- + shared-key: "lance-context-deps" + workspaces: | + crates/lance-context-core + python - name: Install dependencies run: | sudo apt update @@ -89,16 +85,12 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1 with: cache: false - - name: Cache Rust build (shared) - uses: actions/cache@v4 + - uses: Swatinem/rust-cache@v2 with: - path: | - .cargo-target - ~/.cargo/registry - ~/.cargo/git - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-cargo- + shared-key: "lance-context-deps" + workspaces: | + crates/lance-context-core + python - name: Install dependencies run: | sudo apt update diff --git a/.github/workflows/rust-test.yml b/.github/workflows/rust-test.yml index 87d70d8..9f9b0af 100644 --- a/.github/workflows/rust-test.yml +++ b/.github/workflows/rust-test.yml @@ -19,7 +19,6 @@ env: RUSTFLAGS: "-C debuginfo=1" RUST_BACKTRACE: "1" CARGO_INCREMENTAL: "0" - CARGO_TARGET_DIR: ${{ github.workspace }}/.cargo-target jobs: test: @@ -29,23 +28,18 @@ jobs: matrix: toolchain: - stable - - nightly steps: - uses: actions/checkout@v4 - name: Setup rust toolchain run: | rustup toolchain install ${{ matrix.toolchain }} rustup default ${{ matrix.toolchain }} - - name: Cache Rust build (shared) - uses: actions/cache@v4 + - uses: Swatinem/rust-cache@v2 with: - path: | - .cargo-target - ~/.cargo/registry - ~/.cargo/git - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-cargo- + shared-key: "lance-context-deps" + workspaces: | + crates/lance-context-core + python - name: Install dependencies run: | sudo apt update diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index 8918a76..6266fa1 100644 --- a/.github/workflows/style.yml +++ b/.github/workflows/style.yml @@ -17,6 +17,7 @@ concurrency: env: CARGO_TERM_COLOR: always RUSTFLAGS: "-C debuginfo=1" + CARGO_INCREMENTAL: "0" jobs: format: @@ -37,7 +38,10 @@ jobs: - uses: actions/checkout@v4 - uses: Swatinem/rust-cache@v2 with: - workspaces: . + shared-key: "lance-context-deps" + workspaces: | + crates/lance-context-core + python - name: Install dependencies run: | sudo apt update