forked from xintaofei/codeg
-
Notifications
You must be signed in to change notification settings - Fork 0
148 lines (130 loc) · 5.63 KB
/
Copy pathtest.yml
File metadata and controls
148 lines (130 loc) · 5.63 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
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"
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 eslint .
- 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]
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 --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 --bin codeg-server --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