mirror of
https://github.com/lahfir/agent-desktop.git
synced 2026-08-06 14:10:43 +00:00
P1: last_error_survives_successful_calls used ad_check_permissions as a success-only probe but it returns ErrPermDenied without Accessibility permission, overwriting the TLS error slot. Replaced with null-tolerant list accessors that never set last-error. P2: build.rs auto-copied the generated header into include/, making the CI drift check self-heal instead of catching stale ABI. Removed the copy step; CI now diffs OUT_DIR output against the committed header. Added scripts/update-ffi-header.sh for developers. P2: ad_free_handle suppressed ActionNotSupported but the default adapter returns PlatformNotSupported. Added PlatformNotSupported to the match. P3: ad_get_clipboard returned Ok with *out=NULL when clipboard text had an interior NUL. Now returns ErrInternal with a diagnostic message.
108 lines
3.4 KiB
YAML
108 lines
3.4 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main, master]
|
|
pull_request:
|
|
workflow_dispatch:
|
|
|
|
# Cancel in-progress runs for the same ref so stale PR builds don't burn minutes.
|
|
concurrency:
|
|
group: ci-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
# Deny all permissions at workflow level; each job declares only what it needs.
|
|
permissions: {}
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
RUST_BACKTRACE: 1
|
|
|
|
jobs:
|
|
fmt:
|
|
name: Format
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 10
|
|
permissions:
|
|
contents: read
|
|
steps:
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
- run: rustup component add rustfmt
|
|
- run: cargo fmt --all -- --check
|
|
|
|
test:
|
|
name: Test
|
|
runs-on: macos-latest
|
|
timeout-minutes: 30
|
|
permissions:
|
|
contents: read
|
|
steps:
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
|
|
- name: Install Rust toolchain
|
|
run: rustup show
|
|
|
|
- name: Cache cargo registry
|
|
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
|
with:
|
|
path: |
|
|
~/.cargo/registry/index/
|
|
~/.cargo/registry/cache/
|
|
~/.cargo/git/db/
|
|
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}
|
|
restore-keys: ${{ runner.os }}-cargo-
|
|
|
|
- name: Cache build artifacts
|
|
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
|
with:
|
|
path: target/
|
|
key: ${{ runner.os }}-build-ci-${{ hashFiles('**/Cargo.toml') }}-${{ hashFiles('**/*.rs') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-build-ci-${{ hashFiles('**/Cargo.toml') }}-
|
|
${{ runner.os }}-build-ci-
|
|
|
|
- name: Check dependency isolation
|
|
run: |
|
|
if cargo tree -p agent-desktop-core 2>/dev/null | grep -E 'agent-desktop-(macos|windows|linux)'; then
|
|
echo "FAIL: core crate depends on platform crates"
|
|
exit 1
|
|
fi
|
|
echo "OK: core crate has no platform dependencies"
|
|
|
|
- name: Clippy
|
|
run: cargo clippy --all-targets -- -D warnings
|
|
|
|
- name: Unit tests
|
|
run: cargo test --lib --workspace
|
|
|
|
# Use the ci profile (no LTO, opt-level 1) — fast compile, still checks the binary builds.
|
|
- name: Build binary (ci profile)
|
|
run: cargo build --profile ci
|
|
|
|
- name: Check binary size
|
|
run: |
|
|
SIZE=$(stat -f%z target/ci/agent-desktop)
|
|
LIMIT=$((15 * 1024 * 1024))
|
|
echo "Binary size: $(du -sh target/ci/agent-desktop | cut -f1)"
|
|
if [ "$SIZE" -gt "$LIMIT" ]; then
|
|
echo "FAIL: binary exceeds 15MB limit (${SIZE} bytes)"
|
|
exit 1
|
|
fi
|
|
echo "OK: binary within 15MB limit"
|
|
|
|
- name: FFI cdylib build (release-ffi profile)
|
|
run: cargo build --profile release-ffi -p agent-desktop-ffi
|
|
|
|
- name: FFI header drift check
|
|
run: |
|
|
GENERATED=$(find target -path '*/agent-desktop-ffi-*/out/agent_desktop.h' | head -1)
|
|
if [ -z "$GENERATED" ]; then
|
|
echo "FAIL: cbindgen did not produce a header in OUT_DIR"
|
|
exit 1
|
|
fi
|
|
if ! diff -u crates/ffi/include/agent_desktop.h "$GENERATED"; then
|
|
echo "FAIL: crates/ffi/include/agent_desktop.h is out of date"
|
|
echo "Run 'scripts/update-ffi-header.sh' locally and commit the regenerated header."
|
|
exit 1
|
|
fi
|
|
echo "OK: FFI header is in sync with source"
|