-
Notifications
You must be signed in to change notification settings - Fork 206
167 lines (158 loc) · 5.17 KB
/
Copy pathci.yml
File metadata and controls
167 lines (158 loc) · 5.17 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
name: CI
on:
push:
branches: [main, develop]
pull_request:
concurrency:
group: ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
# ========== Stage 1: 变更检测 ==========
changed-files:
runs-on: ubuntu-latest
outputs:
renderer: ${{ steps.changes.outputs.renderer }}
main: ${{ steps.changes.outputs.main }}
skills: ${{ steps.changes.outputs.skills }}
scripts: ${{ steps.changes.outputs.scripts }}
docs: ${{ steps.changes.outputs.docs }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: changes
with:
filters: |
renderer:
- 'src/renderer/**'
- 'vite.config.ts'
- 'tsconfig.json'
- 'tailwind.config.js'
- 'postcss.config.js'
main:
- 'src/main/**'
- 'src/common/**'
- 'electron-tsconfig.json'
- 'src/main/preload.ts'
skills:
- 'SKILLs/**'
scripts:
- 'scripts/**'
- 'electron-builder.json'
docs:
- 'docs/**'
- '**/*.md'
# ========== Stage 2: 代码质量 (快速) ==========
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: '24.x'
- uses: actions/cache@v4
with:
path: ~/.npm
key: npm-${{ runner.os }}-${{ hashFiles('package.json') }}
restore-keys: npm-${{ runner.os }}-
- run: npm install
- name: Lint changed files only
env:
BEFORE_SHA: ${{ github.event.before }}
BASE_REF: ${{ github.base_ref }}
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
FILES=$(git diff --name-only --diff-filter=ACMR origin/${BASE_REF}...HEAD -- '*.ts' '*.tsx')
elif [ -n "$BEFORE_SHA" ] && [ "$BEFORE_SHA" != "0000000000000000000000000000000000000000" ]; then
FILES=$(git diff --name-only --diff-filter=ACMR ${BEFORE_SHA}...HEAD -- '*.ts' '*.tsx')
else
echo "BEFORE_SHA unavailable, falling back to HEAD~1"
FILES=$(git diff --name-only --diff-filter=ACMR HEAD~1 -- '*.ts' '*.tsx')
fi
if [ -n "$FILES" ]; then
echo "Linting changed files:"
echo "$FILES"
echo "$FILES" | xargs -d '\n' npx eslint --ext ts,tsx --report-unused-disable-directives --max-warnings 0
else
echo "No TypeScript files changed, skipping lint"
fi
# ========== Stage 3: Renderer 构建 ==========
build-renderer:
needs: [changed-files, lint]
if: ${{ needs.changed-files.outputs.renderer == 'true' || github.event_name == 'push' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '24.x'
- uses: actions/cache@v4
with:
path: ~/.npm
key: npm-${{ runner.os }}-${{ hashFiles('package.json') }}
restore-keys: npm-${{ runner.os }}-
- run: npm install
- run: npm run build
- uses: actions/upload-artifact@v4
with:
name: renderer-dist
path: dist/
retention-days: 1
# ========== Stage 4: Main 进程构建 ==========
build-main:
needs: [changed-files, lint]
if: ${{ needs.changed-files.outputs.main == 'true' || github.event_name == 'push' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '24.x'
- uses: actions/cache@v4
with:
path: ~/.npm
key: npm-${{ runner.os }}-${{ hashFiles('package.json') }}
restore-keys: npm-${{ runner.os }}-
- run: npm install
- run: npm run compile:electron
- uses: actions/upload-artifact@v4
with:
name: main-dist
path: dist-electron/
retention-days: 1
# ========== Stage 5: Skill 构建 ==========
build-skills:
needs: changed-files
if: ${{ needs.changed-files.outputs.skills == 'true' || github.event_name == 'push' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '24.x'
- uses: actions/cache@v4
with:
path: ~/.npm
key: npm-${{ runner.os }}-${{ hashFiles('package.json') }}
restore-keys: npm-${{ runner.os }}-
- run: npm install
- run: npm run build:skills
# ========== Stage 6: 测试 (Node.js 内置) ==========
test:
needs: [build-main]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '24.x'
- uses: actions/cache@v4
with:
path: ~/.npm
key: npm-${{ runner.os }}-${{ hashFiles('package.json') }}
restore-keys: npm-${{ runner.os }}-
- run: npm install
- run: npm test