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 :
1712        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 :
4427        node-version : [18.x, 20.x, 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,42 @@ jobs:
6239            echo "Working tree dirty at end of job" 
6340            exit 1 
6441          fi 
42+ 
6543lint :
6644    name : Lint 
45+     needs : prepare 
6746    runs-on : ubuntu-latest 
68-     needs :
69-       - prepare 
7047    strategy :
7148      matrix :
7249        node-version : [18.x, 20.x, 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 
87-       - name : Validate RC changelog 
88-         if : ${{ startsWith(github.head_ref, 'release/') }} 
89-         run : yarn auto-changelog validate --rc 
90-       - name : Validate changelog 
91-         if : ${{ !startsWith(github.head_ref, 'release/') }} 
92-         run : yarn auto-changelog validate 
9357      - name : Require clean working directory 
9458        shell : bash 
9559        run : | 
9660          if ! git diff --exit-code; then 
9761            echo "Working tree dirty at end of job" 
9862            exit 1 
9963          fi 
64+ 
10065test :
10166    name : Test 
67+     needs : prepare 
10268    runs-on : ubuntu-latest 
103-     needs :
104-       - prepare 
10569    strategy :
10670      matrix :
10771        node-version : [18.x, 20.x, 22.x] 
10872    steps :
109-       - uses : actions/checkout@v3 
110-       - name : Use Node.js ${{ matrix.node-version }} 
111-         uses : actions/setup-node@v3 
73+       - name : Checkout and setup environment 
74+         uses : MetaMask/action-checkout-and-setup@v1 
11275        with :
76+           is-high-risk-environment : false 
11377          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 
12078      - run : yarn test 
12179      - name : Require clean working directory 
12280        shell : bash 
@@ -125,25 +83,29 @@ jobs:
12583            echo "Working tree dirty at end of job" 
12684            exit 1 
12785          fi 
128- check-workflows :
129-     name : Check workflows 
86+ 
87+ compatibility-test :
88+     name : Compatibility test 
89+     needs : prepare 
13090    runs-on : ubuntu-latest 
91+     strategy :
92+       matrix :
93+         node-version : [18.x, 20.x, 22.x] 
13194    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 
95+       - name : Checkout and setup environment 
96+         uses : MetaMask/action-checkout-and-setup@v1 
97+         with :
98+           is-high-risk-environment : false 
99+           node-version : ${{ matrix.node-version }} 
100+       - name : Install dependencies via Yarn 
101+         run : rm yarn.lock && YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn 
102+       - run : yarn test 
103+       - name : Restore lockfile 
104+         run : git restore yarn.lock 
105+       - name : Require clean working directory 
139106        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!" 
107+         run : | 
108+           if ! git diff --exit-code; then 
109+             echo "Working tree dirty at end of job" 
110+             exit 1 
111+           fi 
0 commit comments