ci(storybook): add audit workflow and exit 1 on audit failures
This commit is contained in:
parent
eb8130af79
commit
d45662ea22
2 changed files with 61 additions and 1 deletions
53
.github/workflows/storybook-audit.yml
vendored
Normal file
53
.github/workflows/storybook-audit.yml
vendored
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
# Storybook audit: build static Storybook, serve it, run the audit script.
|
||||
# Fails the job if any story has console errors, page errors, or unhandled network failures.
|
||||
# See docs/STORYBOOK_CONTRACT.md and apps/web/scripts/audit-storybook.js.
|
||||
name: Storybook Audit
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- "apps/web/**"
|
||||
- ".github/workflows/storybook-audit.yml"
|
||||
pull_request:
|
||||
paths:
|
||||
- "apps/web/**"
|
||||
- ".github/workflows/storybook-audit.yml"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
audit:
|
||||
name: Build & audit Storybook
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: apps/web
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "20"
|
||||
cache: "npm"
|
||||
cache-dependency-path: apps/web/package-lock.json
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Build Storybook
|
||||
run: npm run build-storybook
|
||||
env:
|
||||
VITE_API_URL: /api/v1
|
||||
VITE_USE_MSW: "true"
|
||||
VITE_STORYBOOK: "true"
|
||||
|
||||
- name: Install Playwright Chromium
|
||||
run: npx playwright install chromium --with-deps
|
||||
|
||||
- name: Serve Storybook and run audit
|
||||
run: |
|
||||
npx serve -s storybook-static -p 6007 &
|
||||
sleep 5
|
||||
node scripts/audit-storybook.js
|
||||
|
|
@ -144,6 +144,13 @@ async function audit() {
|
|||
console.log(`Detailed report saved to: ${outputPath}`);
|
||||
|
||||
await browser.close();
|
||||
|
||||
if (report.metadata.storiesWithErrors > 0 || report.metadata.totalErrors > 0) {
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
audit().catch(e => console.error("Top level error:", e));
|
||||
audit().catch(e => {
|
||||
console.error("Top level error:", e);
|
||||
process.exit(1);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue