-
Notifications
You must be signed in to change notification settings - Fork 292
73 lines (71 loc) · 3.24 KB
/
reusable-setup-cache.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Description: this is a reusable workflow that sets up cache for unit and e2e testss.
on:
workflow_call:
inputs:
commit:
# commit to run tests against
required: true
type: string
repository:
# repository to run tests against (possibly a fork of amplify-ui)
required: true
type: string
jobs:
setup:
runs-on: ubuntu-latest
steps:
- name: Checkout Amplify UI
uses: actions/checkout@b80ff79f1755d06ba70441c368a6fe801f5f3a62 # v4.1.3 https://github.com/actions/checkout/commit/cd7d8d697e10461458bc61a30d094dc601a8b017
with:
ref: ${{ inputs.commit }}
repository: ${{ inputs.repository }}
persist-credentials: false
- name: Setup Node.js 20
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 https://github.com/actions/setup-node/commit/60edb5dd545a775178f52524783378180af0d1f8
with:
node-version: 20
cache: 'yarn'
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2
- name: Restore cypress runner from Cache
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 https://github.com/actions/cache/commit/0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
id: restore-cypress-cache
with:
path: ~/.cache/Cypress
key: ${{ runner.os }}-cypress-${{ hashFiles('yarn.lock') }}
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1
- name: Restore Puppeteer runner from Cache
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 https://github.com/actions/cache/commit/0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
id: restore-puppeteer-cache
with:
path: ~/.cache/puppeteer
key: ${{ runner.os }}-puppeteer-${{ hashFiles('yarn.lock') }}
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1
- name: Install packages
uses: ./.github/actions/install-with-retries
with:
# only install binary if cypress cache missed
skip-cypress-binary: ${{ steps.restore-cypress-cache.outputs.cache-hit }}
- name: Build ui package
run: yarn ui build
- name: Cache cypress runner
# create new cypress cache entry only if cypress cache missed and we installed a new one.
if: steps.restore-cypress-cache.outputs.cache-hit != 'true'
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 https://github.com/actions/cache/commit/0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
with:
path: ~/.cache/Cypress
key: ${{ runner.os }}-cypress-${{ hashFiles('yarn.lock') }}
- name: Cache packages/ui/dist
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 https://github.com/actions/cache/commit/0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
with:
path: ./packages/ui/dist
key: ${{ runner.os }}-ui-${{ inputs.commit }}
- name: Cache node_modules
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 https://github.com/actions/cache/commit/0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
with:
path: |
./node_modules
**/node_modules
key: ${{ runner.os }}-nodemodules-${{ inputs.commit }}