-
Notifications
You must be signed in to change notification settings - Fork 10
239 lines (216 loc) · 8.88 KB
/
ci.yml
File metadata and controls
239 lines (216 loc) · 8.88 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
name: CI
on:
push:
branches:
- main
- 'renovate/**'
- 'release/**'
pull_request:
branches:
- main
- 'release/**'
workflow_dispatch:
permissions:
contents: read
actions: read
checks: write
env:
SFCC_DISABLE_TELEMETRY: ${{ vars.SFCC_DISABLE_TELEMETRY }}
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22.x, 24.x]
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
- name: Setup pnpm
uses: pnpm/action-setup@v5
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@v5
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build packages
run: pnpm -r run build
- name: Run SDK tests
id: sdk-test
working-directory: packages/b2c-tooling-sdk
run: pnpm run pretest && pnpm run test:ci && pnpm run lint
- name: Run MCP tests
id: mcp-test
if: always() && steps.sdk-test.conclusion != 'cancelled'
working-directory: packages/b2c-dx-mcp
run: pnpm run pretest && pnpm run test:ci && pnpm run lint
- name: Run CLI tests
id: cli-test
if: always() && steps.mcp-test.conclusion != 'cancelled'
working-directory: packages/b2c-cli
run: pnpm run pretest && pnpm run test:ci && pnpm run lint
- name: Run MRT Utilities tests
id: mrt-test
if: always() && steps.cli-test.conclusion != 'cancelled'
working-directory: packages/mrt-utilities
run: pnpm run pretest && pnpm run test:ci && pnpm run lint
- name: Run VS Extension checks
id: vs-extension-test
if: always() && steps.mrt-test.conclusion != 'cancelled'
working-directory: packages/b2c-vs-extension
run: pnpm run typecheck:agent && pnpm run lint
- name: Test Report
uses: dorny/test-reporter@a43b3a5f7366b97d083190328d2c652e1a8b6aa2 # v3.0.0
if: always() && steps.sdk-test.conclusion != 'cancelled'
with:
name: Test Results (Node ${{ matrix.node-version }})
path: 'packages/*/test-results.json'
reporter: mocha-json
- name: Generate coverage summary
if: always() && steps.sdk-test.conclusion != 'cancelled'
run: |
echo "## Coverage (Node ${{ matrix.node-version }})" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
# SDK Coverage
if [ -f "packages/b2c-tooling-sdk/coverage/lcov.info" ]; then
echo "### @salesforce/b2c-tooling-sdk" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
cd packages/b2c-tooling-sdk && pnpm c8 report --reporter=text-summary 2>/dev/null | tail -n 6 >> $GITHUB_STEP_SUMMARY
cd ../..
echo '```' >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
fi
# CLI Coverage
if [ -f "packages/b2c-cli/coverage/lcov.info" ]; then
echo "### @salesforce/b2c-cli" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
cd packages/b2c-cli && pnpm c8 report --reporter=text-summary 2>/dev/null | tail -n 6 >> $GITHUB_STEP_SUMMARY
cd ../..
echo '```' >> $GITHUB_STEP_SUMMARY
fi
- name: Upload coverage reports
if: always() && steps.sdk-test.conclusion != 'cancelled'
uses: actions/upload-artifact@v7
with:
name: coverage-reports-node-${{ matrix.node-version }}
path: |
packages/b2c-tooling-sdk/coverage/
packages/b2c-cli/coverage/
retention-days: 30
test-windows:
runs-on: windows-latest
# Advisory rollout: Windows coverage is new; surface failures without
# blocking Linux CI while remaining Windows-specific test issues are
# addressed in follow-up PRs. Remove once Windows tests are green.
continue-on-error: true
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
node-version: [22.x, 24.x]
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup Windows machine
uses: ./.github/actions/setup-windows
with:
node-version: ${{ matrix.node-version }}
- name: Build packages
run: pnpm -r run build
- name: Run SDK tests
id: sdk-test
working-directory: packages/b2c-tooling-sdk
run: pnpm run pretest && pnpm run test:ci && pnpm run lint
- name: Run MCP tests
id: mcp-test
if: always() && steps.sdk-test.conclusion != 'cancelled'
working-directory: packages/b2c-dx-mcp
run: pnpm run pretest && pnpm run test:ci && pnpm run lint
- name: Run CLI tests
id: cli-test
if: always() && steps.mcp-test.conclusion != 'cancelled'
working-directory: packages/b2c-cli
# Use the Windows-specific script (test:ci:win) to bypass c8's
# coverage threshold check. V8 coverage on Windows double-counts
# some TS source files (distinct URL casing emitted by the tsx
# loader), which drops the reported function-coverage number below
# the Linux-calibrated 70% threshold even though the tests pass.
# Coverage is still generated and uploaded for inspection.
run: pnpm run pretest && pnpm run test:ci:win && pnpm run lint
- name: Run MRT Utilities tests
id: mrt-test
if: always() && steps.cli-test.conclusion != 'cancelled'
working-directory: packages/mrt-utilities
run: pnpm run pretest && pnpm run test:ci && pnpm run lint
- name: Run VS Extension checks
if: always() && steps.mrt-test.conclusion != 'cancelled'
working-directory: packages/b2c-vs-extension
run: pnpm run typecheck:agent && pnpm run lint
- name: Print Windows test failures
# Mocha's JSON reporter swallows stdout, so Windows-only failures are
# invisible in the step log. Parse the per-package test-results.json
# and echo failing test titles + error messages to the job log for triage.
if: always() && steps.sdk-test.conclusion != 'cancelled'
shell: bash
run: |
node -e "
const fs = require('node:fs');
const path = require('node:path');
const reports = [
'packages/b2c-tooling-sdk/test-results.json',
'packages/b2c-dx-mcp/test-results.json',
'packages/b2c-cli/test-results.json',
];
let totalFailures = 0;
for (const report of reports) {
if (!fs.existsSync(report)) continue;
const data = JSON.parse(fs.readFileSync(report, 'utf8'));
const failures = data.failures || [];
if (failures.length === 0) continue;
totalFailures += failures.length;
console.log('\n=== ' + report + ' (' + failures.length + ' failures) ===');
for (const f of failures) {
console.log('\n✖ ' + f.fullTitle);
if (f.err && f.err.message) console.log(' message: ' + f.err.message.split('\n')[0]);
if (f.err && f.err.stack) console.log(' stack: ' + f.err.stack.split('\n').slice(0, 5).join('\n '));
}
}
if (totalFailures === 0) console.log('No Windows test failures reported.');
else console.log('\nTotal Windows failures: ' + totalFailures);
"
- name: Test Report
uses: dorny/test-reporter@a43b3a5f7366b97d083190328d2c652e1a8b6aa2 # v3.0.0
if: always() && steps.sdk-test.conclusion != 'cancelled'
with:
name: Test Results (Windows Node ${{ matrix.node-version }})
path: 'packages/*/test-results.json'
reporter: mocha-json
- name: Upload test results (for Windows triage)
if: always() && steps.sdk-test.conclusion != 'cancelled'
uses: actions/upload-artifact@v7
with:
name: test-results-windows-node-${{ matrix.node-version }}
path: 'packages/*/test-results.json'
retention-days: 30
- name: Upload coverage reports
if: always() && steps.sdk-test.conclusion != 'cancelled'
uses: actions/upload-artifact@v7
with:
name: coverage-reports-windows-node-${{ matrix.node-version }}
path: |
packages/b2c-tooling-sdk/coverage/
packages/b2c-cli/coverage/
retention-days: 30