Skip to content

Commit 1e586d5

Browse files
andygroveclaude
andcommitted
build: optimize CI cache usage and add fast lint gate
This PR addresses cache storage approaching its 10GB limit by: 1. Cache optimization (saves ~2+ GB): - Remove Java version from cargo cache key (Rust target is JDK-independent) - Use actions/cache/restore + actions/cache/save pattern - Only save cache on main branch, not on PRs 2. Reduce Rust test matrix: - Consolidate from 2 jobs (Java 11 + Java 17) to 1 job (Java 17) - Rust code is JDK-independent, so no coverage lost 3. Add fast lint gate (~30 seconds): - New lint job runs cargo fmt --check before expensive builds - build-native and linux-test-rust depend on lint passing - Fail fast on formatting errors instead of waiting 5-10 minutes - macOS lint runs on ubuntu-latest for cost efficiency Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent f538424 commit 1e586d5

4 files changed

Lines changed: 86 additions & 23 deletions

File tree

.github/actions/rust-test/action.yaml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,7 @@ description: "Run Rust tests"
2121
runs:
2222
using: "composite"
2323
steps:
24-
- name: Check Cargo fmt
25-
shell: bash
26-
run: |
27-
cd native
28-
cargo fmt --all -- --check --color=never
24+
# Note: cargo fmt check is now handled by the lint job that gates this workflow
2925

3026
- name: Check Cargo clippy
3127
shell: bash

.github/workflows/pr_build_linux.yml

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,23 @@ env:
4747

4848
jobs:
4949

50+
# Fast lint check - gates all other jobs
51+
lint:
52+
name: Lint
53+
runs-on: ubuntu-latest
54+
container:
55+
image: amd64/rust
56+
steps:
57+
- uses: actions/checkout@v6
58+
59+
- name: Check Rust formatting
60+
run: |
61+
rustup component add rustfmt
62+
cd native && cargo fmt --all -- --check
63+
5064
# Build native library once and share with all test jobs
5165
build-native:
66+
needs: lint
5267
name: Build Native Library
5368
runs-on: ubuntu-latest
5469
container:
@@ -62,8 +77,8 @@ jobs:
6277
rust-version: ${{ env.RUST_VERSION }}
6378
jdk-version: 17 # JDK only needed for common module proto generation
6479

65-
- name: Cache Cargo
66-
uses: actions/cache@v4
80+
- name: Restore Cargo cache
81+
uses: actions/cache/restore@v4
6782
with:
6883
path: |
6984
~/.cargo/registry
@@ -87,15 +102,21 @@ jobs:
87102
path: native/target/ci/libcomet.so
88103
retention-days: 1
89104

105+
- name: Save Cargo cache
106+
uses: actions/cache/save@v4
107+
if: github.ref == 'refs/heads/main'
108+
with:
109+
path: |
110+
~/.cargo/registry
111+
~/.cargo/git
112+
native/target
113+
key: ${{ runner.os }}-cargo-ci-${{ hashFiles('native/**/Cargo.lock', 'native/**/Cargo.toml') }}
114+
90115
# Run Rust tests (runs in parallel with build-native, uses debug builds)
91116
linux-test-rust:
92-
strategy:
93-
matrix:
94-
os: [ubuntu-latest]
95-
java_version: [11, 17]
96-
fail-fast: false
97-
name: ${{ matrix.os }}/java ${{ matrix.java_version }}-rust
98-
runs-on: ${{ matrix.os }}
117+
needs: lint
118+
name: ubuntu-latest/rust-test
119+
runs-on: ubuntu-latest
99120
container:
100121
image: amd64/rust
101122
steps:
@@ -105,22 +126,33 @@ jobs:
105126
uses: ./.github/actions/setup-builder
106127
with:
107128
rust-version: ${{ env.RUST_VERSION }}
108-
jdk-version: ${{ matrix.java_version }}
129+
jdk-version: 17
109130

110-
- name: Cache Cargo
111-
uses: actions/cache@v4
131+
- name: Restore Cargo cache
132+
uses: actions/cache/restore@v4
112133
with:
113134
path: |
114135
~/.cargo/registry
115136
~/.cargo/git
116137
native/target
117-
key: ${{ runner.os }}-cargo-debug-java${{ matrix.java_version }}-${{ hashFiles('native/**/Cargo.lock', 'native/**/Cargo.toml') }}
138+
# Note: Java version intentionally excluded - Rust target is JDK-independent
139+
key: ${{ runner.os }}-cargo-debug-${{ hashFiles('native/**/Cargo.lock', 'native/**/Cargo.toml') }}
118140
restore-keys: |
119-
${{ runner.os }}-cargo-debug-java${{ matrix.java_version }}-
141+
${{ runner.os }}-cargo-debug-
120142
121143
- name: Rust test steps
122144
uses: ./.github/actions/rust-test
123145

146+
- name: Save Cargo cache
147+
uses: actions/cache/save@v4
148+
if: github.ref == 'refs/heads/main'
149+
with:
150+
path: |
151+
~/.cargo/registry
152+
~/.cargo/git
153+
native/target
154+
key: ${{ runner.os }}-cargo-debug-${{ hashFiles('native/**/Cargo.lock', 'native/**/Cargo.toml') }}
155+
124156
linux-test:
125157
needs: build-native
126158
strategy:

.github/workflows/pr_build_macos.yml

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,23 @@ env:
4747

4848
jobs:
4949

50+
# Fast lint check - gates all other jobs (runs on Linux for cost efficiency)
51+
lint:
52+
name: Lint
53+
runs-on: ubuntu-latest
54+
container:
55+
image: amd64/rust
56+
steps:
57+
- uses: actions/checkout@v6
58+
59+
- name: Check Rust formatting
60+
run: |
61+
rustup component add rustfmt
62+
cd native && cargo fmt --all -- --check
63+
5064
# Build native library once and share with all test jobs
5165
build-native:
66+
needs: lint
5267
name: Build Native Library (macOS)
5368
runs-on: macos-14
5469
steps:
@@ -62,8 +77,8 @@ jobs:
6277
jdk-architecture: aarch64
6378
protoc-architecture: aarch_64
6479

65-
- name: Cache Cargo
66-
uses: actions/cache@v4
80+
- name: Restore Cargo cache
81+
uses: actions/cache/restore@v4
6782
with:
6883
path: |
6984
~/.cargo/registry
@@ -87,6 +102,16 @@ jobs:
87102
path: native/target/ci/libcomet.dylib
88103
retention-days: 1
89104

105+
- name: Save Cargo cache
106+
uses: actions/cache/save@v4
107+
if: github.ref == 'refs/heads/main'
108+
with:
109+
path: |
110+
~/.cargo/registry
111+
~/.cargo/git
112+
native/target
113+
key: ${{ runner.os }}-cargo-ci-${{ hashFiles('native/**/Cargo.lock', 'native/**/Cargo.toml') }}
114+
90115
macos-aarch64-test:
91116
needs: build-native
92117
strategy:

.github/workflows/spark_sql_test.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ jobs:
6868
rust-version: ${{ env.RUST_VERSION }}
6969
jdk-version: 17
7070

71-
- name: Cache Cargo
72-
uses: actions/cache@v4
71+
- name: Restore Cargo cache
72+
uses: actions/cache/restore@v4
7373
with:
7474
path: |
7575
~/.cargo/registry
@@ -91,6 +91,16 @@ jobs:
9191
path: native/target/ci/libcomet.so
9292
retention-days: 1
9393

94+
- name: Save Cargo cache
95+
uses: actions/cache/save@v4
96+
if: github.ref == 'refs/heads/main'
97+
with:
98+
path: |
99+
~/.cargo/registry
100+
~/.cargo/git
101+
native/target
102+
key: ${{ runner.os }}-cargo-ci-${{ hashFiles('native/**/Cargo.lock', 'native/**/Cargo.toml') }}
103+
94104
spark-sql-auto-scan:
95105
needs: build-native
96106
strategy:

0 commit comments

Comments
 (0)