{{ message }}
Repository navigation
260 lines (234 loc) · 11.1 KB
/
Copy pathtest.yml
File metadata and controls
260 lines (234 loc) · 11.1 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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
name: Test
on:
push:
branches:
- main
pull_request:
env:
RUST_BACKTRACE: short
# Refuse to silently regenerate snapshots in CI — any drift must be
# accepted locally with `cargo insta review` and committed.
INSTA_UPDATE: "no"
# Debuginfo as line tables only (`test` inherits `dev`): backtraces keep
# their file:line, and the type and variable records no CI step reads are
# not built (on macOS they are most of codeg_lib's ~1 GB debug rlib). With
# them the desktop cell ran the 16 GB Windows runner out of commit ("The
# paging file is too small for this operation to complete. (os error
# 1455)"): rustc maps every upstream rlib copy-on-write, Windows charges
# such a view in full against RAM + pagefile, and the tests and bins that
# link codeg_lib each map their own view, in parallel.
CARGO_PROFILE_DEV_DEBUG: line-tables-only
concurrency:
group: test-${{ github.ref }}
cancel-in-progress: true
jobs:
frontend:
name: Frontend (lint + vitest + build)
# Frontend tests are OS-independent (jsdom + pure TS), keep on Linux
# to save CI minutes.
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
run_install: false
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 24
cache: "pnpm"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Lint
run: pnpm lint .
- name: Browser agent bundle matches its source
# `src-tauri/src/browser/js/agent.bundle.js` is committed so that a
# cargo build needs no node — `include_str!` reads it at compile time.
# A committed artifact is only worth anything if it is the one the
# source produces, and nothing else in the build would notice a stale
# one: the Rust side would happily embed last week's bundle.
run: pnpm browser:agent:check
- name: Browser agent typecheck
# `browser-agent/` is excluded from the app's tsconfig (its vendored
# half answers to Playwright's compiler settings, not ours), so the
# repo-wide typecheck in `pnpm build` never sees our entry point.
run: pnpm browser:agent:types
- name: Unit tests (vitest)
run: pnpm test
- name: Static export build
run: pnpm build
rust:
name: Rust ${{ matrix.mode }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, macos-latest, windows-latest]
mode: [desktop, server, cli]
include:
- mode: desktop
# `test-utils` exposes test scaffolding (AppState::new_for_test,
# EventEmitter::test_web_only, ConnectionManager::insert_test_connection,
# parser `with_base_dir`, `db::test_helpers`) for integration tests
# under `tests/`. Without the flag those items are physically
# uncompiled, so integration tests would fail to link.
cargo_args: "--features test-utils"
# Desktop clippy must lint integration tests too, so it picks up
# `--all-targets`. test-utils is already on, so tests compile.
clippy_args: "--all-targets --features test-utils"
- mode: server
# Server build is feature-gated off the Tauri runtime; no
# need for webkit/appindicator system libs. `--lib` skips
# integration tests for `cargo test`, so `test-utils` is not
# required here.
cargo_args: "--no-default-features --features server-bin --bin codeg-server --lib"
# Server clippy intentionally skips `--all-targets`: integration
# tests are already linted in the desktop cells, and pulling
# them in here would force `test-utils` (a test-only feature)
# into the server build matrix. Lint scope here is lib + the
# codeg-server binary, which is exactly the cfg-gated surface
# that this cell exists to verify.
clippy_args: "--no-default-features --features server-bin --bin codeg-server --lib"
- mode: cli
# The `codeg-cli` client (`src/cli/`), which only `cli-bin`
# compiles: the server cells leave it out, and the Windows
# desktop cell only builds its tests (`--no-run`), so without
# this cell they would never run on Windows. The runtime side
# (`cli_run`) is in the lib, which the server cells test already.
cargo_args: "--no-default-features --features cli-bin --lib cli::"
clippy_args: "--no-default-features --features cli-bin --bin codeg-cli --lib"
steps:
- uses: actions/checkout@v4
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Rust cache
uses: swatinem/rust-cache@v2
with:
workspaces: "./src-tauri -> target"
shared-key: test-${{ matrix.os }}-${{ matrix.mode }}
- name: Install Linux desktop dependencies
# Only the Linux desktop build needs webkit/appindicator. Windows
# ships WebView2 with the OS; macOS uses WKWebView from the SDK.
if: matrix.os == 'ubuntu-22.04' && matrix.mode == 'desktop'
run: |
sudo apt-get update
sudo apt-get install -y \
libwebkit2gtk-4.1-dev \
libayatana-appindicator3-dev \
librsvg2-dev
- name: Prepare Tauri frontendDist placeholder
# Tauri's build script validates `frontendDist` and bundled resource
# paths during Rust compilation. The frontend job owns the real static
# export; Rust desktop cells only need the path to exist for tests.
if: matrix.mode == 'desktop'
shell: bash
run: |
mkdir -p out
printf '<!doctype html><html><body></body></html>\n' > out/index.html
- name: cargo test
# Windows desktop test binaries link the Tauri runtime and can fail at
# process load on GitHub-hosted runners before Rust tests start. Keep
# compile coverage here; Linux/macOS desktop and Windows server cells
# run the executable test suites.
working-directory: src-tauri
run: cargo test ${{ matrix.cargo_args }} ${{ (matrix.os == 'windows-latest' && matrix.mode == 'desktop') && '--no-run' || '' }}
- name: cargo clippy
# Clippy on each (os, mode) cell — desktop covers tauri-only code
# paths plus integration tests, server covers cfg-gated server-only
# code. Treat warnings as errors now that the 8 pre-existing
# advisories are cleared.
working-directory: src-tauri
run: cargo clippy ${{ matrix.clippy_args }} -- -D warnings
- name: Web handlers must route through commands/*_core
# Lock in the dedup from Phase 8: web/handlers/{folders,conversations}.rs
# must not call DB services directly. They have to delegate to a
# `_core` function in `commands/*.rs` so the Tauri command and HTTP
# entrypoints share one implementation. Run on Linux only — pure
# text check, no per-OS variance.
if: matrix.os == 'ubuntu-22.04' && matrix.mode == 'desktop'
working-directory: src-tauri
run: |
if grep -nE 'folder_service::|conversation_service::|tab_service::|import_service::' \
src/web/handlers/folders.rs \
src/web/handlers/conversations.rs; then
echo "::error::Web handlers must call commands/*_core, not services directly."
exit 1
fi
install-sh:
# install.sh stops what runs the files it replaces, and nothing else: on
# Linux `cp` onto a running program fails, but the desktop app, other
# users, other directories and containers run a codeg-server or codeg-mcp
# of their own. The test runs the script's stop section against fake
# programs; the installer itself downloads a release and writes to
# /usr/local/bin, so it is not run. /bin/bash: on macOS that is 3.2, what
# `curl … | bash` gets there. Linux runs it once more as root, for
# processes of other mount namespaces.
name: install.sh on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, macos-latest]
steps:
- uses: actions/checkout@v4
- name: install.sh parses
run: /bin/bash -n install.sh
- name: install.sh stops only what runs the files it replaces
env:
CODEG_INSTALL_TEST_STRICT: "1"
run: /bin/bash scripts/test-install-stop.sh install.sh
- name: The same, as root
if: runner.os == 'Linux'
run: sudo CODEG_INSTALL_TEST_STRICT=1 /bin/bash scripts/test-install-stop.sh install.sh
install-ps1:
# Two Windows PowerShell 5.1 traps that PowerShell 7 never hits. First,
# `.\install.ps1` reads a script without a BOM in the ANSI code page,
# where a UTF-8 em-dash ends in a curly quote that closes the string it is
# in — and then the whole script fails to parse (`irm … | iex` decodes
# UTF-8, so it is spared this one). Second, Join-Path takes two paths: a
# third fails when its line runs, however the script was loaded — the
# README's `irm … | iex` included.
name: install.ps1 in Windows PowerShell 5.1
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Check install.ps1 as Windows PowerShell 5.1 reads and runs it
shell: powershell
run: |
$bytes = [System.IO.File]::ReadAllBytes((Join-Path $PWD "install.ps1"))
if ($bytes.Length -ge 3 -and $bytes[0] -eq 0xEF -and $bytes[1] -eq 0xBB -and $bytes[2] -eq 0xBF) {
$text = [System.Text.Encoding]::UTF8.GetString($bytes, 3, $bytes.Length - 3)
} else {
$text = [System.Text.Encoding]::Default.GetString($bytes)
}
$tokens = $null
$errors = $null
$ast = [System.Management.Automation.Language.Parser]::ParseInput($text, [ref]$tokens, [ref]$errors)
if ($errors) {
foreach ($e in $errors) {
Write-Host "::error file=install.ps1,line=$($e.Extent.StartLineNumber)::$($e.Message)"
}
exit 1
}
# Windows PowerShell 5.1's Join-Path takes two paths (it has no
# -AdditionalChildPath): a third fails when the line runs, not when
# the script parses.
$bad = $false
$calls = $ast.FindAll({
param($node)
$node -is [System.Management.Automation.Language.CommandAst] -and
$node.GetCommandName() -eq "Join-Path"
}, $true)
foreach ($call in $calls) {
$paths = @($call.CommandElements | Select-Object -Skip 1 | Where-Object {
$_ -isnot [System.Management.Automation.Language.CommandParameterAst]
})
if ($paths.Count -gt 2) {
Write-Host "::error file=install.ps1,line=$($call.Extent.StartLineNumber)::Join-Path with $($paths.Count) paths fails in Windows PowerShell 5.1"
$bad = $true
}
}
if ($bad) { exit 1 }
You can’t perform that action at this time.
