Speed up deploy action#4595
Conversation
|
Claude finished @MartinquaXD's task in 3m 46s —— View job PR Review: Speed up
|
There was a problem hiding this comment.
Code Review
This pull request removes the compile-time vergen build dependency across multiple crates, replacing it with a runtime version check in a new observe::version module that reads GIT_SHA and GIT_BRANCH environment variables. It also consolidates the workspace members in the root Cargo.toml and adds a new Dockerfile.deploy-ci. The review feedback recommends optimizing the runtime version retrieval by caching the environment variables using std::sync::LazyLock to avoid performance overhead and string allocations on every request to the version endpoint.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| push: true | ||
| tags: ${{ steps.meta_services.outputs.tags }} | ||
| labels: ${{ steps.meta_services.outputs.labels }} | ||
| build-contexts: binaries=target/release |
There was a problem hiding this comment.
Using binaries=target/release as a named build context sends the entire target/release/ directory to buildkit, not just the six binaries. With cache-all-crates: true + debug = 1, that directory (deps/, build/, .fingerprint/, incremental/, …) is easily multiple GB. Since setup-buildx-action uses the docker-container driver by default, that whole tree gets tarred and transferred to the builder on every deploy — which eats into the speedup this PR is trying to achieve.
Consider staging just the needed binaries into a small directory first and pointing the context at that, e.g.:
- name: Stage binaries
run: |
mkdir -p dist
cp target/release/{autopilot,driver,orderbook,refunder,solvers,pool-indexer} dist/and build-contexts: binaries=dist.
| push: true | ||
| tags: ${{ steps.meta_services.outputs.tags }} | ||
| labels: ${{ steps.meta_services.outputs.labels }} | ||
| build-contexts: binaries=target/release |
There was a problem hiding this comment.
Using binaries=target/release as a named build context sends the entire target/release/ directory to buildkit, not just the six binaries. With cache-all-crates: true + debug = 1, that directory (deps/, build/, .fingerprint/, incremental/, …) is easily multiple GB. Since setup-buildx-action uses the docker-container driver by default, that whole tree gets tarred and transferred to the builder on every deploy — which eats into the speedup this PR is trying to achieve.
Consider staging just the needed binaries into a small directory first and pointing the context at that, e.g.:
- name: Stage binaries
run: |
mkdir -p dist
cp target/release/{autopilot,driver,orderbook,refunder,solvers,pool-indexer} dist/and build-contexts: binaries=dist.
f06b4f9 to
bf4cc57
Compare
|
Claude finished @MartinquaXD's task in 3m 42s —— View job PR Review: Speed up
|
|
Warning Gemini encountered an error creating the review. You can try again by commenting |
Description
Currently the
deployaction takes ~15m. This makes preparing and rolling out hotfixes extremely tedious.The main issue is that we can't make good use of caches because so far our builds happen inside docker. While it is possible to use
cargo-chefto cache the dependencies it's not optimal and relatively complex.Changes
The goal of this PR is to do the main work of compiling the binaries in the GH runner while making optimal use of caching.
This requires a few changes:
rust-cachedoes not cache the build artifacts of the generated contract bindings. To support that I needed to move them out of their separate workspace and made them part of the main workspace. Dissolving this extra workspace and merging it into the main workspace also slightly changed the behavior of formatting and doc tests which is why thejustcommands for those had to be adjusted a bit.observecrate that was only there to silence a warning. Now the warning gets silenced via a lint option in the workspace cargo.toml file.cargofigures out which files changed by looking at the modified timestamp. This gets set to the current time during thecheckoutaction. Since this invalidates the cache I introduced another action that sets each source file's modified date to the date of the commit that last changed it.To help
rust-cachepick the most relevant cache the cache key was chosen specifically. The most important parts are$CARGO_LOCK_HASH-$BRANCH_NAME-$RUN_ID. The cargo lock hash gets added by default but the branch name and run id are added explicitly. They are here to ensure that each branch operates on their own cache to avoid experiments interfering with themaincache which is primarily used to build the images that get released to staging and always just have small incremental changes. The run id was added to force rust-cache to effectively store an updated cache snapshot after every new build. Otherwise changes from previous commits would always be compiled in addition to the latest commit.How to test
Checked how long it takes to compile minimal changes. In these runs I only changed 1 line in the driver or solvers binary which only took 3:30 instead of the usual 15m.
Also tested on sepolia staging that the autopilot and init container run as expected and that the version string is reasonable.

