Skip to content

Commit 3763bb3

Browse files
committed
Adds CI caching for tests
1 parent 4a47b38 commit 3763bb3

File tree

1 file changed

+52
-6
lines changed

1 file changed

+52
-6
lines changed

.github/workflows/ui-tests.yml

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,44 @@ name: "UI Tests"
33
on: push
44

55
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
625
# Run interaction and accessibility tests
726
interaction-and-accessibility:
827
runs-on: ubuntu-latest
28+
needs: install-cache
929
steps:
1030
- uses: actions/checkout@v2
1131
- uses: actions/setup-node@v2
1232
with:
1333
node-version: "16.x"
14-
- name: Install dependencies
15-
run: yarn
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
1644
- name: Install Playwright
1745
run: npx playwright install --with-deps
1846
- name: Build Storybook
@@ -25,12 +53,21 @@ jobs:
2553
# Run visual and composition tests with Chromatic
2654
visual-and-composition:
2755
runs-on: ubuntu-latest
56+
needs: install-cache
2857
steps:
2958
- uses: actions/checkout@v2
3059
with:
3160
fetch-depth: 0 # Required to retrieve git history
32-
- name: Install dependencies
33-
run: yarn
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
3471
- name: Publish to Chromatic
3572
uses: chromaui/action@v1
3673
with:
@@ -39,10 +76,19 @@ jobs:
3976
# Run user flow tests with Cypress
4077
user-flow:
4178
runs-on: ubuntu-latest
79+
needs: install-cache
4280
steps:
4381
- uses: actions/checkout@v2
44-
- name: Install dependencies
45-
run: yarn
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
4692
- name: Cypress run
4793
uses: cypress-io/github-action@v4
4894
with:

0 commit comments

Comments
 (0)