198 lines
6.2 KiB
YAML
198 lines
6.2 KiB
YAML
name: Storybook
|
|
|
|
on:
|
|
pull_request:
|
|
paths:
|
|
- "apps/storybook/**"
|
|
- "packages/ui/src/stories/**"
|
|
- "packages/ui-app/src/stories/**"
|
|
- "packages/ui-subframe/src/stories/**"
|
|
- "packages/ui-mock/src/stories/**"
|
|
- ".github/workflows/storybook.yml"
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- "apps/storybook/**"
|
|
- "packages/ui/src/stories/**"
|
|
- "packages/ui-app/src/stories/**"
|
|
- "packages/ui-subframe/src/stories/**"
|
|
- "packages/ui-mock/src/stories/**"
|
|
- ".github/workflows/storybook.yml"
|
|
|
|
env:
|
|
PLAYWRIGHT_BROWSERS_PATH: .cache/ms-playwright
|
|
|
|
jobs:
|
|
build-storybook:
|
|
name: Build static Storybook
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 20
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Enable Corepack
|
|
run: corepack enable
|
|
|
|
- name: Prepare pnpm 10.33.0
|
|
run: corepack prepare pnpm@10.33.0 --activate
|
|
|
|
- name: Configure pnpm store
|
|
run: pnpm config set store-dir .pnpm-store
|
|
|
|
- name: Cache pnpm store
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: .pnpm-store
|
|
key: ${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-pnpm-
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Build Storybook static site
|
|
run: pnpm --filter @toolctrl/storybook build-storybook
|
|
|
|
- name: Upload static Storybook artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: storybook-static
|
|
path: apps/storybook/storybook-static
|
|
if-no-files-found: error
|
|
retention-days: 14
|
|
|
|
test-storybook:
|
|
name: Storybook test-runner (a11y gate)
|
|
needs: build-storybook
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 25
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Enable Corepack
|
|
run: corepack enable
|
|
|
|
- name: Prepare pnpm 10.33.0
|
|
run: corepack prepare pnpm@10.33.0 --activate
|
|
|
|
- name: Configure pnpm store
|
|
run: pnpm config set store-dir .pnpm-store
|
|
|
|
- name: Cache pnpm store
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: .pnpm-store
|
|
key: ${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-pnpm-
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Download built Storybook
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: storybook-static
|
|
path: apps/storybook/storybook-static
|
|
|
|
- name: Cache Playwright browsers
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: .cache/ms-playwright
|
|
key: ${{ runner.os }}-playwright-${{ hashFiles('pnpm-lock.yaml') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-playwright-
|
|
|
|
- name: Install Playwright Chromium
|
|
run: pnpm --filter @toolctrl/storybook exec playwright install --with-deps chromium
|
|
|
|
- name: Serve static Storybook and run test-runner with a11y gate
|
|
run: |
|
|
set -euo pipefail
|
|
pnpm --filter @toolctrl/storybook exec http-server storybook-static --port 6006 --silent &
|
|
SERVER_PID=$!
|
|
trap "kill $SERVER_PID 2>/dev/null || true" EXIT
|
|
pnpm --filter @toolctrl/storybook exec wait-on http://127.0.0.1:6006 --timeout 60000
|
|
TARGET_URL=http://127.0.0.1:6006 pnpm --filter @toolctrl/storybook test:storybook
|
|
|
|
visual-regression:
|
|
name: Storybook visual-regression (Lost-Pixel)
|
|
needs: build-storybook
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 20
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Check for committed Lost-Pixel baseline
|
|
id: baseline
|
|
run: |
|
|
set -euo pipefail
|
|
if ls apps/storybook/.lostpixel/baseline/*.png >/dev/null 2>&1; then
|
|
echo "present=true" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "present=false" >> "$GITHUB_OUTPUT"
|
|
echo "::notice::No Lost-Pixel baseline committed yet — skipping visual-regression. Run 'pnpm --filter @toolctrl/storybook visual-regression:update' and commit apps/storybook/.lostpixel/baseline/*.png to enable this gate."
|
|
fi
|
|
|
|
- name: Enable Corepack
|
|
if: steps.baseline.outputs.present == 'true'
|
|
run: corepack enable
|
|
|
|
- name: Prepare pnpm 10.33.0
|
|
if: steps.baseline.outputs.present == 'true'
|
|
run: corepack prepare pnpm@10.33.0 --activate
|
|
|
|
- name: Configure pnpm store
|
|
if: steps.baseline.outputs.present == 'true'
|
|
run: pnpm config set store-dir .pnpm-store
|
|
|
|
- name: Cache pnpm store
|
|
if: steps.baseline.outputs.present == 'true'
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: .pnpm-store
|
|
key: ${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-pnpm-
|
|
|
|
- name: Install dependencies
|
|
if: steps.baseline.outputs.present == 'true'
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Download built Storybook
|
|
if: steps.baseline.outputs.present == 'true'
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: storybook-static
|
|
path: apps/storybook/storybook-static
|
|
|
|
- name: Cache Playwright browsers
|
|
if: steps.baseline.outputs.present == 'true'
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: .cache/ms-playwright
|
|
key: ${{ runner.os }}-playwright-${{ hashFiles('pnpm-lock.yaml') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-playwright-
|
|
|
|
- name: Install Playwright Chromium
|
|
if: steps.baseline.outputs.present == 'true'
|
|
run: pnpm --filter @toolctrl/storybook exec playwright install --with-deps chromium
|
|
|
|
- name: Run Lost-Pixel visual-regression diff
|
|
if: steps.baseline.outputs.present == 'true'
|
|
run: pnpm --filter @toolctrl/storybook visual-regression
|
|
|
|
- name: Upload Lost-Pixel diff images
|
|
if: steps.baseline.outputs.present == 'true' && failure()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: lost-pixel-diff
|
|
path: apps/storybook/.lostpixel/difference
|
|
if-no-files-found: ignore
|
|
retention-days: 14
|