Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[profile.default]
# Keep nextest's 200 ms threshold, but do not accept leaked output handles as a pass.
leak-timeout = { period = "200ms", result = "fail" }

[[profile.default.overrides]]
# This otherwise starts near the end and leaves the other test workers idle.
filter = 'test(=highlight::tests::shipped_syntax_set_compiles_under_active_regex_backend)'
priority = 100
152 changes: 116 additions & 36 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,71 @@ env:
RUST_BACKTRACE: 1

jobs:
desktop:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
# Not a matrix: a job can only wait for a whole matrix, and each platform's
# required check must wait for that platform's Clippy and tests alone.
linux-clippy:
name: Linux x64 / clippy
runs-on: ubuntu-24.04
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
include:
- name: Linux x64
os: ubuntu-24.04
- name: macOS arm64
os: macos-26
- name: Windows x64
os: windows-2022
steps:
- uses: actions/checkout@v7
steps: &clippy-steps
- &checkout
uses: actions/checkout@v7

- name: Disable Windows Defender real-time scanning
- &disable-defender
name: Disable Windows Defender real-time scanning
if: runner.os == 'Windows'
shell: pwsh
continue-on-error: true
run: Set-MpPreference -DisableRealtimeMonitoring $true

- name: Install stable Rust
- &install-rust
name: Install stable Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy

# Clippy restores the test jobs' cache but never saves its own: it already
# finishes before the tests, and a second cache per platform would overflow
# the repository's Actions cache quota and evict the test caches.
- name: Restore Cargo build data
uses: Swatinem/rust-cache@v2
with:
shared-key: ci-${{ runner.os }}-${{ runner.arch }}
save-if: false

- &install-linux-dependencies
name: Install Linux system dependencies
if: runner.os == 'Linux'
run: |
# The Azure mirror has delivered packages at ~65 kB/s on these runners.
for source in /etc/apt/sources.list.d/ubuntu.sources /etc/apt/apt-mirrors.txt; do
if [[ -f "$source" ]]; then
sudo sed -i 's|http://azure\.archive\.ubuntu\.com/ubuntu|https://archive.ubuntu.com/ubuntu|g' "$source"
fi
done
apt_get=(sudo apt-get -o Acquire::ForceIPv4=true -o Acquire::Retries=3)
"${apt_get[@]}" update
"${apt_get[@]}" install -y --no-install-recommends \
build-essential clang cmake pkg-config libssl-dev libzstd-dev \
libasound2-dev libfontconfig-dev libwayland-dev libxkbcommon-dev \
libxkbcommon-x11-dev libx11-xcb-dev libxcb1-dev libgbm-dev \
libvulkan-dev xvfb

- name: Check formatting
run: cargo fmt --all --check

- name: Run Clippy
run: cargo clippy --workspace --all-targets --locked -- -D warnings

linux-tests:
name: Linux x64 / tests
runs-on: ubuntu-24.04
timeout-minutes: 60
steps: &test-steps
- *checkout
- *disable-defender
- *install-rust

# Only main writes the cache so pull requests share one warm copy per
# platform instead of evicting each other from the repository quota.
- name: Cache Cargo build data
Expand All @@ -73,26 +110,15 @@ jobs:
Expand-Archive -Path $archive -DestinationPath "$env:USERPROFILE\.cargo\bin" -Force
cargo nextest --version

- name: Install Linux system dependencies
if: runner.os == 'Linux'
run: |
apt_get=(sudo apt-get -o Acquire::ForceIPv4=true -o Acquire::Retries=3)
"${apt_get[@]}" update
"${apt_get[@]}" install -y --no-install-recommends \
build-essential clang cmake pkg-config libssl-dev libzstd-dev \
libasound2-dev libfontconfig-dev libwayland-dev libxkbcommon-dev \
libxkbcommon-x11-dev libx11-xcb-dev libxcb1-dev libgbm-dev \
libvulkan-dev xvfb
if cargo tree -e normal -i glib-sys >/dev/null 2>&1; then
"${apt_get[@]}" install -y --no-install-recommends \
libgtk-3-dev libwebkit2gtk-4.1-dev
fi

- name: Check formatting
run: cargo fmt --all --check
- *install-linux-dependencies

- name: Run Clippy
run: cargo clippy --workspace --all-targets --locked -- -D warnings
# Two slots per CPU: most tests wait on child processes rather than compute.
- name: Set nextest test concurrency
shell: python
run: |
import os
with open(os.environ["GITHUB_ENV"], "a") as env_file:
env_file.write(f"NEXTEST_TEST_THREADS={os.cpu_count() * 2}\n")

- name: Run tests
if: runner.os != 'Linux'
Expand All @@ -106,6 +132,60 @@ jobs:
if: runner.os == 'Linux'
run: xvfb-run -a cargo nextest run --workspace --locked

macos-clippy:
name: macOS arm64 / clippy
runs-on: macos-26
timeout-minutes: 60
steps: *clippy-steps

macos-tests:
name: macOS arm64 / tests
runs-on: macos-26
timeout-minutes: 60
steps: *test-steps

windows-clippy:
name: Windows x64 / clippy
runs-on: windows-2022
timeout-minutes: 60
steps: *clippy-steps

windows-tests:
name: Windows x64 / tests
runs-on: windows-2022
timeout-minutes: 60
steps: *test-steps

# The required checks keep their platform names. A skipped or cancelled job
# must not let its platform's check pass.
linux:
name: Linux x64
needs: [linux-clippy, linux-tests]
if: always()
runs-on: ubuntu-24.04
timeout-minutes: 5
steps: &require-platform
- name: Require the platform's Clippy and tests
env:
RESULTS: ${{ join(needs.*.result, ' ') }}
run: test "$RESULTS" = "success success"

macos:
name: macOS arm64
needs: [macos-clippy, macos-tests]
if: always()
runs-on: ubuntu-24.04
timeout-minutes: 5
steps: *require-platform

windows:
name: Windows x64
needs: [windows-clippy, windows-tests]
if: always()
runs-on: ubuntu-24.04
timeout-minutes: 5
steps: *require-platform

dependencies:
name: Dependency hygiene
runs-on: ubuntu-24.04
Expand Down
31 changes: 2 additions & 29 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ concurrency:
group: release-${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }}
cancel-in-progress: false

# Tag-scoped Cargo caches cannot warm the next release and evict the main CI
# caches from the shared Actions quota.
jobs:
setup:
runs-on: ubuntu-24.04
Expand Down Expand Up @@ -98,11 +100,6 @@ jobs:
with:
targets: ${{ matrix.target }}

- name: Cache Cargo build data
uses: Swatinem/rust-cache@v2
with:
shared-key: release-${{ matrix.target }}

- name: Install Linux system dependencies
if: matrix.platform == 'linux'
run: |
Expand All @@ -112,10 +109,6 @@ jobs:
build-essential clang cmake pkg-config libssl-dev libzstd-dev \
libasound2-dev libfontconfig-dev libwayland-dev libxkbcommon-dev \
libxkbcommon-x11-dev libx11-xcb-dev libxcb1-dev libgbm-dev libvulkan-dev
if cargo tree -e normal -i glib-sys >/dev/null 2>&1; then
"${apt_get[@]}" install -y --no-install-recommends \
libgtk-3-dev libwebkit2gtk-4.1-dev
fi

- name: Build release binary
shell: bash
Expand Down Expand Up @@ -416,11 +409,6 @@ jobs:
with:
targets: wasm32-unknown-unknown

- name: Cache Cargo build data
uses: Swatinem/rust-cache@v2
with:
shared-key: release-web-bundle

- name: Install wasm tools
run: |
cargo install wasm-bindgen-cli --version 0.2.127 --locked
Expand Down Expand Up @@ -504,11 +492,6 @@ jobs:
with:
targets: ${{ matrix.target }}

- name: Cache Cargo build data
uses: Swatinem/rust-cache@v2
with:
shared-key: release-headless-${{ matrix.target }}

- name: Install Linux system dependencies
if: matrix.platform == 'linux'
run: |
Expand Down Expand Up @@ -614,11 +597,6 @@ jobs:
with:
targets: ${{ matrix.target }}

- name: Cache Cargo build data
uses: Swatinem/rust-cache@v2
with:
shared-key: release-traverse-${{ matrix.target }}

- name: Install Linux system dependencies
if: matrix.platform == 'linux'
run: |
Expand Down Expand Up @@ -683,11 +661,6 @@ jobs:
with:
targets: aarch64-linux-android

- name: Cache Cargo build data
uses: Swatinem/rust-cache@v2
with:
shared-key: release-android-arm64

- name: Set up JDK 21
uses: actions/setup-java@v6
with:
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions crates/agent/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ process = [
"dep:smol",
"dep:ureq",
"dep:uuid",
"dep:windows",
]

[dependencies]
Expand All @@ -31,6 +32,9 @@ smol = { version = "2", optional = true }
ureq = { version = "2", default-features = false, features = ["tls", "gzip"], optional = true }
uuid = { version = "1", features = ["v4"], optional = true }

[target.'cfg(windows)'.dependencies]
windows = { version = "=0.62.2", features = ["Win32_Foundation"], optional = true }

[dev-dependencies]
env_logger = "0.11"
toml = "1.1"
Expand Down
2 changes: 2 additions & 0 deletions crates/agent/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ pub mod pi;
#[cfg(feature = "process")]
mod process;
#[cfg(feature = "process")]
pub use process::keep_own_stdio_from_children;
#[cfg(feature = "process")]
mod subagent_tail;

use std::path::PathBuf;
Expand Down
36 changes: 35 additions & 1 deletion crates/agent/src/process.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Child-process constructors that never flash a console window on Windows.
//! Child-process constructors that never flash a console window on Windows,
//! and never hand a child this process's own standard handles.
//!
//! Provider CLIs are spawned from a GUI app; a plain `Command` on Windows
//! allocates a console for the child, which pops a black box on screen.
Expand All @@ -17,8 +18,41 @@ const STDERR_TAIL_LINES: usize = 20;
#[cfg(windows)]
const CREATE_NO_WINDOW: u32 = 0x0800_0000;

/// Keep this process's own standard handles out of every child it starts.
///
/// Windows gives a child each inheritable handle of its parent, not only the
/// stdio its `Command` names, so a child that outlives the parent keeps open
/// the pipes whoever runs the parent reads from. A child spawned with
/// `Stdio::inherit` still gets them: std hands it an inheritable duplicate.
/// No-op elsewhere.
pub fn keep_own_stdio_from_children() {
#[cfg(windows)]
{
use std::os::windows::io::AsRawHandle as _;
use windows::Win32::Foundation::{
HANDLE, HANDLE_FLAG_INHERIT, HANDLE_FLAGS, SetHandleInformation,
};
static ONCE: std::sync::Once = std::sync::Once::new();
ONCE.call_once(|| {
for handle in [
std::io::stdin().as_raw_handle(),
std::io::stdout().as_raw_handle(),
std::io::stderr().as_raw_handle(),
] {
// SAFETY: these are this process's standard handles, open for
// its lifetime; a missing one only makes the call fail, which
// leaves nothing to keep from a child.
let _ = unsafe {
SetHandleInformation(HANDLE(handle), HANDLE_FLAG_INHERIT.0, HANDLE_FLAGS(0))
};
}
});
}
}

/// A blocking `std::process::Command` with the console suppressed.
pub(crate) fn command<S: AsRef<std::ffi::OsStr>>(program: S) -> std::process::Command {
keep_own_stdio_from_children();
#[cfg_attr(not(windows), allow(unused_mut))]
// Approved constructor: this is the helper every other site must use.
#[allow(clippy::disallowed_methods)]
Expand Down
10 changes: 9 additions & 1 deletion crates/runtime/src/app/pull_request_watch_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,10 @@ impl Harness {
] {
self.events.try_send(event).unwrap();
}
// The host's event pump queues each event for the host as it takes it,
// whether or not the host still acts on it.
let events = self.events.clone();
self.cx.run_until(|_| events.is_empty());
self.cx.run_until_parked();
}

Expand Down Expand Up @@ -837,7 +841,11 @@ fn a_wake_steers_into_a_running_turn_and_is_not_repeated() {
.events
.try_send(AgentEvent::TurnAccepted { delivery_id })
.unwrap();
harness.cx.run_until_parked();
harness.cx.run_until(|state| {
state
.resident("thread")
.is_some_and(|session| session.delivery_in_flight.is_none() && session.turn_in_flight)
});

harness.pass();
let commands = harness.commands.clone();
Expand Down
Loading
Loading