4646 RUST_VERSION : stable
4747
4848jobs :
49-
50- # Run Rust tests once per JDK version
49+
50+ # Build native library once and share with all test jobs
51+ build-native :
52+ name : Build Native Library
53+ runs-on : ubuntu-latest
54+ container :
55+ image : amd64/rust
56+ steps :
57+ - uses : actions/checkout@v6
58+
59+ - name : Setup Rust toolchain
60+ uses : ./.github/actions/setup-builder
61+ with :
62+ rust-version : ${{ env.RUST_VERSION }}
63+ jdk-version : 17 # JDK only needed for common module proto generation
64+
65+ - name : Cache Cargo
66+ uses : actions/cache@v4
67+ with :
68+ path : |
69+ ~/.cargo/registry
70+ ~/.cargo/git
71+ native/target
72+ key : ${{ runner.os }}-cargo-ci-${{ hashFiles('native/**/Cargo.lock', 'native/**/Cargo.toml') }}
73+ restore-keys : |
74+ ${{ runner.os }}-cargo-ci-
75+
76+ - name : Build native library (CI profile)
77+ run : |
78+ cd native
79+ # CI profile: same overflow behavior as release, but faster compilation
80+ # (no LTO, parallel codegen)
81+ cargo build --profile ci
82+
83+ - name : Upload native library
84+ uses : actions/upload-artifact@v4
85+ with :
86+ name : native-lib-linux
87+ path : native/target/ci/libcomet.so
88+ retention-days : 1
89+
90+ # Run Rust tests (runs in parallel with build-native, uses debug builds)
5191 linux-test-rust :
5292 strategy :
5393 matrix :
@@ -60,15 +100,29 @@ jobs:
60100 image : amd64/rust
61101 steps :
62102 - uses : actions/checkout@v6
103+
63104 - name : Setup Rust & Java toolchain
64105 uses : ./.github/actions/setup-builder
65106 with :
66- rust-version : ${{env.RUST_VERSION}}
107+ rust-version : ${{ env.RUST_VERSION }}
67108 jdk-version : ${{ matrix.java_version }}
109+
110+ - name : Cache Cargo
111+ uses : actions/cache@v4
112+ with :
113+ path : |
114+ ~/.cargo/registry
115+ ~/.cargo/git
116+ native/target
117+ key : ${{ runner.os }}-cargo-debug-java${{ matrix.java_version }}-${{ hashFiles('native/**/Cargo.lock', 'native/**/Cargo.toml') }}
118+ restore-keys : |
119+ ${{ runner.os }}-cargo-debug-java${{ matrix.java_version }}-
120+
68121 - name : Rust test steps
69122 uses : ./.github/actions/rust-test
70-
123+
71124 linux-test :
125+ needs : build-native
72126 strategy :
73127 matrix :
74128 os : [ubuntu-latest]
@@ -186,11 +240,31 @@ jobs:
186240
187241 steps :
188242 - uses : actions/checkout@v6
243+
189244 - name : Setup Rust & Java toolchain
190245 uses : ./.github/actions/setup-builder
191246 with :
192- rust-version : ${{env.RUST_VERSION}}
247+ rust-version : ${{ env.RUST_VERSION }}
193248 jdk-version : ${{ matrix.profile.java_version }}
249+
250+ - name : Download native library
251+ uses : actions/download-artifact@v4
252+ with :
253+ name : native-lib-linux
254+ # Download to release/ since Maven's -Prelease expects libcomet.so there
255+ path : native/target/release/
256+
257+ # Restore cargo registry cache (for any cargo commands that might run)
258+ - name : Cache Cargo registry
259+ uses : actions/cache@v4
260+ with :
261+ path : |
262+ ~/.cargo/registry
263+ ~/.cargo/git
264+ key : ${{ runner.os }}-cargo-registry-${{ hashFiles('native/**/Cargo.lock') }}
265+ restore-keys : |
266+ ${{ runner.os }}-cargo-registry-
267+
194268 - name : Java test steps
195269 uses : ./.github/actions/java-test
196270 with :
@@ -199,3 +273,4 @@ jobs:
199273 maven_opts : ${{ matrix.profile.maven_opts }}
200274 scan_impl : ${{ matrix.profile.scan_impl }}
201275 upload-test-reports : true
276+ skip-native-build : true
0 commit comments