Skip to content

Commit f5068bf

Browse files
committed
fix(contract): fail CI on total outage, run schema tests in workflow
1 parent ad1a301 commit f5068bf

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

.github/workflows/contract-check.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ jobs:
3535
workflow_conclusion: ''
3636
if_no_artifact_found: ignore
3737

38+
# Run schema unit tests before checker
39+
- run: npx vitest run tests/contract/
40+
3841
# Run contract checker
3942
- id: checker
4043
run: npx tsx tests/contract/checker.ts

tests/contract/checker.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,16 @@ async function main(): Promise<void> {
228228
JSON.stringify(report, null, 2) + '\n',
229229
);
230230

231-
// 有漂移时以非零退出码通知 CI
231+
// Exit with error if drift detected or if zero commands passed (total outage)
232232
const hasDrift = results.some(r => r.status === 'drifted');
233+
const passedCount = results.filter(r => r.status === 'passed').length;
233234
if (hasDrift) {
234235
process.exit(1);
235236
}
237+
if (passedCount === 0 && results.length > 0) {
238+
console.error('Error: no commands passed — all failed or drifted');
239+
process.exit(1);
240+
}
236241
}
237242

238243
main().catch((err) => {

0 commit comments

Comments
 (0)