Skip to content

Commit fefe91e

Browse files
committed
add GitHub action to run jest, chromatic and cypress
1 parent 6ae3224 commit fefe91e

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed

.github/workflows/ui-tests.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: 'UI Tests'
2+
3+
on: push
4+
5+
jobs:
6+
# Install and cache npm dependencies
7+
install-cache:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout Commit
11+
uses: actions/checkout@v2
12+
- name: Cache yarn dependencies and cypress
13+
uses: actions/cache@v2
14+
id: yarn-cache
15+
with:
16+
path: |
17+
~/.cache/Cypress
18+
node_modules
19+
key: ${{ runner.os }}-yarn-v1-${{ hashFiles('**/yarn.lock') }}
20+
restore-keys: |
21+
${{ runner.os }}-yarn-v1
22+
- name: Install dependencies if cache invalid
23+
if: steps.yarn-cache.outputs.cache-hit != 'true'
24+
run: yarn
25+
# Run interaction and accessibility tests
26+
interaction-and-accessibility:
27+
runs-on: ubuntu-latest
28+
needs: install-cache
29+
steps:
30+
- uses: actions/checkout@v2
31+
- uses: actions/setup-node@v2
32+
with:
33+
node-version: '14.x'
34+
- name: Restore yarn dependencies
35+
uses: actions/cache@v2
36+
id: yarn-cache
37+
with:
38+
path: |
39+
~/.cache/Cypress
40+
node_modules
41+
key: ${{ runner.os }}-yarn-v1-${{ hashFiles('**/yarn.lock') }}
42+
restore-keys: |
43+
${{ runner.os }}-yarn-v1
44+
- name: Install Playwright
45+
run: npx playwright install --with-deps
46+
- name: Build Storybook
47+
run: yarn build-storybook --quiet
48+
- name: Serve Storybook and run tests
49+
run: |
50+
npx concurrently -k -s first -n "SB,TEST" -c "magenta,blue" \
51+
"npx http-server storybook-static --port 6006 --silent" \
52+
"npx wait-on tcp:6006 && yarn test-storybook"
53+
# Run visual and composition tests with Chromatic
54+
visual-and-composition:
55+
runs-on: ubuntu-latest
56+
needs: install-cache
57+
steps:
58+
- uses: actions/checkout@v2
59+
with:
60+
fetch-depth: 0 # Required to retrieve git history
61+
- name: Restore yarn dependencies
62+
uses: actions/cache@v2
63+
id: yarn-cache
64+
with:
65+
path: |
66+
~/.cache/Cypress
67+
node_modules
68+
key: ${{ runner.os }}-yarn-v1-${{ hashFiles('**/yarn.lock') }}
69+
restore-keys: |
70+
${{ runner.os }}-yarn-v1
71+
- name: Publish to Chromatic
72+
uses: chromaui/action@v1
73+
with:
74+
# Grab this from the Chromatic manage page
75+
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
76+
# Run user flow tests with Cypress
77+
user-flow:
78+
runs-on: ubuntu-latest
79+
needs: install-cache
80+
steps:
81+
- uses: actions/checkout@v2
82+
- name: Restore yarn dependencies
83+
uses: actions/cache@v2
84+
id: yarn-cache
85+
with:
86+
path: |
87+
~/.cache/Cypress
88+
node_modules
89+
key: ${{ runner.os }}-yarn-v1-${{ hashFiles('**/yarn.lock') }}
90+
restore-keys: |
91+
${{ runner.os }}-yarn-v1
92+
- name: Cypress run
93+
uses: cypress-io/github-action@v2
94+
with:
95+
start: npm start

0 commit comments

Comments
 (0)