11name : Build, Lint, and Test
22
33on :
4- push :
5- branches : [main]
6- pull_request :
4+ workflow_call :
75
86jobs :
97 prepare :
108 name : Prepare
119 runs-on : ubuntu-latest
12- outputs :
13- YARN_CACHE_DIR : ${{ steps.yarn-cache-dir.outputs.YARN_CACHE_DIR }}
14- YARN_VERSION : ${{ steps.yarn-version.outputs.YARN_VERSION }}
1510 strategy :
1611 matrix :
17- node-version : [18.x, 20.x]
12+ node-version : [18.x, 20.x, 22.x ]
1813 steps :
19- - uses : actions/checkout@v3
20- - name : Use Node.js ${{ matrix.node-version }}
21- uses : actions/setup-node@v3
14+ - name : Checkout and setup environment
15+ uses : MetaMask/action-checkout-and-setup@v1
2216 with :
17+ is-high-risk-environment : false
2318 node-version : ${{ matrix.node-version }}
24- - name : Get Yarn cache directory
25- run : echo "YARN_CACHE_DIR=$(yarn config get cacheFolder)" >> "$GITHUB_OUTPUT"
26- id : yarn-cache-dir
27- - name : Get Yarn version
28- run : echo "YARN_VERSION=$(yarn --version)" >> "$GITHUB_OUTPUT"
29- id : yarn-version
30- - name : Cache Yarn dependencies
31- uses : actions/cache@v3
32- with :
33- path : ${{ steps.yarn-cache-dir.outputs.YARN_CACHE_DIR }}
34- key : yarn-cache-${{ runner.os }}-${{ steps.yarn-version.outputs.YARN_VERSION }}-${{ hashFiles('yarn.lock') }}-${{ matrix.node-version }}
35- - name : Install Yarn dependencies
36- run : yarn --immutable
19+ cache-node-modules : ${{ matrix.node-version == '22.x' }}
20+
3721 build :
3822 name : Build
23+ needs : prepare
3924 runs-on : ubuntu-latest
40- needs :
41- - prepare
4225 strategy :
4326 matrix :
44- node-version : [18.x, 20 .x]
27+ node-version : [22 .x]
4528 steps :
46- - uses : actions/checkout@v3
47- - name : Use Node.js ${{ matrix.node-version }}
48- uses : actions/setup-node@v3
29+ - name : Checkout and setup environment
30+ uses : MetaMask/action-checkout-and-setup@v1
4931 with :
32+ is-high-risk-environment : false
5033 node-version : ${{ matrix.node-version }}
51- - name : Restore Yarn dependencies
52- uses : actions/cache@v3
53- with :
54- path : ${{ needs.prepare.outputs.YARN_CACHE_DIR }}
55- key : yarn-cache-${{ runner.os }}-${{ needs.prepare.outputs.YARN_VERSION }}-${{ hashFiles('yarn.lock') }}-${{ matrix.node-version }}
56- - run : yarn --immutable
5734 - run : yarn build
5835 - name : Require clean working directory
5936 shell : bash
@@ -62,61 +39,48 @@ jobs:
6239 echo "Working tree dirty at end of job"
6340 exit 1
6441 fi
42+
6543 lint :
6644 name : Lint
45+ needs : prepare
6746 runs-on : ubuntu-latest
68- needs :
69- - prepare
7047 strategy :
7148 matrix :
72- node-version : [18.x, 20 .x]
49+ node-version : [22 .x]
7350 steps :
74- - uses : actions/checkout@v3
75- - name : Use Node.js ${{ matrix.node-version }}
76- uses : actions/setup-node@v3
51+ - name : Checkout and setup environment
52+ uses : MetaMask/action-checkout-and-setup@v1
7753 with :
54+ is-high-risk-environment : false
7855 node-version : ${{ matrix.node-version }}
79- - name : Restore Yarn dependencies
80- uses : actions/cache@v3
81- with :
82- path : ${{ needs.prepare.outputs.YARN_CACHE_DIR }}
83- key : yarn-cache-${{ runner.os }}-${{ needs.prepare.outputs.YARN_VERSION }}-${{ hashFiles('yarn.lock') }}-${{ matrix.node-version }}
84- - run : yarn --immutable
8556 - run : yarn lint
86- - run : yarn build
8757 - name : Validate RC changelog
8858 if : ${{ startsWith(github.head_ref, 'release/') }}
89- run : yarn auto- changelog validate --rc
59+ run : yarn lint: changelog --rc
9060 - name : Validate changelog
9161 if : ${{ !startsWith(github.head_ref, 'release/') }}
92- run : yarn auto- changelog validate
62+ run : yarn lint: changelog
9363 - name : Require clean working directory
9464 shell : bash
9565 run : |
9666 if ! git diff --exit-code; then
9767 echo "Working tree dirty at end of job"
9868 exit 1
9969 fi
70+
10071 test :
10172 name : Test
73+ needs : prepare
10274 runs-on : ubuntu-latest
103- needs :
104- - prepare
10575 strategy :
10676 matrix :
107- node-version : [18.x, 20.x]
77+ node-version : [18.x, 20.x, 22.x ]
10878 steps :
109- - uses : actions/checkout@v3
110- - name : Use Node.js ${{ matrix.node-version }}
111- uses : actions/setup-node@v3
79+ - name : Checkout and setup environment
80+ uses : MetaMask/action-checkout-and-setup@v1
11281 with :
82+ is-high-risk-environment : false
11383 node-version : ${{ matrix.node-version }}
114- - name : Restore Yarn dependencies
115- uses : actions/cache@v3
116- with :
117- path : ${{ needs.prepare.outputs.YARN_CACHE_DIR }}
118- key : yarn-cache-${{ runner.os }}-${{ needs.prepare.outputs.YARN_VERSION }}-${{ hashFiles('yarn.lock') }}-${{ matrix.node-version }}
119- - run : yarn --immutable
12084 - run : yarn test
12185 - name : Require clean working directory
12286 shell : bash
@@ -125,25 +89,29 @@ jobs:
12589 echo "Working tree dirty at end of job"
12690 exit 1
12791 fi
128- check-workflows :
129- name : Check workflows
92+
93+ compatibility-test :
94+ name : Compatibility test
95+ needs : prepare
13096 runs-on : ubuntu-latest
97+ strategy :
98+ matrix :
99+ node-version : [18.x, 20.x, 22.x]
131100 steps :
132- - uses : actions/checkout@v3
133- - name : Download actionlint
134- id : download-actionlint
135- run : bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/d5f726fb9c9aaff30c8c3787a9b9640f7612838a/scripts/download-actionlint.bash) 1.6.21
136- shell : bash
137- - name : Check workflow files
138- run : ${{ steps.download-actionlint.outputs.executable }} -color
101+ - name : Checkout and setup environment
102+ uses : MetaMask/action-checkout-and-setup@v1
103+ with :
104+ is-high-risk-environment : false
105+ node-version : ${{ matrix.node-version }}
106+ - name : Install dependencies via Yarn
107+ run : rm yarn.lock && YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn
108+ - run : yarn test
109+ - name : Restore lockfile
110+ run : git restore yarn.lock
111+ - name : Require clean working directory
139112 shell : bash
140- all-jobs-pass :
141- name : All jobs pass
142- runs-on : ubuntu-latest
143- needs :
144- - build
145- - lint
146- - test
147- - check-workflows
148- steps :
149- - run : echo "Great success!"
113+ run : |
114+ if ! git diff --exit-code; then
115+ echo "Working tree dirty at end of job"
116+ exit 1
117+ fi
0 commit comments