Skip to content

ci(linux): smoke-gate the musl leg and retire the "musl never compiled" hold - #221

Merged
caomengxuan666 merged 1 commit into
masterfrom
ci/musl-smoke-gate
Oct 9, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
ci/musl-smoke-gate

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

背景

docs/release.md 里那条 musl 欠账原文是:

gnu, not musl — … musl has never been compiled in this repo, so a musl leg would ship an untested libc surface … Add musl legs only after they carry the same smoke gate green.

#210 加的 cross-target-check 只做 cargo check——那不是 smoke gate。所以这条 hold 其实还挂着。这个 PR 把它真正结清。

改动

新增 cross-target-smoke job(ubuntu-22.04):

  1. 构建 x86_64-unknown-linux-musl 的 --release 二进制
  2. 跑 release pipeline 的那四项检查(docs/release.md "The smoke gate" 原文那四项):
    • --version 必须带上本 crate 版本 + pin 住的 rubash revision
    • niu -c 'echo ok' → ok
    • printf 'a\nb\n' | niu -c 'sort | head -1' → a
    • plugin sync --bootstrap(空 spec + 隔离 HOME,必须 exit 0 且零输出)

第 3 项是关键——它证明 musl 静态二进制上的 fork/exec + 管道能在真实 coreutils 上跑通。光编译过证明不了这个。

另外在 smoke 之前先断言二进制确实静态:ldd 必须报 statically linked,否则 fail。这样"悄悄链回宿主 glibc 却被当成 musl 构建"过不了关。

不需要 musl-tools:rustc 通过宿主 cc 链到工具链自带的 self-contained musl crt/libc(实测 rustlib/x86_64-unknown-linux-musl/lib/self-contained/ 有 11 个文件,含 libc.a)。所以 ubuntu runner 零额外依赖。

为什么这次能真跑,ohos 那次只能 check

静态 musl x86_64 二进制能在 glibc runner 上原生执行;ohos 没有可用运行时,只能 cargo check。这是两者能拿到不同级别证据的原因。

本地实测(开 PR 前跑的)

musl release 二进制四项全过:

check 结果
--version ✅ Niubash 1.3.4 + rubash git <rev>
echo ok ✅ ok
sort | head -1 ✅ a
plugin sync --bootstrap ✅ 离线静默,rc=0

外加 readelf -d 无 NEEDED 条目 → 完全静态;uname -s = Linux、$BASH_VERSION = 5.3.0(1)-release。

docs/release.md 与 release.yml

  • docs/release.md 的 "gnu, not musl" 那条重写:发布的 tarball 仍是 gnu(artifact matrix 没动),但 musl 现在每次 CI 都编译 + smoke,所以"加 musl 发布产物"从"测试覆盖缺口"变成了"交付决策"。
  • release.yml 里 build-linux matrix 的注释重复了同一句过时论断("musl has never been compiled in this repo"),就地更正。只改注释,matrix 不变。

改动面

文件 改动
.github/workflows/ci.yml +94(新增 1 个 job,不动现有 job)
docs/release.md 重写 1 个 bullet
.github/workflows/release.yml 注释更正(5 行,matrix 不变)

…d" hold

docs/release.md held the musl leg back with a specific condition: "Add musl
legs only after they carry the same smoke gate green." `cross-target-check`
(since #210) only runs `cargo check`, which is not that gate -- so the hold
was still open. Close it properly.

`cross-target-smoke` (new job, ubuntu-22.04) builds `--release` for
x86_64-unknown-linux-musl and runs the exact four checks the release
pipeline runs (docs/release.md "The smoke gate"):

  1. `--version` names this crate version and the pinned rubash revision
  2. `niu -c 'echo ok'` -> ok
  3. `printf 'a\nb\n' | niu -c 'sort | head -1'` -> a
  4. `plugin sync --bootstrap`, empty spec + isolated HOME, exit 0 / silent

A static musl x86_64 binary runs natively on the glibc runner, so unlike
the ohos target this one can carry the real gate rather than a compile
check. Before smoking, the job asserts `ldd` reports `statically linked`,
so a silent re-link against the runner's glibc cannot pass as a musl build.
No `musl-tools` package: rustc links against the toolchain's own
self-contained musl crt/libc through the host `cc` (verified: 11 files in
rustlib/x86_64-unknown-linux-musl/lib/self-contained, incl. libc.a).

Verified locally before opening this: the musl release binary passes all
four checks, and `readelf -d` shows no NEEDED entries.

docs/release.md: the "gnu, not musl" bullet is rewritten -- released
tarballs stay gnu (artifact matrix unchanged), but musl is now compiled AND
smoked every CI run, so adding a musl release artifact is a delivery
decision rather than a test-coverage gap. release.yml's build-linux matrix
comment repeated the stale claim and is corrected in place (comment only;
no matrix change).
@caomengxuan666
caomengxuan666 merged commit e447c7a into master Oct 9, 2026
8 of 9 checks passed
@caomengxuan666
caomengxuan666 deleted the ci/musl-smoke-gate branch October 10, 2026 01:35
caomengxuan666 added a commit that referenced this pull request Oct 10, 2026
…247)

build-android: aarch64-linux-android + armv7-linux-androideabi, real
bionic link via nttld/setup-ndk (r27c, API 24 clang drivers), zip
artifact per leg, ELF-arch verification in place of the (impossible
on-runner) runtime smoke, disclosed on the step summary.

build-openharmony: aarch64-unknown-linux-ohos, check-only by design
(Tier 2 with host tools, same target ci.yml gates); real linking needs
the OHOS SDK clang wrapper, which has no runner preinstall and no
version-pinned fetch path yet, so no binary is produced or shipped
from this leg -- the artifact is the check log.

Both jobs: continue-on-error, NOT in the release needs -- same
incubation shape the musl leg followed before #221 tightened it.
Tighten only after they run green for a cycle.

docs: platform-support status matrix rows + an Android section.

Refs #207
caomengxuan666 added a commit that referenced this pull request Oct 12, 2026
…l return + build.rs host-agnostic icon gate (#281)

* fix(highlighting): color REPL-only commands (self-update, update-niubash, logout) as builtins (niu#260)

self-update / update-niubash are intercepted by the REPL before engine
command resolution, so they never resolve on PATH and the highlighter
painted them as unknown tokens (red) even though they run fine (issue
screenshot: red 'self-update' at the prompt). Same class of problem for
'logout', which is also a REPL-exact-match word.

Add repl::is_repl_reserved_command as the shared predicate over REPL-
reserved first words (exit, logout, self-update, update-niubash) and
consult it from the highlighter's command-position classification, so
these words get builtin styling instead of UnknownToken. Case-sensitive
by design, matching the REPL's exact-match intercepts; argument
positions are unaffected.

Tests: highlighter repaints the three words as Builtin, argument
position stays Default, predicate unit test covers exact-match
semantics.

* ci: gate the aarch64-linux-android and armv7-linux-androideabi cross-checks (niu#207 step 1)

rubash#456 landed the bionic cfg fixes, so both android targets now
check clean through rubash; this exposes them on the niubash side of
the workspace check, same shape as the musl/ohos legs (#210/#221).
Both targets verified green locally: cargo check --workspace --locked
--target aarch64-linux-android and --target armv7-linux-androideabi.

Two blockers surfaced and are fixed here:

- arboard 3.6.1 (via reedline's system_clipboard feature) has no
  android backend and fails to compile for android targets. Gate the
  feature to non-android targets in Cargo.toml: Windows/macOS/Linux
  builds keep the system clipboard (arboard stays in their graphs),
  android loses Ctrl+V system paste behind a stub
  add_system_clipboard_keybindings, bracketed paste unaffected.

- build.rs gated the icon .res embedding on #[cfg(windows)] - a HOST
  predicate. Cross-checking an android target from a Windows dev box
  made it run the SDK's arm64 rc.exe, an arm64 binary that cannot
  launch on x64 (os error 216). Gate on CARGO_CFG_TARGET_OS instead;
  the resource only links into PE binaries anyway. Ubuntu-hosted CI
  legs are unaffected either way.

Part of niubash#207 (platform roadmap) step 1/2: make the compile
surface visible and honest. Android remains compile-verified only -
no release artifacts until a native smoke gate exists per
docs/release.md red line.

* fix(main): rc-0 one-shot exits return from main so the history session-end write runs

Pre-existing master red (host_contract::history_and_fc_use_the_host_history_provider,
failing on CI since 130598a): a one-shot 'niu -c history -c' left the
history file holding the pre-clear list instead of truncating it.

Root cause: 130598a routed every one-shot exit through
finish_one_shot -> piped_stdout::finish_and_exit -> std::process::exit,
which skips Rust destructors. RubashHistoryProvider::drop is the only
thing that carries a GNU 'history -c' to the file at session end
(niubash#265), so rc-0 -c sessions stopped flushing. 484dad3 (the
original fast path) returned Ok(()) on rc 0 and only diverged on
nonzero codes - the Drop ran and the test passed.

finish_one_shot now calls piped_stdout::finish() and exits only on
nonzero codes; rc 0 returns to the caller. Arms that previously relied
on the always-diverging call tail now 'return Ok(())' explicitly so
they cannot fall through into the script/REPL arms.

Verified: the manual -c sequence (history; fc 2 / -s / -d 2 / -c) ends
with an empty history file; 'exit 5' still propagates rc 5; host_contract
and cwd_state suites green; cwd-state recording (the #272 feature)
still runs before both exit forms.

* fix(build): compile embed_windows_icon on every host - the call site is runtime-gated on the target OS

3ea224e (#207 step 1) moved the call site from host #[cfg(windows)] to a
CARGO_CFG_TARGET_OS runtime check so a Windows host cross-checking an
android target no longer runs the SDK's arm64 rc.exe (os error 216), but
left the definition behind #[cfg(windows)]. On a linux/macOS host the
call site now compiles while the definition is cfg'd out: E0425 on every
non-Windows host (ubuntu/macos/android/ohos/armv7 cross-checks).

Drop the cfg from the definition - it is std-only and dead unless the
target is Windows.
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.

1 participant