refactor: move LHS sidebar in-flow + RHS TOC overflow handling (#387) #1162
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build Fixtures Site for Visual Regression Tests | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| # Visual regression tests run against the curated quantecon-book-theme-fixtures | |
| # site, pinned to a specific commit so the input doesn't move between theme | |
| # PRs. To bump the pin, update FIXTURES_SHA below. | |
| env: | |
| FIXTURES_REPO: QuantEcon/quantecon-book-theme-fixtures | |
| FIXTURES_SHA: d8ffc17c753ecf45fa25c6062827e1aa9de201b3 | |
| # Explicit least-privilege permissions: | |
| # contents: write — checkout + upload-artifact + nwtgck/actions-netlify | |
| # posts commit comments (POST /commits/<sha>/comments) | |
| # actions: read — download-artifact (cross-job) | |
| # pull-requests: write — daun/playwright-report-summary PR comment | |
| # statuses: write — nwtgck/actions-netlify commit status (preview URL) | |
| # deployments: write — nwtgck/actions-netlify GitHub deployments record | |
| # The earlier narrower version (contents:read, pull-requests:write only) caused | |
| # the Netlify action's preview-URL notification to fail 403 — deploy succeeded | |
| # but reviewers couldn't see the link from the PR. | |
| permissions: | |
| contents: write | |
| actions: read | |
| pull-requests: write | |
| statuses: write | |
| deployments: write | |
| # The CI is split into three jobs so the Netlify preview deploys regardless | |
| # of whether visual regression tests pass. Reviewers need the preview link | |
| # to *decide* whether failing visual tests reflect intentional design changes | |
| # (in which case they comment /update-snapshots) or genuine regressions. | |
| # Previously the preview was a later step of a single job and got skipped on | |
| # visual-test failure — exactly the case where reviewers need it most. | |
| # | |
| # build → visual (gate; may fail) | |
| # ↘ | |
| # preview (always runs; uploads the artifact reviewers eyeball) | |
| # | |
| # `build` produces the fixtures HTML once; `visual` and `preview` consume it | |
| # in parallel via actions/upload-artifact + download-artifact. | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout theme | |
| uses: actions/checkout@v6 | |
| - name: Checkout fixtures | |
| uses: actions/checkout@v6 | |
| with: | |
| repository: ${{ env.FIXTURES_REPO }} | |
| ref: ${{ env.FIXTURES_SHA }} | |
| path: fixtures | |
| - name: Setup Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.13" | |
| cache: "pip" | |
| - name: Install fixtures build deps + this PR's theme | |
| run: | | |
| pip install -r fixtures/requirements.txt | |
| pip install . | |
| - name: Build fixtures site | |
| working-directory: fixtures | |
| run: jb build . --warningiserror | |
| - name: Upload fixtures build artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: fixtures-build | |
| path: fixtures/_build/html/ | |
| retention-days: 1 | |
| visual: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout theme | |
| uses: actions/checkout@v6 | |
| - name: Download fixtures build artifact | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: fixtures-build | |
| path: fixtures/_build/html/ | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Install Playwright | |
| run: | | |
| npm ci | |
| npx playwright install --with-deps chromium | |
| - name: Run Visual Regression Tests | |
| id: visual-tests | |
| run: npm run test:visual | |
| continue-on-error: true | |
| env: | |
| SITE_PATH: fixtures/_build/html | |
| - name: Upload Playwright Report | |
| uses: actions/upload-artifact@v7 | |
| if: always() | |
| with: | |
| name: playwright-report | |
| path: playwright-report/ | |
| retention-days: 30 | |
| - name: Upload Test Results (on failure) | |
| uses: actions/upload-artifact@v7 | |
| if: steps.visual-tests.outcome == 'failure' | |
| with: | |
| name: visual-test-diff | |
| path: test-results/ | |
| retention-days: 30 | |
| - name: Post Visual Test Results to PR | |
| uses: daun/playwright-report-summary@v4 | |
| if: github.event_name == 'pull_request' | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| report-file: playwright-report/results.json | |
| comment-title: '🎭 Visual Regression Test Results' | |
| - name: Fail if Visual Tests Failed | |
| if: steps.visual-tests.outcome == 'failure' | |
| run: exit 1 | |
| preview: | |
| needs: build | |
| # Skip on forks: PRs from fork repos don't get NETLIFY_AUTH_TOKEN / | |
| # NETLIFY_SITE_ID secrets, so the deploy would fail and block external | |
| # contributors' CI. Matches the codecov guard pattern in tests.yml:51. | |
| if: > | |
| github.repository == 'QuantEcon/quantecon-book-theme' && | |
| (github.event_name == 'push' || | |
| github.event.pull_request.head.repo.full_name == github.repository) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download fixtures build artifact | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: fixtures-build | |
| path: fixtures/_build/html/ | |
| - name: Preview Deploy to Netlify | |
| uses: nwtgck/actions-netlify@v3.0 | |
| with: | |
| publish-dir: 'fixtures/_build/html/' | |
| production-branch: main | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| deploy-message: "Preview Deploy from GitHub Actions" | |
| env: | |
| NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
| NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} |