Skip to content

ci: add Rust compilation and dependency caching#1603

Merged
Benoît Cortier (CBenoit) merged 6 commits into
masterfrom
ci/try-sccache
Dec 4, 2025
Merged

ci: add Rust compilation and dependency caching#1603
Benoît Cortier (CBenoit) merged 6 commits into
masterfrom
ci/try-sccache

Conversation

@CBenoit
Copy link
Copy Markdown
Member

@CBenoit Benoît Cortier (CBenoit) commented Dec 3, 2025

Enable sccache for compilation caching using GitHub Actions cache backend, and Swatinem/rust-cache for dependency caching. This significantly reduces CI build times by avoiding redundant compilation and dependency downloads.

  • Add ci/install-sccache.ps1 for cross-platform sccache installation
  • Configure sccache with GHA cache backend for all Rust jobs
  • Add Swatinem/rust-cache with cache-targets disabled
  • Make sccache opt-out via workflow inputs (enabled by default)

Enable sccache for compilation caching using GitHub Actions cache backend,
and Swatinem/rust-cache for dependency caching. This significantly reduces
CI build times by avoiding redundant compilation and dependency downloads.

- Add ci/install-sccache.ps1 for cross-platform sccache installation
- Configure sccache with GHA cache backend for all Rust jobs
- Add Swatinem/rust-cache@v2.7.3 with cache-targets disabled
- Make sccache opt-out via workflow inputs (enabled by default)
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 adds compilation and dependency caching to GitHub Actions CI workflows to reduce build times. Sccache is configured with GitHub Actions cache backend for compilation caching, while Swatinem/rust-cache handles dependency caching.

Key changes:

  • Added cross-platform PowerShell script for sccache installation
  • Configured sccache with GitHub Actions cache backend across all Rust build jobs
  • Added Swatinem/rust-cache@v2.7.3 for cargo registry and dependency caching
  • Made sccache opt-out via workflow inputs (enabled by default)

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
ci/install-sccache.ps1 New PowerShell script for cross-platform sccache binary installation with version 0.12.0
.github/workflows/create-new-release.yml Disables sccache for release builds by passing sccache: false input
.github/workflows/ci.yml Adds workflow inputs for sccache control, configures caching in preflight job, and adds Rust cache + sccache setup steps to all Rust build jobs

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

Comment thread ci/install-sccache.ps1 Outdated
Comment thread ci/install-sccache.ps1 Outdated
Comment thread .github/workflows/ci.yml
Comment thread .github/workflows/ci.yml Outdated
Comment thread ci/install-sccache.ps1 Outdated
Comment thread ci/install-sccache.ps1 Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

.github/workflows/ci.yml:1174

  • The pedm-simulator job compiles Rust code (via cargo +nightly build in prepare.ps1) but is missing the Rust cache setup that was added to other Rust compilation jobs. For consistency and to benefit from caching improvements, consider adding:
- name: Setup Rust cache
  uses: ./.github/actions/setup-rust-cache
  with:
    sccache-enabled: ${{ needs.preflight.outputs.sccache }}

after the checkout step and before the "Prepare runner" step. Also add a "Show sccache stats" step at the end of the job.

  pedm-simulator:
    name: PEDM simulator
    runs-on: windows-2022
    needs: [preflight]

    steps:
      - name: Checkout ${{ github.repository }}
        uses: actions/checkout@v4
        with:
          ref: ${{ needs.preflight.outputs.ref }}

      - name: Prepare runner
        run: |
          rustup toolchain install nightly
          choco install pstools --yes

      - name: Prepare PEDM simulator build
        run: ./crates/pedm-simulator/prepare.ps1

      - name: Build PEDM simulator container
        run: ./crates/pedm-simulator/build-container.ps1

      - name: Run PEDM simulator (container with limited user)
        run: ./crates/pedm-simulator/run-container.ps1

      # It’s difficult to get realtime stdout/stderr when using psexec -s.
      # Instead, the run-expect-elevation.ps1 script will redirect the output into a file that we can read afterwards.
      - name: Run PEDM simulator (as LocalSystem)
        run: |
          $scriptPath = Resolve-Path -Path "./crates/pedm-simulator/run-expect-elevation.ps1"
          psexec -accepteula -s pwsh.exe $scriptPath
          Get-Content -Path ./crates/pedm-simulator/pedm-simulator_run-expect-elevation.out


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

Comment thread ci/install-sccache.ps1
Comment thread .github/actions/setup-rust-cache/action.yml
@CBenoit
Copy link
Copy Markdown
Member Author

image image image
  • master: 15-23 minutes
  • Swatinem/rust-cache: 14-16 minutes
  • Swatinem/rust-cache (no targets/ caching) + sccache: 10-11 minutes

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

.github/workflows/ci.yml:1152

  • The pedm-simulator job runs cargo build (via the prepare.ps1 script) but doesn't have the Rust cache setup. This is inconsistent with other Rust build jobs and will result in slower build times. Consider adding:
- name: Setup Rust cache
  uses: ./.github/actions/setup-rust-cache
  with:
    sccache-enabled: ${{ needs.preflight.outputs.sccache }}

after the checkout step and before the "Prepare runner" step.

  pedm-simulator:
    name: PEDM simulator
    runs-on: windows-2022
    needs: [preflight]

    steps:
      - name: Checkout ${{ github.repository }}
        uses: actions/checkout@v4
        with:
          ref: ${{ needs.preflight.outputs.ref }}


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

@CBenoit Benoît Cortier (CBenoit) merged commit 488942f into master Dec 4, 2025
206 checks passed
@CBenoit Benoît Cortier (CBenoit) deleted the ci/try-sccache branch December 4, 2025 03:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants