|
1 | | -# Description: this is a reusable workflow that sets up cache for unit and e2e testss. |
| 1 | +# Description: this is a reusable workflow that sets up cache for unit and e2e tests. |
| 2 | +# It checks if caches exist and populates them if missing, so downstream jobs can restore them. |
2 | 3 |
|
3 | 4 | on: |
4 | 5 | workflow_call: |
@@ -29,44 +30,51 @@ jobs: |
29 | 30 | cache: 'yarn' |
30 | 31 | env: |
31 | 32 | SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2 |
32 | | - - name: Restore cypress runner from Cache |
33 | | - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 https://github.com/actions/cache/commit/1bd1e32a3bdc45362d1e726936510720a7c30a57 |
34 | | - id: restore-cypress-cache |
| 33 | + - name: Check if Cypress cache exists |
| 34 | + uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 |
| 35 | + id: check-cypress-cache |
35 | 36 | with: |
36 | 37 | path: ~/.cache/Cypress |
37 | 38 | key: ${{ runner.os }}-cypress-${{ hashFiles('yarn.lock') }} |
38 | | - env: |
39 | | - SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1 |
40 | | - - name: Restore Puppeteer runner from Cache |
41 | | - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 https://github.com/actions/cache/commit/1bd1e32a3bdc45362d1e726936510720a7c30a57 |
42 | | - id: restore-puppeteer-cache |
| 39 | + lookup-only: true |
| 40 | + - name: Check if Puppeteer cache exists |
| 41 | + uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 |
| 42 | + id: check-puppeteer-cache |
43 | 43 | with: |
44 | 44 | path: ~/.cache/puppeteer |
45 | 45 | key: ${{ runner.os }}-puppeteer-${{ hashFiles('yarn.lock') }} |
46 | | - env: |
47 | | - SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1 |
48 | | - - name: Restore node_modules from Cache |
49 | | - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 https://github.com/actions/cache/commit/1bd1e32a3bdc45362d1e726936510720a7c30a57 |
50 | | - id: restore-node-modules-cache |
| 46 | + lookup-only: true |
| 47 | + - name: Check if node_modules cache exists |
| 48 | + uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 |
| 49 | + id: check-node-modules-cache |
51 | 50 | with: |
52 | 51 | path: | |
53 | 52 | ./node_modules |
54 | 53 | **/node_modules |
55 | 54 | key: ${{ runner.os }}-nodemodules-${{ hashFiles('yarn.lock') }} |
56 | | - env: |
57 | | - SEGMENT_DOWNLOAD_TIMEOUT_MINS: 3 |
| 55 | + lookup-only: true |
58 | 56 | - name: Install packages |
59 | | - if: steps.restore-node-modules-cache.outputs.cache-hit != 'true' |
| 57 | + if: steps.check-node-modules-cache.outputs.cache-hit != 'true' |
60 | 58 | uses: ./.github/actions/install-with-retries |
61 | 59 | with: |
62 | | - # only install binary if cypress cache missed |
63 | | - skip-cypress-binary: ${{ steps.restore-cypress-cache.outputs.cache-hit }} |
64 | | - - name: Restore packages/ui/dist from Cache |
65 | | - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 https://github.com/actions/cache/commit/1bd1e32a3bdc45362d1e726936510720a7c30a57 |
66 | | - id: restore-ui-cache |
| 60 | + skip-cypress-binary: ${{ steps.check-cypress-cache.outputs.cache-hit }} |
| 61 | + - name: Cache node_modules |
| 62 | + if: steps.check-node-modules-cache.outputs.cache-hit != 'true' |
| 63 | + uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 |
67 | 64 | with: |
68 | | - path: ./packages/ui/dist |
69 | | - key: ${{ runner.os }}-ui-${{ inputs.commit }} |
70 | | - - name: Build ui package |
71 | | - if: steps.restore-ui-cache.outputs.cache-hit != 'true' |
72 | | - run: yarn ui build |
| 65 | + path: | |
| 66 | + ./node_modules |
| 67 | + **/node_modules |
| 68 | + key: ${{ runner.os }}-nodemodules-${{ hashFiles('yarn.lock') }} |
| 69 | + - name: Cache Cypress |
| 70 | + if: steps.check-cypress-cache.outputs.cache-hit != 'true' |
| 71 | + uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 |
| 72 | + with: |
| 73 | + path: ~/.cache/Cypress |
| 74 | + key: ${{ runner.os }}-cypress-${{ hashFiles('yarn.lock') }} |
| 75 | + - name: Cache Puppeteer |
| 76 | + if: steps.check-puppeteer-cache.outputs.cache-hit != 'true' |
| 77 | + uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 |
| 78 | + with: |
| 79 | + path: ~/.cache/puppeteer |
| 80 | + key: ${{ runner.os }}-puppeteer-${{ hashFiles('yarn.lock') }} |
0 commit comments