This repository was archived by the owner on Jan 29, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 71
309 lines (244 loc) · 9.07 KB
/
ci.yml
File metadata and controls
309 lines (244 loc) · 9.07 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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
name: CI Pipeline
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
env:
NODE_VERSION: '20'
CACHE_VERSION: 'v2'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# Quick validation job for fast feedback
quick-check:
name: Quick Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Type checking
run: |
echo "Running comprehensive TypeScript checks..."
# Main TypeScript check
npm run typecheck || echo "⚠️ Main typecheck had issues"
# CLI-specific TypeScript check
if [ -f "tsconfig.cli.json" ]; then
echo "Checking CLI TypeScript configuration..."
npx tsc --project tsconfig.cli.json --noEmit || echo "⚠️ CLI typecheck had issues"
fi
# Check for TypeScript errors in specific directories
if [ -d "src/cli" ]; then
echo "Checking CLI source files..."
npx tsc --noEmit src/cli/*.ts src/cli/**/*.ts 2>/dev/null || echo "⚠️ CLI source files have TS issues"
fi
- name: Lint code
run: npm run lint
- name: Static Analysis for Build Issues
run: |
echo "Running static analysis for common build issues..."
# Check for shebang issues in source files
echo "Checking for shebang issues in source files..."
if find src -name "*.ts" -o -name "*.js" 2>/dev/null | xargs grep -l "^#!" 2>/dev/null | head -3; then
echo "⚠️ Found shebangs in TypeScript/JS source files (may cause issues)"
fi
# Check for dependency usage patterns
echo "Checking dependency patterns..."
if find src -name "*.ts" -o -name "*.js" 2>/dev/null | xargs grep -l "require.*commander\|import.*commander" 2>/dev/null | head -3; then
echo "ℹ️ Found commander usage (ensure it's in dependencies)"
fi
if find src -name "*.ts" -o -name "*.js" 2>/dev/null | xargs grep -l "require.*chalk\|import.*chalk" 2>/dev/null | head -3; then
echo "ℹ️ Found chalk usage (ensure it's in dependencies)"
fi
echo "✅ Static analysis completed"
test:
name: Test Suite
runs-on: ${{ matrix.os }}
needs: quick-check
strategy:
fail-fast: false
matrix:
node-version: [18, 20, 22]
os: [ubuntu-latest, windows-latest, macos-latest]
env:
NODE_OPTIONS: '--experimental-vm-modules'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
registry-url: 'https://registry.npmjs.org'
- name: Cache node modules
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ env.CACHE_VERSION }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ matrix.node-version }}-${{ env.CACHE_VERSION }}-
${{ runner.os }}-node-${{ matrix.node-version }}-
- name: Install dependencies
run: npm ci
- name: Type checking
run: npm run typecheck
- name: Lint code
run: npm run lint
- name: Build project
run: npm run build
- name: Test CLI binary
if: matrix.os == 'ubuntu-latest' && matrix.node-version == 20
run: |
echo "Testing CLI binary installation and functionality..."
# Create package and install globally
npm pack
PACKAGE_FILE=$(ls *.tgz | head -1)
echo "Created package: $PACKAGE_FILE"
npm install -g "$PACKAGE_FILE"
# Test basic CLI commands with better error handling
echo "Testing gemini-flow --help..."
gemini-flow --help >/dev/null || echo "⚠️ CLI help command failed"
echo "Testing gemini-flow --version..."
gemini-flow --version || echo "⚠️ CLI version command failed"
echo "Testing additional CLI commands..."
gemini-flow list-models >/dev/null 2>&1 || echo "⚠️ CLI list-models failed (may be normal without API key)"
gemini-flow auth --status >/dev/null 2>&1 || echo "⚠️ CLI auth status failed (may be normal without setup)"
gemini-flow doctor >/dev/null 2>&1 || echo "⚠️ CLI doctor failed (may be normal)"
echo "✅ CLI testing completed"
# Cleanup
npm uninstall -g "@clduab11/gemini-flow" || echo "⚠️ Failed to uninstall global package"
rm -f *.tgz
build-artifacts:
name: Build Artifacts
runs-on: ubuntu-latest
needs: test
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build project
run: npm run build
- name: Create package
run: npm pack
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: npm-package
path: '*.tgz'
retention-days: 30
- name: Upload dist directory
uses: actions/upload-artifact@v4
with:
name: dist-files
path: dist/
retention-days: 7
security-audit:
name: Security Audit
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run npm audit
run: npm audit --audit-level=moderate
- name: Check for vulnerable dependencies
run: |
if npm audit --audit-level=high --json | jq '.vulnerabilities | length > 0'; then
echo "High severity vulnerabilities found!"
npm audit --audit-level=high
exit 1
fi
validate-package:
name: Validate Package
runs-on: ubuntu-latest
needs: build-artifacts
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: npm-package
- name: Test package installation
run: |
# Create temp directory for testing
mkdir -p /tmp/package-test
cd /tmp/package-test
# Initialize a test project
npm init -y
# Install the package from tarball
npm install $GITHUB_WORKSPACE/*.tgz
# Test CLI commands
npx gemini-flow --help
npx quantum-flow --version
- name: Validate package.json
run: |
# Check required fields
node -e "
const pkg = require('./package.json');
const required = ['name', 'version', 'description', 'main', 'bin', 'files'];
required.forEach(field => {
if (!pkg[field]) throw new Error(\`Missing required field: \${field}\`);
});
console.log('Package.json validation passed');
"
performance-test:
name: Performance Tests
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build project
run: npm run build
- name: Run performance benchmarks
run: |
if [ -f "scripts/benchmark.ts" ]; then
npm run benchmark
else
echo "No benchmark script found, skipping performance tests"
fi
- name: Comment PR with performance results
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
// This would add performance results as a comment on the PR
// Implementation depends on benchmark output format
console.log('Performance test completed');