-
Notifications
You must be signed in to change notification settings - Fork 5
236 lines (198 loc) · 8.2 KB
/
tests.yml
File metadata and controls
236 lines (198 loc) · 8.2 KB
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
name: Tests
# PR-time gate: runs Rust + plugin unit tests, Linux Docker e2e, and Windows e2e
# before merge. Tag pushes go through `release.yml` which independently runs the
# build matrix and publishes — both workflows call the SAME reusable e2e suite
# (`_e2e-suite.yml`) so PR-time and release-time e2e never drift.
#
# IMPORTANT: any change to bridge transport, bash spawning, ONNX install,
# locking, or platform-conditional code paths SHOULD touch the matching
# integration test or e2e scenario in `_e2e-suite.yml`. The Linux harness has
# caught real regressions before; the Windows e2e is here to extend that
# coverage to issue-#26-class Windows-specific bugs (bash timeouts, lock
# recovery, path separators).
on:
pull_request:
paths:
- "crates/**"
- "packages/**"
- "tests/**"
- "Cargo.toml"
- "Cargo.lock"
- "package.json"
- "bun.lock"
- ".github/opencode-version.txt"
- ".github/workflows/tests.yml"
- ".github/workflows/_e2e-suite.yml"
push:
branches:
- main
paths:
- "crates/**"
- "packages/**"
- "tests/**"
- "Cargo.toml"
- "Cargo.lock"
- "package.json"
- "bun.lock"
- ".github/opencode-version.txt"
- ".github/workflows/tests.yml"
- ".github/workflows/_e2e-suite.yml"
workflow_dispatch:
inputs:
ref:
description: "Git ref to test (branch name, tag, or commit SHA)"
required: false
type: string
# Cancel in-flight runs for the same PR/branch when a new commit arrives.
# Saves CI minutes and surfaces the latest result faster.
concurrency:
group: tests-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
# ---------------------------------------------------------------------------
# Rust + plugin unit tests on Linux (fast inner loop)
# ---------------------------------------------------------------------------
unit:
name: Unit tests (Linux)
runs-on: ubuntu-22.04
timeout-minutes: 25
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install workspace deps
run: bun install --frozen-lockfile
- name: Build aft-bridge dist (workspace consumers depend on it)
run: bun run --cwd packages/aft-bridge build
- name: Cargo build (debug — needed by plugin e2e tests)
run: cargo build -p agent-file-tools
- name: Cargo test
run: cargo test --workspace
- name: Bun typecheck
run: bun run typecheck
- name: Bun lint
run: bun run lint
- name: Bun test (all packages)
run: bun run test
env:
# Tests don't need real cache locations — keep them out of the runner's
# ~/.cache to avoid cross-test pollution.
AFT_CACHE_DIR: ${{ runner.temp }}/aft-cache
# ---------------------------------------------------------------------------
# Rust + plugin tests on macOS
# Catches macOS-specific code paths: FSEvents watcher behavior (different
# coalescing latency from inotify), /var vs /private/var symlink
# canonicalization, broken-symlink-chain fallback, bash_background SIGTERM
# behavior, and Apple Silicon-specific Rust compilation. The build-darwin-*
# jobs in release.yml only run `cargo build` — this is the only place we
# actually execute tests on macOS in CI.
# ---------------------------------------------------------------------------
rust-macos:
name: Unit tests (macOS)
runs-on: macos-latest
timeout-minutes: 25
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install workspace deps
run: bun install --frozen-lockfile
- name: Build aft-bridge dist (workspace consumers depend on it)
run: bun run --cwd packages/aft-bridge build
- name: Cargo build (debug — needed by plugin e2e tests)
run: cargo build -p agent-file-tools
- name: Cargo test
run: cargo test --workspace
- name: Bun typecheck
run: bun run typecheck
- name: Bun test (all packages)
run: bun run test
env:
AFT_CACHE_DIR: ${{ runner.temp }}/aft-cache
# ---------------------------------------------------------------------------
# Rust integration tests on Windows
# Catches platform-conditional code paths (#[cfg(target_os = "windows")])
# and Windows process/path/signal differences. Same suite as Linux but on a
# real Windows runner — does NOT spin up OpenCode, that's the e2e job below.
# ---------------------------------------------------------------------------
rust-windows:
name: Cargo test (Windows)
runs-on: windows-2022
timeout-minutes: 30
# Non-blocking on Windows: many integration tests build NDJSON
# requests by hand-formatting paths via `r#"...{path.display()}..."#`,
# which produces invalid JSON on Windows because backslashes in
# `C:\Users\...` get parsed as escape sequences. Migrating ~150
# call sites to `serde_json::json!` is a separate cleanup; the
# production code path is platform-clean (538 lib tests pass on
# Windows runners, plus the Windows native E2E job below covers
# the integration layer). Tracked for follow-up.
continue-on-error: true
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-pc-windows-msvc
- uses: Swatinem/rust-cache@v2
- name: Cargo test (lib only — integration tests need JSON path-escape cleanup)
run: cargo test --workspace --lib
shell: pwsh
# ---------------------------------------------------------------------------
# Bash permission flow on Windows
# Scoped to bash.test.ts only: covers the runAsk + Effect runtime path on
# Windows for OS-parity peace of mind. The runAsk fix itself is platform-
# agnostic JavaScript semantics — Linux/macOS in the `unit` and `rust-macos`
# jobs already cover that. Running the full plugin bun suite on Windows
# blocks on broader integration-harness JSON-path escape issues (see
# rust-windows comment), so we scope this to one test file.
#
# Why a real bun runner on Windows: this exercises the BinaryBridge
# spawning aft.exe over NDJSON via stdio on the Windows process model. It
# catches a class of bugs that Linux+macOS bun + Windows native E2E miss
# individually — Effect-runtime semantics under bun's Windows process
# spawn implementation. Non-blocking for now; promote to required once we
# have N green runs.
# ---------------------------------------------------------------------------
bun-windows-bash:
name: Bash permission e2e (Windows)
runs-on: windows-2022
timeout-minutes: 20
continue-on-error: true
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install workspace deps
run: bun install --frozen-lockfile
shell: pwsh
- name: Build aft-bridge dist (workspace consumers depend on it)
run: bun run --cwd packages/aft-bridge build
shell: pwsh
- name: Cargo build (debug — bash.test.ts spawns the real aft binary)
run: cargo build -p agent-file-tools
shell: pwsh
- name: Bun test (bash permission flow — full bridge + plugin + Rust)
run: bun test src/__tests__/e2e/bash.test.ts
working-directory: packages/opencode-plugin
shell: pwsh
env:
AFT_CACHE_DIR: ${{ runner.temp }}/aft-cache
# ---------------------------------------------------------------------------
# Linux Docker e2e + Windows native e2e — single source of truth shared
# with release.yml. See `_e2e-suite.yml` for the actual job definitions.
# ---------------------------------------------------------------------------
e2e:
name: E2E
needs: unit
uses: ./.github/workflows/_e2e-suite.yml