-
Notifications
You must be signed in to change notification settings - Fork 15
267 lines (233 loc) Β· 8.59 KB
/
main.yml
File metadata and controls
267 lines (233 loc) Β· 8.59 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
name: MiningOS App CI Pipeline
on:
push:
branches: [main, staging, develop]
pull_request:
branches: [main, staging, develop]
types: [opened, reopened, synchronize]
# Global permissions - restrict to minimum required
permissions:
contents: read
env:
NODE_VERSION: '20'
jobs:
# π Supply Chain Security (Runs first)
security:
name: π Supply Chain Security
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
steps:
- name: π₯ Checkout code
uses: actions/checkout@v6
with:
ref: "${{ github.event.pull_request.head.sha || github.sha }}"
clean: true
- name: π¦ Setup Node.js
uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: π₯ Install dependencies
run: npm ci --prefer-offline
- name: π Verify package integrity (npm audit signatures)
run: |
echo "π Verifying npm package signatures..."
npm audit signatures 2>&1 || echo "::warning::Some packages may not have verified signatures"
echo "β
Signature verification complete"
- name: π‘οΈ Run npm audit for vulnerabilities
run: |
echo "π‘οΈ Checking for known vulnerabilities..."
npm audit --audit-level=high || (
echo "::warning::High severity vulnerabilities detected"
echo "π‘ Run \`npm audit fix\` to attempt automatic fixes"
)
echo "β
Vulnerability audit complete"
- name: π Generate SBOM (Software Bill of Materials)
run: |
echo "π Generating SBOM for supply chain visibility..."
if npm sbom --sbom-format=cyclonedx > sbom.json 2>&1; then
PURL_COUNT=$(grep -c '"purl"' sbom.json 2>/dev/null || echo "0")
if [ "$PURL_COUNT" -gt 0 ]; then
echo "β
SBOM generated successfully"
echo "π Package count: $PURL_COUNT"
else
echo "::warning::SBOM generated but appears empty"
fi
else
echo "::notice::SBOM generation failed (requires npm 10.7+)"
rm -f sbom.json
fi
# π Code Quality & Security (Parallel with others)
quality:
name: π Code Quality & Security
runs-on: ubuntu-latest
timeout-minutes: 5
needs: security
permissions:
contents: read
steps:
- name: π₯ Checkout code
uses: actions/checkout@v6
with:
ref: "${{ github.event.pull_request.head.sha || github.sha }}"
clean: true
- name: π Check package-lock.json consistency
run: |
echo "π Verifying package-lock.json consistency..."
npm install --package-lock-only --prefer-offline
git diff --exit-code package-lock.json || (
echo "β package-lock.json is out of sync with package.json."
echo "π‘ Run \`npm install\` and commit the updated lockfile."
exit 1
)
echo "β
package-lock.json is consistent"
- name: π¦ Setup Node.js
uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: π₯ Install dependencies
run: npm ci --prefer-offline
- name: π§Ή Linting
run: |
echo "β‘ Running linter with zero tolerance for warnings..."
time npm run lint
echo "β
Linting passed with no warnings or errors"
- name: π· TypeScript Type Check
run: |
echo "π· Running TypeScript type checking..."
time npm run typecheck
echo "β
TypeScript type checking passed"
- name: π¨ Code Formatting Check
run: |
echo "π¨ Checking code formatting..."
time npm run prettier
# π§ͺ Testing (Parallel with quality)
test:
name: π§ͺ Testing
runs-on: ubuntu-latest
timeout-minutes: 8
needs: security
permissions:
contents: read
steps:
- name: π₯ Checkout code
uses: actions/checkout@v6
with:
ref: "${{ github.event.pull_request.head.sha || github.sha }}"
clean: true
- name: π¦ Setup Node.js
uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: π₯ Install dependencies
run: npm ci --prefer-offline
- name: π§ͺ Run Test Suite
run: |
echo "π§ͺ Running optimized test suite..."
time CI=true npm test
env:
CI: true
- name: π Upload Coverage to Codecov
uses: codecov/codecov-action@v5
with:
file: ./coverage/lcov.info
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
# ποΈ Build (Parallel with quality and test)
build:
name: ποΈ Build
runs-on: ubuntu-latest
timeout-minutes: 6
needs: security
permissions:
contents: read
steps:
- name: π₯ Checkout code
uses: actions/checkout@v6
with:
ref: "${{ github.event.pull_request.head.sha || github.sha }}"
clean: true
- name: π¦ Setup Node.js
uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: π₯ Install dependencies
run: npm ci --prefer-offline
- name: ποΈ Production Build
run: |
echo "ποΈ Building production bundle..."
time npm run build
- name: π Bundle Size Analysis
run: |
echo "π Analyzing bundle size..."
du -sh build/
echo "π Build artifacts:"
find build/ -type f -name "*.js" -o -name "*.css" | head -5 | xargs ls -lh
# π Summary & Performance Stats (Runs after all parallel jobs complete)
summary:
name: π Summary & Performance Stats
runs-on: ubuntu-latest
needs: [security, quality, test, build]
if: always()
permissions:
contents: read
steps:
- name: π₯ Checkout code for summary
uses: actions/checkout@v6
with:
ref: "${{ github.event.pull_request.head.sha || github.sha }}"
clean: true
- name: π Performance Summary
run: |
echo "π CI Pipeline Performance Summary"
echo "===================================="
echo ""
echo "π Commit Information:"
echo " Commit: $(git rev-parse HEAD)"
echo " Message: $(git log -1 --pretty=format:'%s')"
echo " Author: $(git log -1 --pretty=format:'%an <%ae>')"
echo " Date: $(git log -1 --pretty=format:'%ad' --date=short)"
echo ""
echo "π― Job Results:"
echo " π Supply Chain Security: ${{ needs.security.result }}"
echo " π Code Quality: ${{ needs.quality.result }}"
echo " π§ͺ Testing: ${{ needs.test.result }}"
echo " ποΈ Build: ${{ needs.build.result }}"
echo ""
echo "β‘ Performance Metrics:"
echo " π Linting: Optimized with cache strategy"
echo " π· TypeScript: Type checking enabled"
echo " π§ͺ Test Suite: All tests passing"
echo " ποΈ Build: Production bundle generated"
echo " π Total CI Time: Parallel execution enabled"
echo ""
echo "π§ Optimizations Applied:"
echo " β
Supply chain security checks (npm audit signatures)"
echo " β
ESLint cache strategy optimized"
echo " β
Zero tolerance for linter warnings"
echo " β
TypeScript strict type checking"
echo " β
Test mocks streamlined"
echo " β
Parallel job execution"
echo " β
Reduced timeouts and redundant steps"
echo ""
echo "π Test Coverage:"
echo " π All tests passing"
echo " π― Critical paths covered"
echo " β‘ Optimized test execution"
- name: π Success Notification
if: ${{ needs.security.result == 'success' && needs.quality.result == 'success' && needs.test.result == 'success' && needs.build.result == 'success' }}
run: |
echo "π All checks passed! Ready for merge."
echo ""
echo "π Performance Highlights:"
echo " β’ Linting: Zero tolerance for warnings"
echo " β’ TypeScript: Type checking passed"
echo " β’ Tests: All tests passing"
echo " β’ Build: Production ready"
echo " β’ CI: Optimized for speed and reliability"