1+ name : Pre Check
2+
3+ on :
4+ push :
5+ branches : [ dev ]
6+ pull_request :
7+ branches : [ dev ]
8+
9+ env :
10+ CARGO_TERM_COLOR : always
11+ NODE_VERSION : ' 18'
12+ RUST_VERSION : ' 1.85.0'
13+ PNPM_VERSION : ' 8'
14+
15+ jobs :
16+ # 前端检查和测试
17+ frontend :
18+ name : Frontend Check
19+ runs-on : ubuntu-latest
20+
21+ steps :
22+ - name : Checkout repository
23+ uses : actions/checkout@v4
24+
25+ - name : Setup Node.js
26+ uses : actions/setup-node@v4
27+ with :
28+ node-version : ${{ env.NODE_VERSION }}
29+
30+ - name : Setup pnpm
31+ uses : pnpm/action-setup@v2
32+ with :
33+ version : ${{ env.PNPM_VERSION }}
34+
35+ - name : Get pnpm store directory
36+ id : pnpm-cache
37+ shell : bash
38+ run : |
39+ echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
40+
41+ - name : Setup pnpm cache
42+ uses : actions/cache@v3
43+ with :
44+ path : ${{ steps.pnpm-cache.outputs.STORE_PATH }}
45+ key : ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
46+ restore-keys : |
47+ ${{ runner.os }}-pnpm-store
48+
49+ - name : Install dependencies
50+ run : |
51+ if [ -f "pnpm-lock.yaml" ]; then
52+ pnpm install --frozen-lockfile
53+ else
54+ pnpm install
55+ fi
56+
57+ - name : Type check
58+ run : pnpm vue-tsc --noEmit
59+
60+ - name : Build frontend
61+ run : pnpm build
62+
63+ # 后端检查和测试
64+ backend :
65+ name : Backend Check
66+ runs-on : ${{ matrix.platform }}
67+
68+ strategy :
69+ fail-fast : false
70+ matrix :
71+ platform : [ macos-latest, windows-latest ]
72+
73+ steps :
74+ - name : Checkout repository
75+ uses : actions/checkout@v4
76+
77+ - name : Setup Rust
78+ uses : dtolnay/rust-toolchain@stable
79+ with :
80+ toolchain : ${{ env.RUST_VERSION }}
81+ components : rustfmt, clippy
82+
83+ - name : Rust Cache
84+ uses : Swatinem/rust-cache@v2
85+ with :
86+ workspaces : src-tauri
87+
88+ - name : Rust format check
89+ run : cargo fmt --all --manifest-path src-tauri/Cargo.toml -- --check
90+
91+ - name : Rust clippy check
92+ run : cargo clippy --manifest-path src-tauri/Cargo.toml --all-targets --all-features -- -D warnings
93+
94+ - name : Build backend
95+ run : cargo build --manifest-path src-tauri/Cargo.toml
96+
97+ - name : Run backend tests
98+ run : cargo test --manifest-path src-tauri/Cargo.toml
99+
100+ # 完整应用构建测试
101+ build :
102+ name : Build Application
103+ needs : [ frontend, backend ]
104+ runs-on : ${{ matrix.platform }}
105+
106+ strategy :
107+ fail-fast : false
108+ matrix :
109+ platform : [ macos-latest, windows-latest ]
110+
111+ steps :
112+ - name : Checkout repository
113+ uses : actions/checkout@v4
114+
115+ - name : Setup Node.js
116+ uses : actions/setup-node@v4
117+ with :
118+ node-version : ${{ env.NODE_VERSION }}
119+
120+ - name : Setup pnpm
121+ uses : pnpm/action-setup@v2
122+ with :
123+ version : ${{ env.PNPM_VERSION }}
124+
125+ - name : Setup Rust
126+ uses : dtolnay/rust-toolchain@stable
127+ with :
128+ toolchain : ${{ env.RUST_VERSION }}
129+
130+ - name : Rust Cache
131+ uses : Swatinem/rust-cache@v2
132+ with :
133+ workspaces : src-tauri
134+
135+ - name : Install frontend dependencies
136+ run : |
137+ if [ -f "pnpm-lock.yaml" ]; then
138+ pnpm install --frozen-lockfile
139+ else
140+ pnpm install
141+ fi
142+ shell : bash
143+
144+ - name : Build application
145+ run : pnpm tauri build
146+
147+ - name : Upload build artifacts (macOS)
148+ if : matrix.platform == 'macos-latest'
149+ uses : actions/upload-artifact@v4
150+ with :
151+ name : macos-build
152+ path : src-tauri/target/release/bundle/
153+ retention-days : 7
154+
155+ - name : Upload build artifacts (Windows)
156+ if : matrix.platform == 'windows-latest'
157+ uses : actions/upload-artifact@v4
158+ with :
159+ name : windows-build
160+ path : src-tauri/target/release/bundle/
161+ retention-days : 7
162+
163+ # 代码质量检查
164+ quality :
165+ name : Code Quality
166+ runs-on : ubuntu-latest
167+
168+ steps :
169+ - name : Checkout repository
170+ uses : actions/checkout@v4
171+ with :
172+ fetch-depth : 0 # 获取完整历史,用于 SonarCloud
173+
174+ - name : Setup Node.js
175+ uses : actions/setup-node@v4
176+ with :
177+ node-version : ${{ env.NODE_VERSION }}
178+
179+ - name : Setup pnpm
180+ uses : pnpm/action-setup@v2
181+ with :
182+ version : ${{ env.PNPM_VERSION }}
183+
184+ - name : Setup Rust
185+ uses : dtolnay/rust-toolchain@stable
186+ with :
187+ toolchain : ${{ env.RUST_VERSION }}
188+
189+ - name : Install dependencies
190+ run : |
191+ if [ -f "pnpm-lock.yaml" ]; then
192+ pnpm install --frozen-lockfile
193+ else
194+ pnpm install
195+ fi
196+
197+ - name : Generate coverage report
198+ run : |
199+ pnpm vitest run --coverage || true
200+ continue-on-error : true
201+
202+ - name : Check bundle size
203+ run : pnpm build && du -sh dist/
204+
205+ - name : Security audit (npm)
206+ run : pnpm audit || true
207+ continue-on-error : true
208+
209+ - name : Security audit (cargo)
210+ run : |
211+ cargo install cargo-audit
212+ cargo audit --file src-tauri/Cargo.lock || true
213+ continue-on-error : true
214+
215+ # 依赖检查
216+ dependencies :
217+ name : Dependencies Check
218+ runs-on : ubuntu-latest
219+
220+ steps :
221+ - name : Checkout repository
222+ uses : actions/checkout@v4
223+
224+ - name : Setup Node.js
225+ uses : actions/setup-node@v4
226+ with :
227+ node-version : ${{ env.NODE_VERSION }}
228+
229+ - name : Setup pnpm
230+ uses : pnpm/action-setup@v2
231+ with :
232+ version : ${{ env.PNPM_VERSION }}
233+
234+ - name : Check outdated dependencies
235+ run : |
236+ pnpm outdated || true
237+ continue-on-error : true
238+
239+ - name : Check for duplicated dependencies
240+ run : |
241+ pnpm why --recursive || true
242+ continue-on-error : true
0 commit comments