-
Notifications
You must be signed in to change notification settings - Fork 1
201 lines (169 loc) · 5.56 KB
/
Copy pathci.yml
File metadata and controls
201 lines (169 loc) · 5.56 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
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
issues: write
pull-requests: write
concurrency:
group: ci-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true
jobs:
quality:
name: Quality Gates
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile
- name: Lint
run: pnpm lint
- name: Typecheck
run: pnpm typecheck
- name: Build
run: pnpm build
- name: Codebase Intelligence CI
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
BASE_REF="origin/${{ github.base_ref }}"
else
BASE_REF="${{ github.event.before }}"
if [ -z "$BASE_REF" ] || [ "$BASE_REF" = "0000000000000000000000000000000000000000" ]; then
BASE_REF="HEAD~1"
fi
fi
set +e
npx -y codebase-intelligence@canary ci . \
--base "$BASE_REF" \
--new-only \
--changed-workspaces \
--format annotations \
--summary \
--force
CBI_STATUS=$?
npx -y codebase-intelligence@canary ci . \
--base "$BASE_REF" \
--new-only \
--changed-workspaces \
--format sarif \
--output codebase-intelligence.sarif \
--summary \
--force
CBI_SARIF_STATUS=$?
npx -y codebase-intelligence@canary ci . \
--base "$BASE_REF" \
--new-only \
--changed-workspaces \
--comment markdown \
--output codebase-intelligence-pr-comment.md \
--summary \
--force
CBI_COMMENT_STATUS=$?
if [ -f codebase-intelligence-pr-comment.md ]; then
cat codebase-intelligence-pr-comment.md >> "$GITHUB_STEP_SUMMARY"
fi
if [ "$CBI_STATUS" -ne 0 ]; then
exit "$CBI_STATUS"
fi
if [ "$CBI_SARIF_STATUS" -ne 0 ]; then
exit "$CBI_SARIF_STATUS"
fi
exit "$CBI_COMMENT_STATUS"
- name: Post Codebase Intelligence PR comment
if: ${{ always() && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository }}
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const marker = '<!-- codebase-intelligence-ci-comment -->';
const reportPath = 'codebase-intelligence-pr-comment.md';
if (!fs.existsSync(reportPath)) {
core.info('No Codebase Intelligence PR comment report found.');
return;
}
const report = fs.readFileSync(reportPath, 'utf8').trim();
if (!report) {
core.info('Codebase Intelligence PR comment report is empty.');
return;
}
const body = `${marker}\n${report}`;
const { owner, repo } = context.repo;
const issue_number = context.issue.number;
const comments = await github.paginate(github.rest.issues.listComments, {
owner,
repo,
issue_number,
per_page: 100,
});
const existing = comments.find((comment) =>
comment.user?.type === 'Bot' && comment.body?.includes(marker)
);
if (existing) {
await github.rest.issues.updateComment({
owner,
repo,
comment_id: existing.id,
body,
});
return;
}
await github.rest.issues.createComment({
owner,
repo,
issue_number,
body,
});
- name: Upload Codebase Intelligence reports
if: always()
uses: actions/upload-artifact@v4
with:
name: codebase-intelligence-reports
path: |
codebase-intelligence.sarif
codebase-intelligence-pr-comment.md
retention-days: 14
if-no-files-found: warn
# Coverage is best-effort: vitest v3 + v8 provider can hang after tests
# pass on CI runners. The blocking test matrix proves correctness;
# this step is bounded so coverage cannot block the release gate.
- name: Coverage
continue-on-error: true
timeout-minutes: 4
run: timeout 180s pnpm vitest run --coverage --pool forks --no-file-parallelism || true
- name: Upload coverage
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage/
retention-days: 14
if-no-files-found: ignore
test:
name: Tests (${{ matrix.node-version }}, shard ${{ matrix.shard }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [18, 22]
shard: ["1/4", "2/4", "3/4", "4/4"]
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: pnpm
- run: pnpm install --frozen-lockfile
- name: Build
run: pnpm build
- name: Test shard
run: pnpm test:shard --shard=${{ matrix.shard }}