Skip to content

Commit 8d318a5

Browse files
authored
Update workflows to use MetaMask/action-checkout-and-setup (#3214)
This updates all workflows to use `MetaMask/action-checkout-and-setup` and remove the use of `actions/cache`.
1 parent 61853b0 commit 8d318a5

File tree

8 files changed

+164
-227
lines changed

8 files changed

+164
-227
lines changed

.github/workflows/build-lint-test.yml

Lines changed: 56 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,25 @@ jobs:
1717
strategy:
1818
fail-fast: false
1919
matrix:
20-
node-version: [18.x, 20.x]
20+
node-version: [18.x, 20.x, 22.x]
2121
steps:
22-
- uses: actions/checkout@v4
23-
- name: Use Node.js ${{ matrix.node-version }}
24-
uses: actions/setup-node@v4
22+
- name: Checkout and setup environment
23+
uses: MetaMask/action-checkout-and-setup@v1
2524
with:
25+
is-high-risk-environment: false
2626
node-version: ${{ matrix.node-version }}
27-
cache: yarn
28-
- run: yarn --immutable
29-
- name: Cache "@metamask/snaps-execution-environments" build
27+
cache-node-modules: ${{ matrix.node-version == '20.x' }}
28+
- name: Prepare "@metamask/snaps-execution-environments" build
29+
run: yarn workspace @metamask/snaps-execution-environments run build:lavamoat
30+
- name: Save "@metamask/snaps-execution-environments" build
3031
id: cache-snaps-execution-environments-build
31-
uses: actions/cache@v4
32+
uses: actions/upload-artifact@v4
3233
with:
34+
name: snaps-execution-environments-build-${{ runner.os }}-${{ matrix.node-version }}-${{ github.sha }}
35+
retention-days: 1
3336
path: |
37+
.nvmrc
3438
packages/snaps-execution-environments/dist/browserify
35-
key: snaps-execution-environments-build-${{ runner.os }}-${{ matrix.node-version }}-${{ github.sha }}
36-
- name: Prepare "@metamask/snaps-execution-environments" build
37-
if: steps.cache-snaps-execution-environments-build.outputs.cache-hit != 'true'
38-
run: yarn workspace @metamask/snaps-execution-environments run build:lavamoat
3939
- name: Fetch workspace package names
4040
id: workspace-package-names
4141
run: |
@@ -51,21 +51,20 @@ jobs:
5151
runs-on: ubuntu-latest
5252
needs: prepare
5353
steps:
54-
- uses: actions/checkout@v4
55-
- name: Setup Node
56-
uses: actions/setup-node@v4
54+
- name: Checkout and setup environment
55+
uses: MetaMask/action-checkout-and-setup@v1
5756
with:
58-
node-version-file: '.nvmrc'
59-
cache: yarn
60-
- run: yarn --immutable --immutable-cache
57+
is-high-risk-environment: false
6158
- name: Build
6259
run: yarn build:ci
63-
- name: Cache build files
64-
uses: actions/cache@v4
60+
- name: Save build files
61+
uses: actions/upload-artifact@v4
6562
with:
63+
name: build-source-${{ runner.os }}-${{ github.sha }}
64+
retention-days: 1
6665
path: |
66+
.nvmrc
6767
packages/*/dist
68-
key: build-source-${{ runner.os }}-${{ github.sha }}
6968
- name: Require clean working directory
7069
shell: bash
7170
run: |
@@ -79,20 +78,14 @@ jobs:
7978
runs-on: ubuntu-latest
8079
needs: prepare
8180
steps:
82-
- uses: actions/checkout@v4
83-
- name: Setup Node
84-
uses: actions/setup-node@v4
81+
- name: Checkout and setup environment
82+
uses: MetaMask/action-checkout-and-setup@v1
8583
with:
86-
node-version-file: '.nvmrc'
87-
cache: yarn
88-
- run: yarn --immutable --immutable-cache
84+
is-high-risk-environment: false
8985
- name: Restore "@metamask/snaps-execution-environments" build
90-
uses: actions/cache@v4
86+
uses: actions/download-artifact@v4
9187
with:
92-
path: |
93-
packages/snaps-execution-environments/dist/browserify
94-
key: snaps-execution-environments-build-${{ runner.os }}-18.x-${{ github.sha }}
95-
fail-on-cache-miss: true
88+
name: snaps-execution-environments-build-${{ runner.os }}-22.x-${{ github.sha }}
9689
- name: Cache Webpack vendor
9790
id: cache-webpack-vendor
9891
uses: actions/cache@v4
@@ -105,13 +98,6 @@ jobs:
10598
run: yarn workspace @metamask/snaps-simulator run build:vendor
10699
- name: Build
107100
run: yarn workspace @metamask/snaps-simulator run build:webpack
108-
- name: Cache "@metamask/snaps-simulator" build
109-
id: cache-e2e-simulator-build
110-
uses: actions/cache@v4
111-
with:
112-
path: |
113-
packages/snaps-simulator/dist/webpack
114-
key: e2e-simulator-build-${{ runner.os }}-${{ github.sha }}
115101
- name: Require clean working directory
116102
shell: bash
117103
run: |
@@ -125,13 +111,10 @@ jobs:
125111
runs-on: ubuntu-latest
126112
needs: prepare
127113
steps:
128-
- uses: actions/checkout@v4
129-
- name: Setup Node
130-
uses: actions/setup-node@v4
114+
- name: Checkout and setup environment
115+
uses: MetaMask/action-checkout-and-setup@v1
131116
with:
132-
node-version-file: '.nvmrc'
133-
cache: yarn
134-
- run: yarn --immutable --immutable-cache
117+
is-high-risk-environment: false
135118
- name: Build
136119
run: yarn workspace @metamask/test-snaps run build
137120
- name: Require clean working directory
@@ -147,13 +130,10 @@ jobs:
147130
runs-on: ubuntu-latest
148131
needs: prepare
149132
steps:
150-
- uses: actions/checkout@v4
151-
- name: Setup Node
152-
uses: actions/setup-node@v4
133+
- name: Checkout and setup environment
134+
uses: MetaMask/action-checkout-and-setup@v1
153135
with:
154-
node-version-file: '.nvmrc'
155-
cache: yarn
156-
- run: yarn --immutable --immutable-cache
136+
is-high-risk-environment: false
157137
- name: Generate LavaMoat policy
158138
run: yarn workspace @metamask/snaps-execution-environments build:lavamoat:policy
159139
- name: Require clean working directory
@@ -169,13 +149,10 @@ jobs:
169149
runs-on: ubuntu-latest
170150
needs: prepare
171151
steps:
172-
- uses: actions/checkout@v4
173-
- name: Setup Node
174-
uses: actions/setup-node@v4
152+
- name: Checkout and setup environment
153+
uses: MetaMask/action-checkout-and-setup@v1
175154
with:
176-
node-version-file: '.nvmrc'
177-
cache: yarn
178-
- run: yarn --immutable --immutable-cache
155+
is-high-risk-environment: false
179156
- name: Lint
180157
run: yarn lint
181158
- name: Require clean working directory
@@ -195,47 +172,39 @@ jobs:
195172
strategy:
196173
fail-fast: false
197174
matrix:
198-
node-version: [18.x, 20.x]
175+
node-version: [18.x, 20.x, 22.x]
199176
package-name: ${{ fromJson(needs.prepare.outputs.test-workspace-package-names) }}
200177
steps:
201-
- uses: actions/checkout@v4
202-
- name: Use Node.js ${{ matrix.node-version }}
203-
uses: actions/setup-node@v4
178+
- name: Checkout and setup environment
179+
uses: MetaMask/action-checkout-and-setup@v1
204180
with:
181+
is-high-risk-environment: false
205182
node-version: ${{ matrix.node-version }}
206-
cache: yarn
207183
- name: Restore "@metamask/snaps-execution-environments" build
208-
uses: actions/cache@v4
184+
uses: actions/download-artifact@v4
209185
with:
210-
path: |
211-
packages/snaps-execution-environments/dist/browserify
212-
key: snaps-execution-environments-build-${{ runner.os }}-${{ matrix.node-version }}-${{ github.sha }}
213-
fail-on-cache-miss: true
186+
name: snaps-execution-environments-build-${{ runner.os }}-${{ matrix.node-version }}-${{ github.sha }}
214187
- name: Restore build files
215-
uses: actions/cache@v4
188+
uses: actions/download-artifact@v4
216189
with:
217-
path: |
218-
packages/*/dist
219-
key: build-source-${{ runner.os }}-${{ github.sha }}
220-
fail-on-cache-miss: true
221-
- run: yarn --immutable --immutable-cache
190+
name: build-source-${{ runner.os }}-${{ github.sha }}
222191
- name: Install Google Chrome
192+
if: ${{ matrix.package-name == '@metamask/snaps-controllers' || matrix.package-name == '@metamask/snaps-execution-environments' || matrix.package-name == '@metamask/snaps-utils' }}
223193
run: yarn install-chrome
224194
- run: yarn workspace ${{ matrix.package-name }} run test
225195
- name: Get coverage folder
226196
id: get-coverage-folder
227197
run: |
228-
echo "stub" >> stub
229198
echo "coverage-folder=$(yarn workspaces list --json | grep ${{ matrix.package-name }} | jq -r '.location')/coverage" >> "$GITHUB_OUTPUT"
230199
echo "artifact-name=$(echo ${{ matrix.package-name }} | sed 's:.*/::')" >> "$GITHUB_OUTPUT"
231200
shell: bash
232201
- name: Upload coverage artifact
233-
if: ${{ matrix.node-version == '18.x' }}
202+
if: ${{ matrix.node-version == '22.x' }}
234203
uses: actions/upload-artifact@v4
235204
with:
236205
name: coverage-${{ steps.get-coverage-folder.outputs.artifact-name }}
237206
path: |
238-
stub
207+
.nvmrc
239208
${{ steps.get-coverage-folder.outputs.coverage-folder }}/**/coverage-final.json
240209
if-no-files-found: warn
241210
retention-days: 1
@@ -273,30 +242,22 @@ jobs:
273242
strategy:
274243
fail-fast: false
275244
matrix:
276-
node-version: [18.x, 20.x]
245+
node-version: [18.x, 20.x, 22.x]
277246
package-name: ${{ fromJson(needs.prepare.outputs.e2e-workspace-package-names) }}
278247
steps:
279-
- uses: actions/checkout@v4
280-
- name: Use Node.js ${{ matrix.node-version }}
281-
uses: actions/setup-node@v4
248+
- name: Checkout and setup environment
249+
uses: MetaMask/action-checkout-and-setup@v1
282250
with:
251+
is-high-risk-environment: false
283252
node-version: ${{ matrix.node-version }}
284-
cache: yarn
285253
- name: Restore "@metamask/snaps-execution-environments" build
286-
uses: actions/cache@v4
254+
uses: actions/download-artifact@v4
287255
with:
288-
path: |
289-
packages/snaps-execution-environments/dist/browserify
290-
key: snaps-execution-environments-build-${{ runner.os }}-${{ matrix.node-version }}-${{ github.sha }}
291-
fail-on-cache-miss: true
256+
name: snaps-execution-environments-build-${{ runner.os }}-${{ matrix.node-version }}-${{ github.sha }}
292257
- name: Restore build files
293-
uses: actions/cache@v4
258+
uses: actions/download-artifact@v4
294259
with:
295-
path: |
296-
packages/*/dist
297-
key: build-source-${{ runner.os }}-${{ github.sha }}
298-
fail-on-cache-miss: true
299-
- run: yarn --immutable --immutable-cache
260+
name: build-source-${{ runner.os }}-${{ github.sha }}
300261
- name: Build snap
301262
run: yarn workspace ${{ matrix.package-name }} run build
302263
- name: Run E2E test
@@ -317,12 +278,9 @@ jobs:
317278
matrix:
318279
os: [macOS-latest, windows-latest]
319280
steps:
320-
- uses: actions/checkout@v4
321-
- name: Use Node.js
322-
uses: actions/setup-node@v4
281+
- name: Checkout and setup environment
282+
uses: MetaMask/action-checkout-and-setup@v1
323283
with:
324-
node-version-file: '.nvmrc'
325-
cache: yarn
326-
- run: yarn --immutable
284+
is-high-risk-environment: false
327285
- run: yarn build:ci
328286
- run: yarn workspace @metamask/snaps-cli run test

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- uses: actions/checkout@v4
1616
- name: Download actionlint
1717
id: download-actionlint
18-
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/7fdc9630cc360ea1a469eed64ac6d78caeda1234/scripts/download-actionlint.bash) 1.6.25
18+
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/7fdc9630cc360ea1a469eed64ac6d78caeda1234/scripts/download-actionlint.bash) 1.7.7
1919
shell: bash
2020
- name: Check workflow files
2121
run: ${{ steps.download-actionlint.outputs.executable }} -color

.github/workflows/publish-environment.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@ jobs:
1919
- name: Ensure `destination_dir` is not empty
2020
if: ${{ inputs.destination_dir == '' }}
2121
run: exit 1
22-
- uses: actions/checkout@v4
23-
- name: Setup Node
24-
uses: actions/setup-node@v4
22+
- name: Checkout and setup environment
23+
uses: MetaMask/action-checkout-and-setup@v1
2524
with:
26-
node-version-file: '.nvmrc'
27-
- run: yarn --immutable
25+
is-high-risk-environment: true
2826
- run: yarn build:lavamoat
2927
- name: configure AWS credentials
3028
uses: aws-actions/configure-aws-credentials@e1e17a757e536f70e52b5a12b2e8d1d1c60e04ef

.github/workflows/publish-github-pages.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,10 @@ jobs:
3333
- name: Ensure `publish_dir` is not empty
3434
if: ${{ inputs.publish_dir == '' }}
3535
run: exit 1
36-
- uses: actions/checkout@v4
37-
- name: Setup Node
38-
uses: actions/setup-node@v4
36+
- name: Checkout and setup environment
37+
uses: MetaMask/action-checkout-and-setup@v1
3938
with:
40-
node-version-file: '.nvmrc'
41-
- run: yarn --immutable
39+
is-high-risk-environment: true
4240
- name: Run build script
4341
run: ${{ inputs.build_script }}
4442
- name: Deploy to `${{ inputs.destination_dir }}` directory of `gh-pages` branch

.github/workflows/publish-preview.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,10 @@ jobs:
3535
env:
3636
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3737
PR_NUMBER: ${{ github.event.issue.number }}
38-
- name: Setup Node
39-
uses: actions/setup-node@v4
38+
- name: Checkout and setup environment
39+
uses: MetaMask/action-checkout-and-setup@v1
4040
with:
41-
node-version-file: '.nvmrc'
42-
cache: yarn
43-
- run: yarn --immutable
41+
is-high-risk-environment: true
4442
- name: Get commit SHA
4543
id: commit-sha
4644
run: echo "COMMIT_SHA=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"

0 commit comments

Comments
 (0)