ci(actions): skipped bun setup and rust-cache on shared-sccache runners
- Updated the bun-install composite action to detect preinstalled Bun and only fetch it when missing. - Added cache-backend detection and wiring so Bun dependencies use RustFS cache when SCCACHE credentials are present. - Conditionally skipped rust-cache in build-native and CI jobs when shared sccache runners are available, relying on the existing RustFS/sccache layer instead.
This commit is contained in:
@@ -53,18 +53,19 @@ runs:
|
||||
echo "$toolchain_bin" >> "$GITHUB_PATH"
|
||||
echo "Prepended $toolchain_bin to PATH"
|
||||
# `Swatinem/rust-cache` keys target/ off its restore-time environment, so
|
||||
# set RUSTFLAGS before restoring it. If x64 target-cpu is only selected
|
||||
# inside ci-build-native.ts/build-native.ts, cargo invalidates the restored
|
||||
# target/ but rust-cache sees an exact key and refuses to save the rebuilt
|
||||
# artifacts, causing macOS x64 baseline to rebuild forever.
|
||||
# set RUSTFLAGS before deciding whether to restore it. If x64 target-cpu is
|
||||
# only selected inside ci-build-native.ts/build-native.ts, cargo invalidates
|
||||
# the restored target/ but rust-cache sees an exact key and refuses to save
|
||||
# the rebuilt artifacts, causing macOS x64 baseline to rebuild forever.
|
||||
#
|
||||
# Include the native source hash in the shared key as well: rust-cache's
|
||||
# lockfile scan misses the workspace root Cargo.toml version that Cargo
|
||||
# fingerprints for workspace crates. Without it, release version bumps can
|
||||
# get an exact hit for artifacts Cargo must rebuild.
|
||||
#
|
||||
# sccache is still layered on top of rust-cache: target/ wins when warm,
|
||||
# sccache fills the gaps when target/ is cold.
|
||||
# On GitHub-hosted runners, rust-cache can still warm target/. On omp-kata,
|
||||
# the shared RustFS-backed sccache is the primary reuse layer and avoids a
|
||||
# second GitHub-cache restore for Cargo dirs/target.
|
||||
- name: Configure native Rust flags
|
||||
if: inputs.target == ''
|
||||
shell: bash
|
||||
@@ -94,7 +95,19 @@ runs:
|
||||
|
||||
echo "RUSTFLAGS=$rustflags" >> "$GITHUB_ENV"
|
||||
echo "Configured RUSTFLAGS=$rustflags"
|
||||
- name: Decide Rust artifact cache
|
||||
id: rust_artifact_cache
|
||||
shell: bash
|
||||
run: |
|
||||
if [ -n "${SCCACHE_BUCKET:-}" ]; then
|
||||
echo "use_rust_cache=false" >> "$GITHUB_OUTPUT"
|
||||
echo "Rust target cache: skipped on shared-sccache runners"
|
||||
else
|
||||
echo "use_rust_cache=true" >> "$GITHUB_OUTPUT"
|
||||
echo "Rust target cache: GitHub Actions"
|
||||
fi
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
if: steps.rust_artifact_cache.outputs.use_rust_cache == 'true'
|
||||
with:
|
||||
shared-key: native-${{ inputs.platform }}-${{ inputs.arch }}-${{ inputs.variant || 'default' }}-h${{ inputs.hash }}
|
||||
cache-on-failure: true
|
||||
@@ -126,9 +139,6 @@ runs:
|
||||
if: inputs.target == ''
|
||||
with:
|
||||
tool: nextest
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
bun-version: "1.3"
|
||||
- uses: ./.github/actions/bun-install
|
||||
# Cross-compile toolchain selection: non-MSVC targets (e.g.
|
||||
# `aarch64-unknown-linux-gnu`) build with `cargo-zigbuild`; MSVC targets
|
||||
|
||||
@@ -1,31 +1,47 @@
|
||||
name: "bun install (shared cache)"
|
||||
description: >
|
||||
Run `bun install --frozen-lockfile` with a shared dependency cache. On
|
||||
self-hosted omp-kata runners (where the sccache S3 credentials are injected)
|
||||
the bun store and node_modules are cached in the in-cluster RustFS S3; every
|
||||
other runner falls back to the stock actions/cache backend.
|
||||
Ensure bun is on PATH, then run `bun install --frozen-lockfile` with a shared
|
||||
dependency cache. bun setup is skipped when the runner image already ships it
|
||||
(the preloaded omp-kata image), and only fetched on runners that lack it
|
||||
(e.g. GitHub-hosted). The cache uses the in-cluster RustFS S3 when the sccache
|
||||
credentials are present, and the stock actions/cache backend otherwise.
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
# The whole repo already keys "are we on hosted infra?" off
|
||||
# $SCCACHE_BUCKET (see actions/build-native). RUNNER_ENVIRONMENT is empty
|
||||
# on ARC pods, so it is not a usable signal here.
|
||||
- name: Detect cache backend
|
||||
id: backend
|
||||
- name: Detect environment
|
||||
id: env
|
||||
shell: bash
|
||||
run: |
|
||||
# bun is baked into the omp-kata runner image — only fetch it when the
|
||||
# runner doesn't already provide it (GitHub-hosted), so we don't
|
||||
# re-download bun from GitHub releases on every job.
|
||||
if command -v bun >/dev/null 2>&1; then
|
||||
echo "setup_bun=false" >> "$GITHUB_OUTPUT"
|
||||
echo "bun present: $(bun --version) (preloaded image)"
|
||||
else
|
||||
echo "setup_bun=true" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
# The repo keys "are we on can.internal infra?" off $SCCACHE_BUCKET (see
|
||||
# actions/build-native). RUNNER_ENVIRONMENT is empty on ARC pods, so it
|
||||
# is not a usable signal here.
|
||||
if [ -n "${SCCACHE_BUCKET:-}" ] && [ -n "${AWS_ACCESS_KEY_ID:-}" ]; then
|
||||
echo "kind=rustfs" >> "$GITHUB_OUTPUT"
|
||||
echo "cache=rustfs" >> "$GITHUB_OUTPUT"
|
||||
echo "bun cache backend: RustFS S3 ($SCCACHE_BUCKET @ $SCCACHE_ENDPOINT)"
|
||||
else
|
||||
echo "kind=gha" >> "$GITHUB_OUTPUT"
|
||||
echo "cache=gha" >> "$GITHUB_OUTPUT"
|
||||
echo "bun cache backend: GitHub Actions cache"
|
||||
fi
|
||||
- name: Install bun when absent
|
||||
if: steps.env.outputs.setup_bun == 'true'
|
||||
shell: bash
|
||||
run: |
|
||||
export BUN_INSTALL="${HOME}/.bun"
|
||||
curl -fsSL https://bun.sh/install | bash -s "bun-v1.3.14"
|
||||
echo "${BUN_INSTALL}/bin" >> "$GITHUB_PATH"
|
||||
|
||||
# Off-infra (GitHub-hosted): stock actions/cache for the bun store.
|
||||
- name: Cache bun store (GitHub cache)
|
||||
if: steps.backend.outputs.kind == 'gha'
|
||||
if: steps.env.outputs.cache == 'gha'
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.bun/install/cache
|
||||
@@ -33,7 +49,7 @@ runs:
|
||||
|
||||
# On-infra (omp-kata): RustFS store + node_modules over the LAN.
|
||||
- name: Restore bun caches (RustFS)
|
||||
if: steps.backend.outputs.kind == 'rustfs'
|
||||
if: steps.env.outputs.cache == 'rustfs'
|
||||
shell: bash
|
||||
run: bash "$GITHUB_ACTION_PATH/rustfs-cache.sh" restore
|
||||
|
||||
@@ -42,6 +58,6 @@ runs:
|
||||
run: bun install --frozen-lockfile
|
||||
|
||||
- name: Save bun caches (RustFS)
|
||||
if: steps.backend.outputs.kind == 'rustfs'
|
||||
if: steps.env.outputs.cache == 'rustfs'
|
||||
shell: bash
|
||||
run: bash "$GITHUB_ACTION_PATH/rustfs-cache.sh" save
|
||||
|
||||
+14
-30
@@ -190,9 +190,6 @@ jobs:
|
||||
runs-on: omp-kata
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
bun-version: "1.3"
|
||||
- uses: ./.github/actions/bun-install
|
||||
- name: Type check workspace
|
||||
run: bun run ci:check:full
|
||||
@@ -259,9 +256,6 @@ jobs:
|
||||
timeout-minutes: 20
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
bun-version: "1.3"
|
||||
- uses: ./.github/actions/bun-install
|
||||
- name: Resolve Linux x64 native artifact run
|
||||
id: source
|
||||
@@ -291,9 +285,6 @@ jobs:
|
||||
timeout-minutes: 20
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
bun-version: "1.3"
|
||||
- uses: ./.github/actions/bun-install
|
||||
- name: Resolve Linux x64 native artifact run
|
||||
id: source
|
||||
@@ -325,9 +316,6 @@ jobs:
|
||||
timeout-minutes: 25
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
bun-version: "1.3"
|
||||
- uses: ./.github/actions/setup-system-deps
|
||||
- uses: ./.github/actions/bun-install
|
||||
- name: Resolve Linux x64 native artifact run
|
||||
@@ -358,9 +346,6 @@ jobs:
|
||||
timeout-minutes: 25
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
bun-version: "1.3"
|
||||
- uses: ./.github/actions/setup-system-deps
|
||||
- uses: ./.github/actions/bun-install
|
||||
- name: Resolve Linux x64 native artifact run
|
||||
@@ -391,9 +376,6 @@ jobs:
|
||||
timeout-minutes: 25
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
bun-version: "1.3"
|
||||
- uses: ./.github/actions/bun-install
|
||||
- name: Resolve Linux x64 native artifact run
|
||||
id: source
|
||||
@@ -425,9 +407,6 @@ jobs:
|
||||
timeout-minutes: 25
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
bun-version: "1.3"
|
||||
- uses: ./.github/actions/setup-system-deps
|
||||
- uses: ./.github/actions/bun-install
|
||||
- name: Resolve Linux x64 native artifact run
|
||||
@@ -458,9 +437,6 @@ jobs:
|
||||
timeout-minutes: 15
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
bun-version: "1.3"
|
||||
- uses: ./.github/actions/setup-system-deps
|
||||
- uses: ./.github/actions/bun-install
|
||||
- name: Resolve Linux x64 native artifact run
|
||||
@@ -488,21 +464,29 @@ jobs:
|
||||
runs-on: omp-kata
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
bun-version: "1.3"
|
||||
- uses: dtolnay/rust-toolchain@nightly
|
||||
with:
|
||||
toolchain: nightly-2026-04-29
|
||||
- name: Decide Rust artifact cache
|
||||
id: rust_artifact_cache
|
||||
shell: bash
|
||||
run: |
|
||||
if [ -n "${SCCACHE_BUCKET:-}" ]; then
|
||||
echo "use_rust_cache=false" >> "$GITHUB_OUTPUT"
|
||||
echo "Rust target cache: skipped on shared-sccache runners"
|
||||
else
|
||||
echo "use_rust_cache=true" >> "$GITHUB_OUTPUT"
|
||||
echo "Rust target cache: GitHub Actions"
|
||||
fi
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
if: steps.rust_artifact_cache.outputs.use_rust_cache == 'true'
|
||||
with:
|
||||
shared-key: install-methods-linux-x64
|
||||
cache-on-failure: true
|
||||
save-if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
|
||||
cache-workspace-crates: true
|
||||
# Layer sccache on top of rust-cache for the same reason as the
|
||||
# build-native action: release version bumps bust the target/ cache,
|
||||
# but sccache hits at the rustc-unit level survive.
|
||||
# On omp-kata, shared S3-backed sccache already carries the compile reuse
|
||||
# and avoids a second GitHub-cache handshake for target/.
|
||||
- name: Setup sccache
|
||||
uses: mozilla-actions/sccache-action@v0.0.10
|
||||
- name: Enable sccache for cargo
|
||||
|
||||
Reference in New Issue
Block a user