Skip to content

ci(l1): optimize CI times with toolchain caching#60

Merged
ilitteri merged 4 commits into
mainfrom
ci/optimize-ci-times
Feb 17, 2026
Merged

ci(l1): optimize CI times with toolchain caching#60
ilitteri merged 4 commits into
mainfrom
ci/optimize-ci-times

Conversation

@ilitteri

Copy link
Copy Markdown
Collaborator

Motivation

CI runs are taking longer than necessary due to repeated downloads of zkVM toolchains and suboptimal workflow configuration. This PR implements several optimizations to reduce CI time.

Description

Toolchain Caching

  • SP1: Cache ~/.sp1 directory with key sp1-toolchain-5.0.8
  • RISC0: Cache ~/.risc0 directory with key risc0-toolchain-3.0.3
  • ZisK: Cache ~/.zisk directory with key zisk-toolchain-0.14.0
    • Also fixed the install script to use versioned URL (v0.14.0) instead of latest

When updating toolchain versions, update both the install command AND the cache key.

Workflow Optimizations

  • Remove fetch-depth: 0 from checkout (shallow clone is sufficient for linting)
  • Change trigger from push to all branches → pull_request + push to main only
    • Prevents duplicate CI runs (PR creation + branch push were both triggering)
  • Combine rustup component add rustfmt and clippy into single command

Free Disk Space

Expanded cleanup to include:

  • CodeQL bundles
  • Swift
  • PowerShell
  • Miniconda

Expected Impact

Optimization Expected Savings
Toolchain caching 1-3 min per job (on cache hit)
Shallow checkout 5-10s per job
Single rustup command ~2s per job
Fewer duplicate runs 50% fewer total runs

How to Test

  1. Merge this PR
  2. Open a new PR to trigger CI
  3. First run will populate caches (no speedup)
  4. Subsequent runs should show cache hits and faster times

Checklist

  • SP1 cache key includes version
  • RISC0 cache key includes version
  • ZisK cache key includes version
  • ZisK install uses versioned script
  • Trigger changed to PR + main
  • Free disk expanded

- Cache SP1 toolchain (~/.sp1) with version 5.0.8 in cache key
- Cache RISC0 toolchain (~/.risc0) with version 3.0.3 in cache key
- Cache ZisK toolchain (~/.zisk) with version 0.14.0 in cache key
- Fix ZisK install to use versioned install script (v0.14.0)
- Remove unnecessary fetch-depth: 0 from checkout (shallow clone is sufficient)
- Change trigger from push to all branches to PR + main only (prevents duplicate runs)
- Combine rustfmt and clippy installation into single command
- Expand free-disk action to remove more unused tools (CodeQL, Swift, PowerShell, Miniconda)
Copilot AI review requested due to automatic review settings January 21, 2026 00:55
@github-actions github-actions Bot added the L1 label Jan 21, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR optimizes CI run times through toolchain caching, workflow trigger improvements, and enhanced disk space cleanup. The goal is to reduce redundant downloads and eliminate duplicate CI runs.

Changes:

  • Added caching for SP1, RISC0, and ZisK toolchains with versioned cache keys
  • Changed workflow triggers from all branch pushes to pull requests and main branch pushes only to prevent duplicate runs
  • Consolidated multiple free disk space cleanup commands and added cleanup for CodeQL, Swift, PowerShell, and Miniconda
  • Combined rustup component installation commands and removed unnecessary fetch-depth parameter

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
.github/workflows/pr-main.yaml Updated workflow triggers to reduce duplicate runs, removed fetch-depth, and consolidated rustup commands
.github/actions/install-sp1/action.yml Added caching for SP1 toolchain with version 5.0.8
.github/actions/install-risc0/action.yml Added caching for RISC0 toolchain with version 3.0.3
.github/actions/install-zisk/action.yml Added caching for ZisK toolchain with version 0.14.0, fixed install script to use versioned URL, separated PATH update into dedicated step
.github/actions/free-disk/action.yml Consolidated cleanup commands into single step and added additional cleanup targets
Comments suppressed due to low confidence (2)

.github/actions/install-sp1/action.yml:19

  • The SP1 binaries need to be added to PATH regardless of whether the cache was hit. When the cache is restored, the installation step is skipped, but the PATH is not updated. This will cause failures when trying to use SP1 tools. Add a separate step after the installation that always runs to add the SP1 bin directory to GITHUB_PATH, similar to how it's done in the ZisK installation action (line 28-30 in install-zisk/action.yml).
    - name: Install SP1
      if: steps.sp1-cache.outputs.cache-hit != 'true'
      shell: bash
      run: |
        curl -L https://sp1up.succinct.xyz | bash
        ~/.sp1/bin/sp1up --version 5.0.8

.github/actions/install-risc0/action.yml:23

  • The RISC0 binaries need to be added to PATH regardless of whether the cache was hit. When the cache is restored, the installation step is skipped, but the PATH is not updated. This will cause failures when trying to use RISC0 tools. Add a separate step after the installation that always runs to add the RISC0 bin directory to GITHUB_PATH, similar to how it's done in the ZisK installation action (line 28-30 in install-zisk/action.yml).
    - name: Install RISC0
      if: steps.risc0-cache.outputs.cache-hit != 'true'
      shell: bash
      run: |
        curl -L https://risczero.com/install | bash
        ~/.risc0/bin/rzup install cargo-risczero 3.0.3
        ~/.risc0/bin/rzup install risc0-groth16
        ~/.risc0/bin/rzup install rust
        ~/.risc0/bin/rzup install cpp
        ~/.risc0/bin/rzup install r0vm 3.0.3

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +7 to +11

runs:
using: "composite"
steps:
- name: Install system dependencies

Copilot AI Jan 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The system dependencies are installed unconditionally every time, even when the ZisK toolchain is restored from cache. While this ensures dependencies are present, it adds unnecessary overhead on cache hits. Consider adding a conditional check or caching the apt packages separately if they are solely for ZisK and not used elsewhere in the workflow.

Copilot uses AI. Check for mistakes.
@ilitteri ilitteri merged commit e9603ef into main Feb 17, 2026
16 checks passed
@ilitteri ilitteri deleted the ci/optimize-ci-times branch February 17, 2026 13:39
ilitteri added a commit that referenced this pull request Feb 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants