Skip to content

ci: pre-build CI Docker image with deps compiled for faster cold builds #833

@Evrard-Nil

Description

@Evrard-Nil

Follow-up to #831 (test workflow speedup).

Context

PR #831 added sccache, which helps on warm runs. But cold builds (new PR, dependency bump, cache miss) still recompile ~400 crates from scratch. The Cargo.lock is ~8500 lines.

Proposal

Build a CI Docker image that contains a pre-compiled target/ directory with all dev-dependencies compiled (cargo test --no-run). Push to ghcr.io/nearai/cloud-api-ci:latest and refresh via a scheduled workflow (weekly) or on Cargo.lock changes. The runner pulls this image, swatinem/rust-cache hits the pre-warmed cache, and only local crate code is compiled from scratch.

Expected impact

60-80% reduction in compilation time for cache-hit runs. Tradeoff: increased CI complexity, multi-GB image storage, invalidation costs on Cargo.lock changes.

Alternative

Keep relying on sccache (persistent on the self-hosted runner) and only pursue this if cold-build times remain a problem after the dedicated CI VM lands.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions