Skip to content

Commit 86b3675

Browse files
committed
perf(ci): split Linux CLI builds across native amd64/arm64 runners
Use a matrix strategy to build each Linux musl target natively on its matching runner (build-amd64 / build-arm64) instead of cross-compiling both on amd64. This parallelizes the builds and avoids cross-compilation complexity. Also adds sccache (via mise install + memcached endpoint) and Swatinem/rust-cache for cargo target/registry caching on Linux builds.
1 parent 12900ad commit 86b3675

1 file changed

Lines changed: 40 additions & 41 deletions

File tree

‎.github/workflows/publish.yml‎

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,20 @@ jobs:
212212
# uv run python tasks/scripts/release.py python-publish --version "$WHEEL_VERSION"
213213

214214
# ---------------------------------------------------------------------------
215-
# Build CLI binaries (Linux musl — static)
215+
# Build CLI binaries (Linux musl — static, native on each arch)
216216
# ---------------------------------------------------------------------------
217217
build-cli-linux:
218-
name: Build CLI (Linux)
219-
runs-on: build-amd64
218+
name: Build CLI (Linux ${{ matrix.arch }})
219+
strategy:
220+
matrix:
221+
include:
222+
- arch: amd64
223+
runner: build-amd64
224+
target: x86_64-unknown-linux-musl
225+
- arch: arm64
226+
runner: build-arm64
227+
target: aarch64-unknown-linux-musl
228+
runs-on: ${{ matrix.runner }}
220229
timeout-minutes: 60
221230
container:
222231
image: ghcr.io/nvidia/nv-agent-env/ci:latest
@@ -238,34 +247,39 @@ jobs:
238247
- name: Fetch tags
239248
run: git fetch --tags --force
240249

250+
- name: Install tools
251+
run: mise install
252+
253+
- name: Cache Rust target and registry
254+
uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2
255+
with:
256+
shared-key: cli-musl-${{ matrix.arch }}
257+
cache-directories: .cache/sccache
258+
cache-targets: "true"
259+
241260
- name: Compute version
242261
id: version
243262
run: |
244263
set -euo pipefail
245264
CARGO_VERSION=$(uv run python tasks/scripts/release.py get-version --cargo)
246265
echo "cargo_version=${CARGO_VERSION}" >> "$GITHUB_OUTPUT"
247266
248-
- name: Install musl toolchains
267+
- name: Install musl toolchain
249268
run: |
250269
set -euo pipefail
251270
apt-get update
252-
apt-get install -y --no-install-recommends \
253-
musl-tools cmake \
254-
gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
271+
apt-get install -y --no-install-recommends musl-tools
255272
rm -rf /var/lib/apt/lists/*
256273
257-
- name: Add Rust musl targets
258-
run: |
259-
rustup target add x86_64-unknown-linux-musl
260-
rustup target add aarch64-unknown-linux-musl
274+
- name: Add Rust musl target
275+
run: rustup target add ${{ matrix.target }}
261276

262277
- name: Scope workspace to CLI crates
263278
run: |
264279
set -euo pipefail
265280
# Remove workspace members that are not needed for navigator-cli.
266281
# This avoids Cargo feature-unification pulling in aws-lc-sys (via
267-
# russh in navigator-sandbox / navigator-server), which fails to
268-
# cross-compile for musl targets.
282+
# russh in navigator-sandbox / navigator-server).
269283
sed -i 's|members = \["crates/\*"\]|members = ["crates/navigator-cli", "crates/navigator-core", "crates/navigator-bootstrap", "crates/navigator-policy", "crates/navigator-providers", "crates/navigator-tui"]|' Cargo.toml
270284
271285
- name: Patch workspace version
@@ -274,35 +288,25 @@ jobs:
274288
set -euo pipefail
275289
sed -i -E '/^\[workspace\.package\]/,/^\[/{s/^version[[:space:]]*=[[:space:]]*".*"/version = "'"${{ steps.version.outputs.cargo_version }}"'"/}' Cargo.toml
276290
277-
- name: Build x86_64-unknown-linux-musl
278-
run: cargo build --release --target x86_64-unknown-linux-musl -p navigator-cli
291+
- name: Build ${{ matrix.target }}
292+
run: cargo build --release --target ${{ matrix.target }} -p navigator-cli
279293

280-
- name: Build aarch64-unknown-linux-musl
281-
env:
282-
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER: aarch64-linux-gnu-gcc
283-
CC_aarch64_unknown_linux_musl: aarch64-linux-gnu-gcc
284-
CXX_aarch64_unknown_linux_musl: aarch64-linux-gnu-g++
285-
run: cargo build --release --target aarch64-unknown-linux-musl -p navigator-cli
294+
- name: sccache stats
295+
if: always()
296+
run: mise x -- sccache --show-stats
286297

287-
- name: Package binaries
298+
- name: Package binary
288299
run: |
289300
set -euo pipefail
290301
mkdir -p artifacts
291-
292-
# x86_64
293-
tar -czf artifacts/nemoclaw-x86_64-unknown-linux-musl.tar.gz \
294-
-C target/x86_64-unknown-linux-musl/release nemoclaw
295-
296-
# aarch64
297-
tar -czf artifacts/nemoclaw-aarch64-unknown-linux-musl.tar.gz \
298-
-C target/aarch64-unknown-linux-musl/release nemoclaw
299-
302+
tar -czf artifacts/nemoclaw-${{ matrix.target }}.tar.gz \
303+
-C target/${{ matrix.target }}/release nemoclaw
300304
ls -lh artifacts/
301305
302-
- name: Upload artifacts
306+
- name: Upload artifact
303307
uses: actions/upload-artifact@v4
304308
with:
305-
name: cli-linux
309+
name: cli-linux-${{ matrix.arch }}
306310
path: artifacts/*.tar.gz
307311
retention-days: 5
308312

@@ -385,17 +389,12 @@ jobs:
385389
steps:
386390
- uses: actions/checkout@v4
387391

388-
- name: Download Linux CLI artifacts
392+
- name: Download all CLI artifacts
389393
uses: actions/download-artifact@v4
390394
with:
391-
name: cli-linux
392-
path: release/
393-
394-
- name: Download macOS CLI artifact
395-
uses: actions/download-artifact@v4
396-
with:
397-
name: cli-macos
395+
pattern: cli-*
398396
path: release/
397+
merge-multiple: true
399398

400399
- name: Generate checksums
401400
run: |

0 commit comments

Comments
 (0)