-
Notifications
You must be signed in to change notification settings - Fork 5
164 lines (155 loc) · 4.41 KB
/
Copy pathci.yml
File metadata and controls
164 lines (155 loc) · 4.41 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
name: CI
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: write
on:
push:
branches:
- main
paths-ignore:
- 'docs/**'
pull_request:
branches:
- main
paths-ignore:
- 'docs/**'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- run: corepack enable
- uses: actions/setup-node@v6
with:
node-version: lts/*
cache: pnpm
- name: 📦 Install dependencies
run: pnpm install --frozen-lockfile
- name: 👀 Lint
run: pnpm lint
- name: 🚀 Build
run: pnpm build
- name: 📦 Cache build
uses: actions/cache/save@v4
with:
path: |
dist
node_modules
key: build-${{ github.sha }}
test-unit:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v5
- run: corepack enable
- uses: actions/setup-node@v6
with:
node-version: lts/*
- name: 📦 Restore build
uses: actions/cache/restore@v4
with:
path: |
dist
node_modules
key: build-${{ github.sha }}
- name: 🧪 Test (Unit + Integration)
run: pnpm test:unit --coverage
test-e2e:
needs: build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3]
steps:
- uses: actions/checkout@v5
- run: corepack enable
- uses: actions/setup-node@v6
with:
node-version: lts/*
# cache handled via build job
- name: 📦 Restore build
uses: actions/cache/restore@v4
with:
path: |
dist
node_modules
key: build-${{ github.sha }}
- name: 🧪 Test (E2E) - Shard ${{ matrix.shard }}/3
run: pnpm test:e2e --shard=${{ matrix.shard }}/3
coverage-report:
needs: test-unit
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v5
- run: corepack enable
- uses: actions/setup-node@v6
with:
node-version: lts/*
# cache handled via build job
- name: 📦 Restore build
uses: actions/cache/restore@v4
with:
path: |
dist
node_modules
key: build-${{ github.sha }}
- name: 🧪 Generate coverage
run: pnpm test:unit --coverage
- name: 📊 Vitest Coverage Report
uses: davelosert/vitest-coverage-report-action@v2
with:
json-summary-path: ./coverage/coverage-summary.json
json-final-path: ./coverage/coverage-final.json
coverage-badge:
needs: test-unit
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
permissions:
contents: write
steps:
- uses: actions/checkout@v5
- run: corepack enable
- uses: actions/setup-node@v6
with:
node-version: lts/*
# cache handled via build job
- name: 📦 Restore build
uses: actions/cache/restore@v4
with:
path: |
dist
node_modules
key: build-${{ github.sha }}
- name: 🧪 Generate coverage
run: pnpm test:unit --coverage
- name: 📊 Update coverage badge
run: |
COVERAGE=$(node -e "
const data = require('./coverage/coverage-summary.json');
console.log(Math.round(data.total.lines.pct));
")
if [ "$COVERAGE" -ge 80 ]; then COLOR="brightgreen"
elif [ "$COVERAGE" -ge 60 ]; then COLOR="green"
elif [ "$COVERAGE" -ge 40 ]; then COLOR="yellow"
else COLOR="red"; fi
echo "Coverage: $COVERAGE%, Color: $COLOR"
sed -i "s|coverage-[0-9]*%25-[a-z]*|coverage-${COVERAGE}%25-${COLOR}|g" README.md
if git diff --quiet README.md; then
echo "No coverage change"
else
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add README.md
git commit -m "chore: update coverage badge to ${COVERAGE}%"
git push
fi