Skip to content

Feature branch pull-request from feature/floating-ui to main #5245

Feature branch pull-request from feature/floating-ui to main

Feature branch pull-request from feature/floating-ui to main #5245

Workflow file for this run

name: Chromatic - Pull Request
on:
pull_request:
# This allows us to run the workflow on PRs from when they move from draft
# to non-draft.
types: [edited, opened, synchronize, reopened]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
chromatic_changesets:
# Only run this workflow when the Release PR is opened/created.
if: startsWith(github.head_ref, 'changeset-release/')
name: Chromatic - Skip on Release PR (changesets)
uses: ./.github/workflows/chromatic-build.yml
with:
target: 'bot'
secrets:
projectToken: ${{ secrets.CHROMATIC_APP_CODE }}
# ------- Regular PRs --------
chromatic_review:
# (if) Run this step on regular PRs.
if: |
github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]' &&
!startsWith(github.head_ref, 'changeset-release/')
name: Build on regular PRs
uses: ./.github/workflows/chromatic-build.yml
with:
target: 'review'
secrets:
projectToken: ${{ secrets.CHROMATIC_APP_CODE }}
chromatic_review_results:
# (if) Run this step on regular PRs.
if: |
github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]' &&
!startsWith(github.head_ref, 'changeset-release/')
name: Get results on regular PRs
needs: chromatic_review
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
node-version: [20.x]
steps:
# Create/update PR comment with Chromatic results
- name: Find existing comment
uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: A new build was pushed to Chromatic!
- name: Create or update comment
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
edit-mode: replace
issue-number: ${{ github.event.pull_request.number }}
body: |
# A new build was pushed to Chromatic! :rocket:
${{ needs.chromatic_review.outputs.storybookUrl }}
## Chromatic results:
| Metric | Total |
|---|---|
| Captured snapshots | ${{ needs.chromatic_review.outputs.actualCaptureCount }} |
| Tests with visual changes | ${{ needs.chromatic_review.outputs.changeCount }} |
| Total stories | ${{ needs.chromatic_review.outputs.specCount }} |
| Inherited (not captured) snapshots [TurboSnap] | ${{ needs.chromatic_review.outputs.inheritedCaptureCount }} |
| Tests on the build | ${{ needs.chromatic_review.outputs.testCount }} |
storybook_tests:
# (if) Run this step on regular PRs.
if: |
github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]' &&
!startsWith(github.head_ref, 'changeset-release/')
name: Run Storybook tests
needs: chromatic_review
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
node-version: [20.x]
steps:
- name: Checking out latest commit
uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
# Cache and install dependencies
- name: Install & cache node_modules
uses: ./.github/actions/shared-node-cache
with:
node-version: ${{ matrix.node-version }}
# Install Playwright browsers so Vitest browser mode can run story tests
- name: Install playwright dependencies
run: pnpm exec playwright install chromium --with-deps
# Build the project
- name: Generate WB build artifacts
run: pnpm build
- name: Run Storybook tests
run: pnpm test:storybook
env:
SB_URL: '${{ needs.chromatic_review.outputs.storybookUrl }}'