-
-
Notifications
You must be signed in to change notification settings - Fork 42
94 lines (77 loc) · 2.14 KB
/
ci.yml
File metadata and controls
94 lines (77 loc) · 2.14 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
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
# Job 1: Build & Type Check
build:
name: Build & Type Check
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Type check & Build
run: npm run build
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
retention-days: 7
# Job 2: Lint
lint:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run ESLint
run: npm run lint
# Job 3: Bundle Size Check
bundle-size:
name: Bundle Size Check
runs-on: ubuntu-latest
needs: build
timeout-minutes: 10
steps:
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Check bundle size
env:
BUNDLE_SIZE_THRESHOLD: 500
run: |
BUNDLE_SIZE_BYTES=$(find dist -type f -printf '%s\n' | awk '{sum += $1} END {print sum + 0}')
BUNDLE_SIZE_KB=$(( (BUNDLE_SIZE_BYTES + 1023) / 1024 ))
THRESHOLD_BYTES=$(( BUNDLE_SIZE_THRESHOLD * 1024 ))
echo "Bundle size: ${BUNDLE_SIZE_KB}KB (${BUNDLE_SIZE_BYTES} bytes)"
if [ "$BUNDLE_SIZE_BYTES" -gt "$THRESHOLD_BYTES" ]; then
echo "::warning::Bundle size ${BUNDLE_SIZE_KB}KB exceeds ${BUNDLE_SIZE_THRESHOLD}KB threshold."
else
echo "✅ Bundle size ${BUNDLE_SIZE_KB}KB is within threshold"
fi