-
Notifications
You must be signed in to change notification settings - Fork 375
ci: reuse Linux native libraries across workflow runs #5976
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
Open
sunchao
wants to merge
8
commits into
apache:main
Choose a base branch
from
sunchao:dev/chao/codex/ci-native-cache-reuse
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
245eb56
ci: reuse Linux native libraries by validated build inputs
sunchao 9d7cbed
ci: trust the checked-out repository when fingerprinting native inputs
sunchao 5099e8c
ci: simplify native caching around the fixed CI toolchain
sunchao 9ecf8b0
ci: align native cache inputs with main cache warming
sunchao aff75ae
ci: align native cache selection with review feedback
sunchao bd4ee8a
ci: narrow native cache inputs and test routing
sunchao 1dc4bf3
ci: skip redundant native builds on main cache hits
sunchao 80296cb
ci: keep native caches limited to compiled targets
sunchao 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| name: Build or restore the Linux CI native library | ||
| description: 'Reuse an exact-input native library, otherwise build it with the CI profile' | ||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Pin native build flags | ||
| shell: bash | ||
| run: echo 'RUSTFLAGS=-Ctarget-cpu=x86-64-v3 -Clink-arg=-fuse-ld=bfd' >> "$GITHUB_ENV" | ||
|
|
||
| # Call after checkout and setup-builder. Compute once, before Cargo writes | ||
| # generated Rust files, and use the same keys for both restore and save. | ||
| - name: Fingerprint native build inputs | ||
| id: key | ||
| shell: bash | ||
| run: python3 dev/ci/native-cache-key.py --profile ci --github-output "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Restore native library cache | ||
| id: binary-cache | ||
| uses: actions/cache/restore@v6 | ||
| with: | ||
| path: native/target/ci/libcomet.so | ||
| key: ${{ steps.key.outputs.binary-key }} | ||
| # Main restores the incremental cache below, including libcomet.so. | ||
| # A lookup avoids downloading the same library separately. | ||
| lookup-only: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} | ||
|
|
||
| - name: Restore incremental Cargo cache | ||
| id: cargo-cache | ||
| if: steps.binary-cache.outputs.cache-hit != 'true' || (github.event_name == 'push' && github.ref == 'refs/heads/main') | ||
| uses: actions/cache/restore@v6 | ||
| with: | ||
| path: native/target | ||
| key: ${{ steps.key.outputs.source-key }} | ||
| restore-keys: ${{ steps.key.outputs.restore-prefix }} | ||
|
|
||
| - name: Build native library (CI profile) | ||
| if: steps.binary-cache.outputs.cache-hit != 'true' || (github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.cargo-cache.outputs.cache-hit != 'true') | ||
| shell: bash | ||
| run: | | ||
| cd native | ||
| # A library miss always builds, even on an exact incremental hit. | ||
| # Main also builds to populate a missing incremental entry; two exact | ||
| # hits already supply the library and leave neither cache to publish. | ||
| cargo build --locked --profile ci | ||
|
|
||
| - name: Save native library cache | ||
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.binary-cache.outputs.cache-hit != 'true' | ||
| uses: actions/cache/save@v6 | ||
| with: | ||
| path: native/target/ci/libcomet.so | ||
| key: ${{ steps.key.outputs.binary-key }} | ||
|
|
||
| - name: Save incremental Cargo cache | ||
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.cargo-cache.outputs.cache-hit != 'true' | ||
| uses: actions/cache/save@v6 | ||
| with: | ||
| path: native/target | ||
| key: ${{ steps.key.outputs.source-key }} | ||
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
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
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.
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.
This swaps a step-level
env:for a job-scoped one. The value is right: all four callers declare a workflow-levelRUSTFLAGS: "-Clink-arg=-fuse-ld=bfd", andGITHUB_ENVdoes win over it, because the runner evaluates workflow and jobenvonce into the same dictionary thatGITHUB_ENVlater writes to (JobExtension.InitializeJobpopulatingGlobal.EnvironmentVariables, thenStepsRunnerseeding each step's env context from it).What changes is scope.
-Ctarget-cpu=x86-64-v3now applies to every later step in the caller's job, where the old step-levelenv:applied to the onecargo build. Nothing downstream invokes Cargo today, so this is not a bug, but it is an unflagged widening. Dropping this step and puttingenv: RUSTFLAGS: ...on the fingerprint and build steps restores the old scope and removes a step.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 scope observation is correct. I kept the single definition because Andy explicitly requested removing the duplicated fingerprint/build literals in the previous review. These are native-producer jobs, and their remaining steps upload or package the existing library without invoking Cargo. There is no affected downstream build today. Reintroducing the two copies would reverse that agreed simplification, so I have left this unchanged and am keeping the thread open for discussion.