name: CI # Pull requests run the full suite. A push to main only refreshes the pnpm, turbo # and Playwright caches that pull requests restore from. on: push: branches: - main pull_request: branches: - main # A new push to a PR supersedes the run in flight; runs on main always finish. concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: ${{ github.event_name == 'pull_request' }} permissions: id-token: write # OIDC for auth (e.g. artifact upload, future signing) contents: read jobs: video: strategy: fail-fast: false matrix: os: [macos-latest, windows-latest] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v6 - uses: actions/setup-node@v6 with: node-version: 22 - name: Enable Corepack run: corepack enable - name: Install pnpm run: corepack prepare pnpm@10.28.1 --activate - name: Install dependencies run: pnpm install --frozen-lockfile - name: Build the test reporter and what it needs run: pnpm turbo run build --filter=executable-stories-vitest - name: Encode video with the installed ffmpeg run: pnpm --filter executable-stories-formatters exec vitest run test/video.test.ts build-and-test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 - uses: actions/setup-node@v6 with: node-version: 22 - name: Enable Corepack run: corepack enable - name: Install pnpm run: corepack prepare pnpm@10.28.1 --activate # pnpm 10 keeps its store under ~/.local/share/pnpm; ask it for the path. - name: Locate pnpm store id: pnpm-store run: echo "path=$(pnpm store path --silent)" >> "$GITHUB_OUTPUT" - name: Cache pnpm dependencies uses: actions/cache@v5 with: path: ${{ steps.pnpm-store.outputs.path }} key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} restore-keys: | ${{ runner.os }}-pnpm- - name: Install dependencies run: pnpm install --frozen-lockfile # Unchanged packages replay their turbo results from an earlier run. - name: Cache turbo uses: actions/cache@v5 with: path: .turbo/cache key: ${{ runner.os }}-turbo-${{ github.sha }} restore-keys: | ${{ runner.os }}-turbo- - name: Setup Bun uses: oven-sh/setup-bun@v2 with: bun-version: "1.3.13" # Build the workspace first so the binary compile can resolve # executable-stories-core's built subpaths (its exports map points at # dist/*). turbo caches this, so the later Quality build is a cache hit. - name: Build packages run: pnpm build - name: Build formatters binary if: github.event_name == 'pull_request' && hashFiles('packages/executable-stories-formatters/package.json') != '' run: cd packages/executable-stories-formatters && pnpm run compile # Browser binaries only; --with-deps below still installs system packages. Every suite runs # Chromium, so only its packages: all three browsers' (WebKit's codecs) took ~25 min of apt. - name: Cache Playwright browsers uses: actions/cache@v5 with: path: ~/.cache/ms-playwright key: ${{ runner.os }}-playwright-${{ hashFiles('**/pnpm-lock.yaml') }} - name: Install Playwright browsers run: pnpm --filter executable-stories-playwright exec playwright install --with-deps chromium && pnpm --filter playwright-example exec playwright install chromium && pnpm --filter formatters-e2e exec playwright install chromium - name: Quality (build, lint, type-check, test) if: github.event_name == 'pull_request' run: pnpm quality env: CI: true # executable-stories-showcase drives four example apps in a browser. Its # visual baselines (*-linux.png) come from this image, so the job runs in it; # keep the image version in step with @playwright/test so screenshots render # identically. The Quality job above runs the showcase unit tests. showcase-e2e: if: github.event_name == 'pull_request' runs-on: ubuntu-latest container: image: mcr.microsoft.com/playwright:v1.64.1-noble steps: - uses: actions/checkout@v6 - uses: actions/setup-node@v6 with: node-version: 22 - name: Enable Corepack run: corepack enable - name: Install pnpm run: corepack prepare pnpm@10.28.1 --activate - name: Locate pnpm store id: pnpm-store run: echo "path=$(pnpm store path --silent)" >> "$GITHUB_OUTPUT" - name: Cache pnpm dependencies uses: actions/cache@v5 with: path: ${{ steps.pnpm-store.outputs.path }} key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} restore-keys: | ${{ runner.os }}-pnpm- - name: Install dependencies run: pnpm install --frozen-lockfile - name: Build showcase packages run: pnpm turbo build --filter=showcase-example... - name: Validate demo scenarios working-directory: apps/showcase # The CLI's bin is linked at install, before its dist exists, so call the build directly. run: node ../../packages/executable-stories-showcase-cli/dist/cli.js validate examples/demo-react/scenarios --rules examples/demo-react/rules.ts - name: Playwright tests run: pnpm --filter showcase-example test:e2e env: CI: true - name: Upload Playwright report if: failure() uses: actions/upload-artifact@v7 with: name: showcase-playwright-report path: | apps/showcase/playwright-report/ apps/showcase/test-results/ # The Vitest adapter declares `vitest: ">=5.0.5"`. This runs the adapter against # that floor. The version is pinned exactly rather than floated (`5`, `^5.0.5`) # so a fresh 5.x cannot fail the job on the workspace's 7-day supply-chain # quarantine. peer-range: name: vitest ${{ matrix.vitest }} if: github.event_name == 'pull_request' runs-on: ubuntu-latest strategy: fail-fast: false matrix: vitest: - "5.0.5" # the declared floor steps: - uses: actions/checkout@v6 - uses: actions/setup-node@v6 with: node-version: 22 - name: Enable Corepack run: corepack enable - name: Install pnpm run: corepack prepare pnpm@10.28.1 --activate # pnpm 10 keeps its store under ~/.local/share/pnpm; ask it for the path. - name: Locate pnpm store id: pnpm-store run: echo "path=$(pnpm store path --silent)" >> "$GITHUB_OUTPUT" - name: Cache pnpm dependencies uses: actions/cache@v5 with: path: ${{ steps.pnpm-store.outputs.path }} key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} restore-keys: | ${{ runner.os }}-pnpm- - name: Install dependencies run: pnpm install --frozen-lockfile # The adapter imports executable-stories-core and -formatters through # their exports maps, which point at dist/*. Those have to exist before # its vitest.config.ts can load the reporter. - name: Build packages run: pnpm turbo build --filter=executable-stories-vitest... - name: Downgrade vitest to ${{ matrix.vitest }} run: pnpm --filter executable-stories-vitest add -D vitest@${{ matrix.vitest }} env: CI: true - name: Type-check against vitest ${{ matrix.vitest }} types run: pnpm --filter executable-stories-vitest type-check - name: Test against vitest ${{ matrix.vitest }} run: pnpm --filter executable-stories-vitest test env: CI: true dependabot-auto-merge: needs: [build-and-test, peer-range] runs-on: ubuntu-latest # The workflow-level grant is contents: read, which cannot merge. Raise it # for this job alone rather than for the whole file. permissions: contents: write pull-requests: write if: github.actor == 'dependabot[bot]' && github.event_name == 'pull_request' steps: - name: Dependabot metadata id: metadata uses: dependabot/fetch-metadata@v2 with: github-token: "${{ secrets.GITHUB_TOKEN }}" - name: Auto-merge Dependabot PRs if: steps.metadata.outputs.update-type == 'version-update:semver-patch' || steps.metadata.outputs.update-type == 'version-update:semver-minor' run: gh pr merge --auto --merge "$PR_URL" env: PR_URL: ${{ github.event.pull_request.html_url }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}