-
Notifications
You must be signed in to change notification settings - Fork 273
build: build native library once and share across CI test jobs #3249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+230
−7
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,8 +46,48 @@ env: | |
| RUST_VERSION: stable | ||
|
|
||
| jobs: | ||
|
|
||
| # Run Rust tests once per JDK version | ||
|
|
||
| # Build native library once and share with all test jobs | ||
| build-native: | ||
| name: Build Native Library | ||
| runs-on: ubuntu-latest | ||
| container: | ||
| image: amd64/rust | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| - name: Setup Rust toolchain | ||
| uses: ./.github/actions/setup-builder | ||
| with: | ||
| rust-version: ${{ env.RUST_VERSION }} | ||
| jdk-version: 17 # JDK only needed for common module proto generation | ||
|
|
||
| - name: Cache Cargo | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: | | ||
| ~/.cargo/registry | ||
| ~/.cargo/git | ||
| native/target | ||
| key: ${{ runner.os }}-cargo-ci-${{ hashFiles('native/**/Cargo.lock', 'native/**/Cargo.toml') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-cargo-ci- | ||
|
|
||
| - name: Build native library (CI profile) | ||
| run: | | ||
| cd native | ||
| # CI profile: same overflow behavior as release, but faster compilation | ||
| # (no LTO, parallel codegen) | ||
| cargo build --profile ci | ||
|
|
||
| - name: Upload native library | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: native-lib-linux | ||
| path: native/target/ci/libcomet.so | ||
| retention-days: 1 | ||
|
|
||
| # Run Rust tests (runs in parallel with build-native, uses debug builds) | ||
| linux-test-rust: | ||
| strategy: | ||
| matrix: | ||
|
|
@@ -60,15 +100,29 @@ jobs: | |
| image: amd64/rust | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| - name: Setup Rust & Java toolchain | ||
| uses: ./.github/actions/setup-builder | ||
| with: | ||
| rust-version: ${{env.RUST_VERSION}} | ||
| rust-version: ${{ env.RUST_VERSION }} | ||
| jdk-version: ${{ matrix.java_version }} | ||
|
|
||
| - name: Cache Cargo | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: | | ||
| ~/.cargo/registry | ||
| ~/.cargo/git | ||
| native/target | ||
| key: ${{ runner.os }}-cargo-debug-java${{ matrix.java_version }}-${{ hashFiles('native/**/Cargo.lock', 'native/**/Cargo.toml') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-cargo-debug-java${{ matrix.java_version }}- | ||
|
|
||
| - name: Rust test steps | ||
| uses: ./.github/actions/rust-test | ||
|
|
||
| linux-test: | ||
| needs: build-native | ||
| strategy: | ||
| matrix: | ||
| os: [ubuntu-latest] | ||
|
|
@@ -186,11 +240,31 @@ jobs: | |
|
|
||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| - name: Setup Rust & Java toolchain | ||
| uses: ./.github/actions/setup-builder | ||
| with: | ||
| rust-version: ${{env.RUST_VERSION}} | ||
| rust-version: ${{ env.RUST_VERSION }} | ||
| jdk-version: ${{ matrix.profile.java_version }} | ||
|
|
||
| - name: Download native library | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: native-lib-linux | ||
| # Download to release/ since Maven's -Prelease expects libcomet.so there | ||
| path: native/target/release/ | ||
|
|
||
| # Restore cargo registry cache (for any cargo commands that might run) | ||
| - name: Cache Cargo registry | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: | | ||
| ~/.cargo/registry | ||
| ~/.cargo/git | ||
| key: ${{ runner.os }}-cargo-registry-${{ hashFiles('native/**/Cargo.lock') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-cargo-registry- | ||
|
|
||
| - name: Java test steps | ||
| uses: ./.github/actions/java-test | ||
| with: | ||
|
|
@@ -199,3 +273,4 @@ jobs: | |
| maven_opts: ${{ matrix.profile.maven_opts }} | ||
| scan_impl: ${{ matrix.profile.scan_impl }} | ||
| upload-test-reports: true | ||
| skip-native-build: true | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use
${{ runner.os }}-cargo-ci-generated bybuild-nativehere?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
linux-test-rustjob uses debug builds (cargo test) whilebuild-nativeuses the CI profile, so their native/target artifacts are incompatible. Sharing the same cache key would cause cache thrashing, where each job overwrites the other's compiled artifacts, if I'm understanding this correctly.