chore: ✅ fix storybook #9
Workflow file for this run
This file contains 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: "Visual Tests" | |
on: push | |
jobs: | |
# Install and cache npm dependencies | |
install-cache: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Cache npm dependencies and Cypress | |
uses: actions/cache@v4 | |
id: npm-cache | |
with: | |
path: | | |
~/.cache/Cypress | |
node_modules | |
key: ${{ runner.os }}-npm-v1-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-npm-v1 | |
- name: Install dependencies if cache invalid | |
if: steps.npm-cache.outputs.cache-hit != 'true' | |
run: npm ci | |
# Run interaction and accessibility tests | |
interaction-and-accessibility: | |
runs-on: ubuntu-latest | |
needs: install-cache | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Restore npm dependencies | |
uses: actions/cache@v4 | |
id: npm-cache | |
with: | |
path: | | |
~/.cache/Cypress | |
node_modules | |
key: ${{ runner.os }}-npm-v1-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-npm-v1 | |
- name: Install Playwright | |
run: npx playwright install --with-deps | |
- name: Build Storybook | |
run: npm run build-storybook --quiet | |
- name: Serve Storybook and run tests | |
run: | | |
npx concurrently -k -s first -n "SB,TEST" -c "magenta,blue" \ | |
"npx http-server storybook-static --port 6006 --silent" \ | |
"npx wait-on tcp:6006 && npm run test:storybook" | |
# Run visual and composition tests with Chromatic | |
visual-and-composition: | |
runs-on: ubuntu-latest | |
needs: install-cache | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Required to retrieve Git history | |
- name: Restore npm dependencies | |
uses: actions/cache@v4 | |
id: npm-cache | |
with: | |
path: | | |
~/.cache/Cypress | |
node_modules | |
key: ${{ runner.os }}-npm-v1-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-npm-v1 | |
- name: Publish to Chromatic | |
uses: chromaui/action@latest | |
with: | |
# Grab this from the Chromatic manage page | |
buildScriptName: "build:storybook" | |
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} | |
# Run user flow tests with Cypress | |
user-flow: | |
runs-on: ubuntu-latest | |
needs: install-cache | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Restore npm dependencies | |
uses: actions/cache@v4 | |
id: npm-cache | |
with: | |
path: | | |
~/.cache/Cypress | |
node_modules | |
key: ${{ runner.os }}-npm-v1-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-npm-v1 | |
- name: Cypress run | |
uses: cypress-io/github-action@v6 | |
with: | |
start: npm run dev |