Skip to content

Commit a2b98b1

Browse files
refactor: switch to Yarn v4 (#4686)
* refactor: switch to use yarn v4 fix: github action crashing fix: failing yarn v4 install due to incorrect 3rd party dependency fix: remove Keystone pckg causing yarn v4 failure fix: resolutions fix: failing tests fix: github acitons not working with new yarn v4 fix: update readme Update .github/actions/cache-deps/action.yml Co-authored-by: Usame Algan <5880855+usame-algan@users.noreply.github.com> --------- Co-authored-by: Usame Algan <5880855+usame-algan@users.noreply.github.com>
1 parent 1e305f4 commit a2b98b1

25 files changed

+26142
-20699
lines changed

.github/workflows/build/action.yml renamed to .github/actions/build/action.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ description: 'Build the app'
55
inputs:
66
secrets:
77
required: true
8+
description: 'GitHub secrets as JSON'
89

910
prod: # id of input
1011
description: 'Production build flag'
@@ -18,6 +19,12 @@ runs:
1819
using: 'composite'
1920

2021
steps:
22+
- name: Restore Next.js Build Cache & Cypress cache
23+
id: restore-nc
24+
uses: ./.github/actions/cache-deps
25+
with:
26+
mode: restore-nc
27+
2128
- name: Set environment variables
2229
shell: bash
2330
run: |
@@ -60,3 +67,10 @@ runs:
6067
NEXT_PUBLIC_FIREBASE_VAPID_KEY_STAGING: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_FIREBASE_VAPID_KEY_STAGING }}
6168
NEXT_PUBLIC_SPINDL_SDK_KEY: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_SPINDL_SDK_KEY }}
6269
NEXT_PUBLIC_ECOSYSTEM_ID_ADDRESS: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_ECOSYSTEM_ID_ADDRESS }}
70+
71+
- name: Save Next.js Build Cache & Cypress cache
72+
if: steps.restore-nc.outputs.cache-hit-nc != 'true'
73+
uses: ./.github/actions/cache-deps
74+
with:
75+
mode: save-nc
76+
key: ${{ steps.restore-nc.outputs.computed-cache-key-nc }}

.github/actions/cache-deps/action.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: "Cache Yarn Dependencies"
2+
description: "Restore or save yarn dependencies"
3+
inputs:
4+
mode:
5+
description: "restore-yarn | save-yarn | restore-nc | safe-nc"
6+
required: true
7+
key:
8+
description: "The cache key to use to safe. Attention! Make sure to use the correct computed cache key depending on the mode"
9+
required: false
10+
11+
outputs:
12+
cache-hit-yarn:
13+
value: ${{ steps.restore.outputs.cache-hit }}
14+
description: "Whether the cache was hit or not"
15+
computed-cache-key-yarn:
16+
value: ${{ steps.restore.outputs.cache-primary-key }}
17+
description: "The computed cache key for yarn"
18+
cache-hit-nc:
19+
value: ${{ steps.restore-nc.outputs.cache-hit }}
20+
description: "Whether the cache was hit or not"
21+
computed-cache-key-nc:
22+
value: ${{ steps.restore-nc.outputs.cache-primary-key }}
23+
description: "The computed cache key for nextjs/cypress"
24+
25+
runs:
26+
using: "composite"
27+
steps:
28+
- name: Restore Yarn Cache
29+
if: ${{ inputs.mode == 'restore-yarn' }}
30+
id: restore
31+
uses: actions/cache/restore@v4
32+
with:
33+
path: |
34+
**/node_modules
35+
/home/runner/.cache/Cypress
36+
${{ github.workspace }}/.yarn/install-state.gz
37+
${{ github.workspace }}/src/types
38+
key: ${{ runner.os }}-web-core-modules-${{ hashFiles('**/package.json','**/yarn.lock') }}
39+
restore-keys: |
40+
${{ runner.os }}-web-core-modules-
41+
42+
- name: Set composite outputs yarn
43+
if: ${{ inputs.mode == 'restore-yarn' }}
44+
shell: bash
45+
run: |
46+
echo "cache-hit-yarn=${{ steps.restore.outputs.cache-hit }}" >> $GITHUB_OUTPUT
47+
echo "computed-cache-key-yarn=${{ steps.restore.outputs.cache-primary-key }}" >> $GITHUB_OUTPUT
48+
49+
- name: Save Yarn Cache
50+
if: ${{ inputs.mode == 'save-yarn' }}
51+
uses: actions/cache/save@v4
52+
with:
53+
path: |
54+
**/node_modules
55+
/home/runner/.cache/Cypress
56+
${{ github.workspace }}/.yarn/install-state.gz
57+
${{ github.workspace }}/src/types
58+
key: ${{inputs.key}}
59+
60+
- name: Restore Next.js
61+
if: ${{ inputs.mode == 'restore-nc' }}
62+
id: restore-nc
63+
uses: actions/cache/restore@v4
64+
with:
65+
path: |
66+
${{ github.workspace }}/.next/cache
67+
key: ${{ runner.os }}-nextjs-cypress-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
68+
restore-keys: |
69+
${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}-
70+
71+
- name: Set composite outputs nc
72+
if: ${{ inputs.mode == 'restore-nc' }}
73+
shell: bash
74+
run: |
75+
echo "cache-hit-nc=${{ steps.restore-nc.outputs.cache-hit }}" >> $GITHUB_OUTPUT
76+
echo "computed-cache-key-nc=${{ steps.restore-nc.outputs.cache-primary-key }}" >> $GITHUB_OUTPUT
77+
78+
79+
- name: Save Next.js
80+
if: ${{ inputs.mode == 'save-nc' }}
81+
uses: actions/cache/save@v4
82+
with:
83+
path: |
84+
${{ github.workspace }}/.next/cache
85+
key: ${{inputs.key}}

.github/actions/corepack/action.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name: "Enable corepack"
2+
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: "Enable Corepack"
7+
shell: bash
8+
run: corepack enable

.github/workflows/cypress/action.yml renamed to .github/actions/cypress/action.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,19 @@ inputs:
3030
runs:
3131
using: 'composite'
3232
steps:
33-
- uses: ./.github/workflows/yarn
33+
- uses: ./.github/actions/yarn
3434

3535
- name: Install Latest stable Chrome Version
3636
shell: bash
3737
run: |
3838
curl -O 'https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb'
3939
sudo apt-get install ./google-chrome-stable_current_amd64.deb
4040
41-
- name: Install Cypress 13.15.2
42-
shell: bash
43-
run: yarn add -D cypress@13.15.2
44-
45-
- uses: ./.github/workflows/build
41+
- uses: ./.github/actions/build
4642
with:
4743
secrets: ${{ inputs.secrets }}
4844
e2e_mnemonic: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_CYPRESS_MNEMONIC }}
4945

50-
- name: Serve
51-
shell: bash
52-
run: yarn serve &
53-
5446
- uses: cypress-io/github-action@v6
5547
with:
5648
spec: ${{ inputs.spec }}
@@ -60,6 +52,8 @@ runs:
6052
record: true
6153
tag: ${{ inputs.tag }}
6254
config: baseUrl=http://localhost:8080
55+
install: false
56+
start: yarn serve
6357
env:
6458
CYPRESS_RECORD_KEY: ${{ inputs.record_key || fromJSON(inputs.secrets).CYPRESS_RECORD_KEY }}
6559
GITHUB_TOKEN: ${{ fromJSON(inputs.secrets).GITHUB_TOKEN }}

.github/actions/yarn/action.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: 'Yarn'
2+
3+
description: 'Install the dependencies'
4+
5+
runs:
6+
using: 'composite'
7+
steps:
8+
# We require yarn v4 and installing through corepack is the easiest way to get it
9+
- uses: actions/checkout@v4
10+
11+
- uses: ./.github/actions/corepack
12+
13+
- name: Restore Yarn Cache & Types
14+
id: restore-yarn-types
15+
uses: ./.github/actions/cache-deps
16+
with:
17+
mode: restore-yarn
18+
19+
- name: Echo cache hit
20+
shell: bash
21+
run: |
22+
echo "Yarn cache hit: ${{ steps.restore-yarn-types.outputs.cache-hit-yarn }}"
23+
24+
- name: Yarn install & after-install generate types
25+
if: steps.restore-yarn-types.outputs.cache-hit-yarn != 'true'
26+
shell: bash
27+
run: |
28+
yarn install --immutable
29+
yarn after-install
30+
31+
- name: Save Yarn Cache & Types
32+
if: steps.restore-yarn-types.outputs.cache-hit-yarn != 'true'
33+
uses: ./.github/actions/cache-deps
34+
with:
35+
mode: save-yarn
36+
key: ${{ steps.restore-yarn-types.outputs.computed-cache-key-yarn }}

.github/workflows/deploy-dev.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ jobs:
3636

3737
- uses: actions/checkout@v4
3838

39-
- uses: ./.github/workflows/yarn
39+
- uses: ./.github/actions/yarn
4040

41-
- uses: ./.github/workflows/build
41+
- uses: ./.github/actions/build
4242
with:
4343
secrets: ${{ toJSON(secrets) }}
44-
if: startsWith(github.ref, 'refs/heads/main')
44+
# if: startsWith(github.ref, 'refs/heads/main')
4545

4646
#- uses: ./.github/workflows/build-storybook
4747

.github/workflows/deploy-production.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ jobs:
1919
steps:
2020
- uses: actions/checkout@v4
2121

22-
- uses: ./.github/workflows/yarn
22+
- uses: ./.github/actions/yarn
2323

24-
- uses: ./.github/workflows/build
24+
- uses: ./.github/actions/build
2525
with:
2626
secrets: ${{ toJSON(secrets) }}
2727
prod: ${{ true }}

.github/workflows/e2e-full-ondemand.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
steps:
2222
- uses: actions/checkout@v4
2323

24-
- uses: ./.github/workflows/cypress
24+
- uses: ./.github/actions/cypress
2525
with:
2626
secrets: ${{ toJSON(secrets) }}
2727
spec: |

.github/workflows/e2e-hp-ondemand.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
steps:
2222
- uses: actions/checkout@v4
2323

24-
- uses: ./.github/workflows/cypress
24+
- uses: ./.github/actions/cypress
2525
with:
2626
secrets: ${{ toJSON(secrets) }}
2727
spec: |

.github/workflows/e2e-ondemand.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
steps:
2020
- uses: actions/checkout@v4
2121

22-
- uses: ./.github/workflows/cypress
22+
- uses: ./.github/actions/cypress
2323
with:
2424
secrets: ${{ toJSON(secrets) }}
2525
spec: |

.github/workflows/e2e-prod-ondemand.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
steps:
2121
- uses: actions/checkout@v4
2222

23-
- uses: ./.github/workflows/cypress
23+
- uses: ./.github/actions/cypress
2424
with:
2525
secrets: ${{ toJSON(secrets) }}
2626
spec: |

.github/workflows/e2e-safe-apps.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
steps:
2020
- uses: actions/checkout@v4
2121

22-
- uses: ./.github/workflows/cypress
22+
- uses: ./.github/actions/cypress
2323
with:
2424
secrets: ${{ toJSON(secrets) }}
2525
spec: cypress/e2e/safe-apps/*.cy.js

.github/workflows/e2e-smoke.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
steps:
2222
- uses: actions/checkout@v4
2323

24-
- uses: ./.github/workflows/cypress
24+
- uses: ./.github/actions/cypress
2525
with:
2626
secrets: ${{ toJSON(secrets) }}
2727
spec: cypress/e2e/smoke/*.cy.js

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
steps:
1717
- uses: actions/checkout@v4
1818

19-
- uses: ./.github/workflows/yarn
19+
- uses: ./.github/actions/yarn
2020

2121
- uses: CatChen/eslint-suggestion-action@v4.1.7
2222
with:

.github/workflows/nextjs-bundle-analysis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ jobs:
2121
- uses: actions/checkout@v4
2222

2323
- name: Install dependencies
24-
uses: ./.github/workflows/yarn
24+
uses: ./.github/actions/yarn
2525

2626
- name: Build next.js app
27-
uses: ./.github/workflows/build
27+
uses: ./.github/actions/build
2828
with:
2929
secrets: ${{ toJSON(secrets) }}
3030

.github/workflows/unit-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
steps:
2222
- uses: actions/checkout@v4
2323

24-
- uses: ./.github/workflows/yarn
24+
- uses: ./.github/actions/yarn
2525

2626
- name: Annotations and coverage report
2727
uses: ArtiomTr/jest-coverage-report-action@v2.3.1

.github/workflows/yarn/action.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,6 @@ yalc.lock
5656
/public/*.js.LICENSE.txt
5757
certificates
5858
*storybook.log
59+
60+
# Yarn v4
61+
.yarn/*

.yarnrc.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
compressionLevel: mixed
2+
3+
enableGlobalCache: true
4+
5+
nodeLinker: node-modules

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,25 @@ If you don't provide some of the variables, the corresponding features will be d
5151

5252
### Running the app locally
5353

54+
#### Prerequisites
55+
56+
- **Node.js**: Install the latest stable version from [Node.js](https://nodejs.org/).
57+
58+
We use Yarn v4 for package management. If you are running on Node.js v16 or later, you can run:
59+
60+
```bash
61+
corepack enable
62+
```
63+
64+
and then when you run `yarn` in the repository root, it will install the required version of yarn and resolve all
65+
dependencies.
66+
67+
> [!INFO]
68+
>
69+
> Corepack is a tool to help with managing versions of your package managers. It exposes binary proxies for each
70+
> supported package manager that, when called, will identify whatever package manager is
71+
> configured for the current project, download it if needed, and finally run it.
72+
5473
Install the dependencies:
5574

5675
```bash

jest.setup.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { Request } from 'node-fetch'
66

77
jest.mock('@web3-onboard/coinbase', () => jest.fn())
88
jest.mock('@web3-onboard/injected-wallets', () => ({ ProviderLabel: { MetaMask: 'MetaMask' } }))
9-
jest.mock('@web3-onboard/keystone/dist/index', () => jest.fn())
109
jest.mock('@web3-onboard/ledger/dist/index', () => jest.fn())
1110
jest.mock('@web3-onboard/trezor', () => jest.fn())
1211
jest.mock('@web3-onboard/walletconnect', () => jest.fn())

0 commit comments

Comments
 (0)