1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: CI
# The gates that used to exist only as habit on one Mac.
#
# The cross-build jobs are the point. `croft <host>` cross-compiles a static
# binary locally and ships it; when the pinned toolchain lacks a target, that
# path silently degrades to a full `cargo install` on the user's box, with
# nothing but a line in ~/.cache/croft/install.log to say so. Rustup targets
# belong to ONE toolchain, so bumping rust-toolchain.toml orphans every one of
# them - which is what the 1.95.0 -> 1.97.1 bump did, unnoticed for four days.
#
# These jobs run the REAL build (zig for musl, the NDK for Android), not
# `cargo check`: croft's tree-sitter grammars are C, so their build scripts
# need a working cross C compiler and a check alone fails before it can prove
# anything useful.
on:
push:
branches:
pull_request:
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
test:
name: clippy + tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# The suite's terminal tests drive /bin/zsh (the shim they exist to
# cover) and the PDF tests rasterise through poppler's pdftoppm - the
# same binaries croft needs at runtime on a Linux box. The runner
# ships neither.
- name: Install suite runtime dependencies
# The chmod keeps compinit's "insecure directories" interactive
# prompt from wedging every spawned zsh before its first prompt
# (croft never calls compinit; the runner's own zsh startup does).
run: |
sudo apt-get update && sudo apt-get install -y --no-install-recommends zsh poppler-utils
for d in /usr/share/zsh /usr/local/share/zsh; do
if [ -d "$d" ]; then sudo chmod -R go-w "$d"; fi
done
# rust-toolchain.toml is the single source of truth; `rustup show`
# installs exactly the pinned channel and its components.
- name: Install the pinned toolchain
run: rustup show
- uses: Swatinem/rust-cache@v2
- name: Formatting (pinned rustfmt, zero diffs)
run: cargo fmt --check
- name: Clippy (zero warnings)
run: cargo clippy --all-targets -- -D warnings
- name: Tests
# The suite spawns PTYs and real shells; keep the thread count modest
# so the timing-sensitive terminal tests are not starved.
run: cargo test --locked
env:
RUST_TEST_THREADS: 4
cross-musl:
name: ship-path build (${{ matrix.target }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# CROSS_TARGETS in src/cli.rs: the triples `croft <host>` ships.
target:
- x86_64-unknown-linux-musl
- aarch64-unknown-linux-musl
steps:
- uses: actions/checkout@v4
- name: Install the pinned toolchain
run: rustup show
- name: Add the target to the PINNED toolchain
# Run from the checkout so rust-toolchain.toml resolves the channel.
# Adding to the default toolchain instead is precisely the bug this
# job exists to catch.
run: rustup target add ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Install zig and cargo-zigbuild
# cargo-zigbuild probes `python3 -m ziglang` before looking for a zig
# binary on PATH. Recent runner images mark the system Python as
# externally managed, so pip needs the override.
run: |
python3 -m pip install --break-system-packages ziglang \
|| python3 -m pip install ziglang
python3 -m ziglang version
cargo install cargo-zigbuild --locked
# Byte-for-byte the command src/remote.rs runs for a remote install.
- name: cargo zigbuild --profile remote-fast
run: cargo zigbuild --profile remote-fast --locked --bin croft --target ${{ matrix.target }}
- name: The shipped artifact must exist and be a Linux ELF
run: |
bin="target/${{ matrix.target }}/remote-fast/croft"
test -x "$bin"
file "$bin"
file "$bin" | grep -q 'ELF 64-bit LSB'
android:
name: Android build (aarch64-linux-android)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install the pinned toolchain
run: rustup show
- name: Add the Android target to the PINNED toolchain
run: rustup target add aarch64-linux-android
- uses: Swatinem/rust-cache@v2
with:
key: aarch64-linux-android
- name: Install cargo-ndk
run: cargo install cargo-ndk --locked
# Termux builds croft natively on the phone, so nothing ships this
# artifact. Compiling it here is what catches code that cannot build on
# Android at all - otherwise the only way to find out is on the device,
# by hand, after the fact. cargo-ndk wires the runner's NDK into the C
# build scripts the tree-sitter grammars need.
- name: cargo ndk build
# ANDROID_NDK_LATEST_HOME is exported by the runner image into the
# process environment, which the `env` context does NOT see - so it
# has to be expanded by the shell, not by an expression.
# --platform 24: bionic only exports openpty/forkpty from API 23,
# and cargo-ndk's default level is older, so the link dies on
# `undefined symbol: openpty`. 24 is what Termux itself targets.
run: |
export ANDROID_NDK_HOME="$ANDROID_NDK_LATEST_HOME"
echo "Using NDK at $ANDROID_NDK_HOME"
test -d "$ANDROID_NDK_HOME"
cargo ndk --target arm64-v8a --platform 24 build --locked --bin croft