-
Notifications
You must be signed in to change notification settings - Fork 3
304 lines (254 loc) · 8.64 KB
/
ci.yml
File metadata and controls
304 lines (254 loc) · 8.64 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
name: CI/CD Pipeline
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
env:
NODE_VERSION: '18'
jobs:
# Validate repository structure and basic functionality
validate:
name: Validate Repository
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: latest
- name: Check essential files
run: |
echo "Checking repository structure..."
test -f package.json && echo "✅ package.json found"
test -f scripts/install.sh && echo "✅ install.sh found"
test -f scripts/verify-tools.js && echo "✅ verify-tools.js found"
test -f tools/tool-installer.js && echo "✅ tool-installer.js found"
test -f README.md && echo "✅ README.md found"
- name: Validate package.json
run: |
echo "Validating package.json..."
node -e "JSON.parse(require('fs').readFileSync('package.json', 'utf8'))"
echo "✅ package.json is valid JSON"
- name: Check Node.js and pnpm versions
run: |
echo "Node.js version: $(node --version)"
echo "pnpm version: $(pnpm --version)"
# Install dependencies and run quality checks
quality:
name: Code Quality & Dependencies
runs-on: ubuntu-latest
needs: validate
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: latest
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: |
echo "Installing dependencies with pnpm..."
if [ -f pnpm-lock.yaml ]; then
pnpm install --frozen-lockfile
else
echo "No pnpm-lock.yaml found, running regular install..."
pnpm install
fi
- name: Run linting
run: |
echo "Running ESLint..."
if pnpm run lint --if-present; then
echo "✅ Linting passed"
else
echo "⚠️ Linting issues found or no lint script"
fi
- name: Run formatting check
run: |
echo "Checking code formatting..."
if pnpm run format:check --if-present; then
echo "✅ Formatting is correct"
else
echo "⚠️ Formatting issues found or no format:check script"
fi
- name: Validate JSON and YAML files
run: |
echo "Validating configuration files..."
# Validate JSON files
find . -name "*.json" -not -path "./node_modules/*" | while read file; do
echo "Validating $file"
if node -e "JSON.parse(require('fs').readFileSync('$file', 'utf8'))" 2>/dev/null; then
echo "✅ Valid JSON: $file"
else
echo "⚠️ Invalid JSON: $file"
fi
done
# Check lock file
if [ -f pnpm-lock.yaml ]; then
echo "✅ pnpm-lock.yaml found"
else
echo "📝 pnpm-lock.yaml missing - run 'pnpm install' to generate"
fi
# Run tests if they exist
test:
name: Run Tests
runs-on: ubuntu-latest
needs: [validate, quality]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: latest
- name: Install dependencies
run: |
if [ -f pnpm-lock.yaml ]; then
pnpm install --frozen-lockfile
else
pnpm install
fi
- name: Run tests
run: |
if pnpm run test --if-present; then
echo "✅ Tests passed"
else
echo "📝 No tests found or tests failed"
fi
# Security and dependency checks
security:
name: Security Checks
runs-on: ubuntu-latest
needs: quality
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: latest
- name: Install dependencies
run: |
if [ -f pnpm-lock.yaml ]; then
pnpm install --frozen-lockfile
else
pnpm install
fi
- name: Run security audit
run: |
echo "Running security audit..."
if pnpm audit --audit-level moderate; then
echo "✅ No security issues found"
else
echo "⚠️ Security vulnerabilities found - review recommended"
fi
- name: Check for outdated dependencies
run: |
echo "Checking for outdated dependencies..."
pnpm outdated || echo "📦 Some dependencies may be outdated"
# Documentation and README checks
documentation:
name: Documentation
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check documentation structure
run: |
echo "Checking documentation structure..."
# Essential files
test -f README.md && echo "✅ README.md exists"
test -f CONTRIBUTING.md && echo "✅ CONTRIBUTING.md exists" || echo "📝 CONTRIBUTING.md missing"
test -f LICENSE && echo "✅ LICENSE exists" || echo "📝 LICENSE missing"
test -f CHANGELOG.md && echo "✅ CHANGELOG.md exists" || echo "📝 CHANGELOG.md missing"
# README content checks
if grep -q "Quick Start" README.md; then
echo "✅ README has Quick Start section"
else
echo "📝 README missing Quick Start section"
fi
if grep -q -i "install" README.md; then
echo "✅ README has Installation section"
else
echo "📝 README missing Installation section"
fi
# Check for pnpm mentions
if grep -q "pnpm" README.md; then
echo "✅ README mentions pnpm"
else
echo "📝 Consider mentioning pnpm usage in README"
fi
# Final summary (improved logic)
summary:
name: CI Summary
runs-on: ubuntu-latest
needs: [validate, quality, test, security, documentation]
if: always()
steps:
- name: Check overall results
run: |
echo "🔍 CI Pipeline Summary"
echo "====================="
echo "Validate: ${{ needs.validate.result }}"
echo "Quality: ${{ needs.quality.result }}"
echo "Tests: ${{ needs.test.result }}"
echo "Security: ${{ needs.security.result }}"
echo "Documentation: ${{ needs.documentation.result }}"
echo ""
# Only fail on truly critical issues
critical_failed=false
# These jobs MUST pass
if [[ "${{ needs.validate.result }}" == "failure" ]]; then
echo "❌ Repository validation failed"
critical_failed=true
fi
if [[ "${{ needs.quality.result }}" == "failure" ]]; then
echo "❌ Code quality checks failed"
critical_failed=true
fi
# These are helpful but not critical
if [[ "${{ needs.test.result }}" == "failure" ]]; then
echo "⚠️ Tests failed - review recommended"
fi
if [[ "${{ needs.security.result }}" == "failure" ]]; then
echo "⚠️ Security issues found - review recommended"
fi
if [[ "${{ needs.documentation.result }}" == "failure" ]]; then
echo "📝 Documentation could be improved"
fi
echo ""
if [[ "$critical_failed" == "true" ]]; then
echo "❌ Critical issues found - CI failed"
exit 1
else
echo "✅ CI Pipeline completed successfully!"
echo "📝 Review any warnings above for improvements"
fi