Skip to content

Use self-hosted runners for Rust CI jobs#1255

Merged
hut8 merged 6 commits intomainfrom
perf/optimize-ci-self-hosted
Mar 16, 2026
Merged

Use self-hosted runners for Rust CI jobs#1255
hut8 merged 6 commits intomainfrom
perf/optimize-ci-self-hosted

Conversation

@hut8
Copy link
Copy Markdown
Owner

@hut8 hut8 commented Mar 16, 2026

Summary

  • Move test-rust, build-release, test-e2e, and security-audit jobs to self-hosted runners (tenerife-1 through tenerife-8) on a 32-core/125GB machine
  • Replace Swatinem/rust-cache with persistent host-mounted cargo cache volumes (/opt/ci-cache)
  • Namespace all caches per-runner (/ci-cache/${RUNNER_NAME}/) to prevent corruption from concurrent jobs
  • Add concurrency group to cancel stale in-progress CI runs (except on main)

How it works

  • Each self-hosted container job mounts /opt/ci-cache:/ci-cache
  • A setup step symlinks /usr/local/cargo/registry and /usr/local/cargo/git to per-runner subdirectories
  • CARGO_TARGET_DIR is set to a per-runner, per-job-type path (e.g., /ci-cache/tenerife-3/target-test)
  • 8 runner instances via systemd template (github-actions-runner@{1..8}.service) allow full parallelism

What stays on GitHub-hosted

  • test-sveltekit — fast (1.5 min), no Rust
  • build-android — JDK/Gradle toolchain, fast (2 min)
  • build-release-arm64 — cross-compilation, needs separate setup
  • All deploy jobs — lightweight SSH operations

Test plan

  • 8 self-hosted runners registered and online
  • Runners configured as non-ephemeral (persist across jobs)
  • Verify all self-hosted jobs complete successfully
  • Verify warm-cache runs are faster than GitHub-hosted baseline (~13 min)
  • Verify concurrent jobs don't corrupt shared state

Move test-rust and build-release to self-hosted runners on tenerife
for persistent Docker image cache and faster runner provisioning.
Add concurrency group to cancel stale in-progress runs.
Copilot AI review requested due to automatic review settings March 16, 2026 00:56
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

Migrates Rust CI jobs (test-rust and build-release) from GitHub-hosted ubuntu-22.04 runners to self-hosted runners for faster provisioning and persistent Docker cache. Adds a concurrency group to cancel stale CI runs on non-main branches.

Changes:

  • Add concurrency group (ci-${{ github.ref }}) with cancel-in-progress for non-main branches
  • Switch test-rust and build-release jobs from ubuntu-22.04 to self-hosted

You can also share your feedback on Copilot code review. Take the survey.

hut8 added 2 commits March 16, 2026 01:15
- Mount /opt/ci-cache volumes into containers for persistent cargo
  registry, git, and target directories across CI runs
- Remove Swatinem/rust-cache (replaced by local volume mounts)
- Use per-runner CARGO_TARGET_DIR to avoid conflicts between runners
- Move test-e2e and security-audit to self-hosted runners
- Update target path references to use CARGO_TARGET_DIR env var
The runner context is not available in job-level env expressions.
Use GITHUB_ENV in a step after checkout to set CARGO_TARGET_DIR
based on the RUNNER_NAME shell variable instead.
Copilot AI review requested due to automatic review settings March 16, 2026 01:42
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

Migrates Rust-heavy CI jobs to self-hosted runners with persistent volume-mounted caches (replacing Swatinem/rust-cache), and adds a concurrency group to cancel stale CI runs.

Changes:

  • Switch test-rust, build-release, test-e2e, and security-audit jobs from ubuntu-22.04 to self-hosted runners
  • Replace GitHub Actions cache with host-mounted cargo registry/git/target volumes, namespacing target dirs per runner
  • Add concurrency group at workflow level to cancel in-progress runs on non-main branches

You can also share your feedback on Copilot code review. Take the survey.

Comment thread .github/workflows/ci.yml
security-audit:
name: Security Audit
runs-on: ubuntu-22.04
runs-on: self-hosted
Comment thread .github/workflows/ci.yml
test-e2e:
name: E2E Tests (Playwright)
runs-on: ubuntu-22.04
runs-on: self-hosted
Comment thread .github/workflows/ci.yml Outdated
Comment on lines +66 to +68
- /opt/ci-cache/cargo-registry:/usr/local/cargo/registry
- /opt/ci-cache/cargo-git:/usr/local/cargo/git
- /opt/ci-cache/target:/ci-target
Per-runner isolation prevents concurrent cargo registry/git corruption
when multiple runners execute on the same host simultaneously. Each
runner gets its own subdirectory under /opt/ci-cache via symlinks.
Also adds cargo cache volumes to the security-audit job.
@hut8 hut8 enabled auto-merge March 16, 2026 02:05
Copilot AI review requested due to automatic review settings March 16, 2026 02:39
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

Migrates four Rust-heavy CI jobs (test-rust, build-release, test-e2e, security-audit) from GitHub-hosted runners to self-hosted runners with persistent host-mounted cargo caches, replacing the Swatinem/rust-cache action.

Changes:

  • Switch runs-on to self-hosted and mount /opt/ci-cache:/ci-cache for persistent cargo/target caching namespaced per runner
  • Replace Swatinem/rust-cache with symlink-based cache setup steps and per-runner CARGO_TARGET_DIR
  • Add a concurrency group to cancel stale CI runs on non-main branches

You can also share your feedback on Copilot code review. Take the survey.

Comment thread .github/workflows/ci.yml
Comment on lines +95 to +100
- name: Setup persistent cargo cache
run: |
mkdir -p /ci-cache/${RUNNER_NAME}/cargo-registry /ci-cache/${RUNNER_NAME}/cargo-git
ln -sfn /ci-cache/${RUNNER_NAME}/cargo-registry /usr/local/cargo/registry
ln -sfn /ci-cache/${RUNNER_NAME}/cargo-git /usr/local/cargo/git
echo "CARGO_TARGET_DIR=/ci-cache/${RUNNER_NAME}/target-e2e" >> $GITHUB_ENV
- Increase timeout for Enter key login test (5s -> 15s) to handle
  slower redirect under load on self-hosted runners
- Namespace cargo registry/git cache per-runner via symlinks to
  prevent corruption from concurrent jobs on the same host
- Add cargo cache volumes to security-audit job
@hut8 hut8 merged commit 9cd0c4c into main Mar 16, 2026
17 checks passed
@hut8 hut8 deleted the perf/optimize-ci-self-hosted branch March 16, 2026 04:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants