ci: add tests #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: 'UI Tests' | |
on: | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
# Install and cache npm dependencies | |
install-cache: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Cache npm dependencies | |
uses: actions/cache@v3 | |
id: npm-cache | |
with: | |
path: | | |
node_modules | |
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-npm | |
- name: Install dependencies if cache invalid | |
if: steps.npm-cache.outputs.cache-hit != 'true' | |
run: npm install | |
# Run interaction and accessibility tests | |
interaction-and-accessibility: | |
timeout-minutes: 60 | |
runs-on: ubuntu-latest | |
needs: install-cache | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '18.x' | |
- name: Restore npm dependencies | |
uses: actions/cache@v3 | |
id: npm-cache | |
with: | |
path: | | |
node_modules | |
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-npm | |
- name: Install Playwright | |
run: npx playwright install --with-deps | |
- name: Build Storybook | |
run: npm run build-storybook | |
- 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 --timeout 5000 tcp:127.0.0.1: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@v3 | |
id: npm-cache | |
with: | |
path: | | |
node_modules | |
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-npm | |
- name: Publish to Chromatic | |
uses: chromaui/action@v1 | |
with: | |
# Grab this from the Chromatic manage page | |
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} | |