Skip to content

Commit 8e2855c

Browse files
authored
Update workflows to use MetaMask/action-checkout-and-setup (#5474)
## Explanation <!-- Thanks for your contribution! Take a moment to answer these questions so that reviewers have the information they need to properly understand your changes: * What is the current state of things and why does it need to change? * What is the solution your changes offer and how does it work? * Are there any changes whose purpose might not obvious to those unfamiliar with the domain? * If your primary goal was to update one package but you found you had to update another one along the way, why did you do so? * If you had to upgrade a dependency, why did you do so? --> This updates all workflows to remove the use of `actions/checkout`, `actions/setup-node`, `actions/cache`. The implementation here is based on MetaMask/snaps#3214. ## References MetaMask-planning#3925. ## Changelog n/a, this doesn't make any changes to packages directly. ## Checklist - [ ] I've updated the test suite for new or updated code as appropriate - [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [ ] I've highlighted breaking changes using the "BREAKING" category above as appropriate - [ ] I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes
1 parent 210763d commit 8e2855c

File tree

6 files changed

+98
-156
lines changed

6 files changed

+98
-156
lines changed

.github/workflows/ensure-blocking-pr-labels-absent.yml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,10 @@ jobs:
1313
permissions:
1414
pull-requests: read
1515
steps:
16-
- uses: actions/checkout@v4
17-
- name: Use Node.js
18-
uses: actions/setup-node@v4
16+
- name: Checkout and setup environment
17+
uses: MetaMask/action-checkout-and-setup@v1
1918
with:
20-
node-version-file: '.nvmrc'
21-
- name: Install Yarn
22-
run: corepack enable
23-
- name: Restore Yarn cache
24-
uses: actions/setup-node@v4
25-
with:
26-
node-version-file: '.nvmrc'
27-
cache: 'yarn'
28-
- run: yarn --immutable
19+
is-high-risk-environment: false
2920
- name: Run command
3021
uses: actions/github-script@v7
3122
with:

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

Lines changed: 21 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,15 @@ jobs:
99
runs-on: ubuntu-latest
1010
strategy:
1111
matrix:
12-
node-version: [18.x, 20.x]
12+
node-version: [18.x, 20.x, 22.x]
1313
outputs:
1414
child-workspace-package-names: ${{ steps.workspace-package-names.outputs.child-workspace-package-names }}
1515
steps:
16-
- uses: actions/checkout@v4
17-
- name: Install Node.js ${{ matrix.node-version }}
18-
uses: actions/setup-node@v4
16+
- name: Checkout and setup environment
17+
uses: MetaMask/action-checkout-and-setup@v1
1918
with:
20-
node-version: ${{ matrix.node-version }}
21-
- name: Install Yarn
22-
run: corepack enable
23-
- name: Restore Yarn cache
24-
uses: actions/setup-node@v4
25-
with:
26-
node-version: ${{ matrix.node-version }}
27-
cache: yarn
28-
- run: yarn --immutable
19+
is-high-risk-environment: false
20+
cache-node-modules: ${{ matrix.node-version == '22.x' }}
2921
- name: Fetch workspace package names
3022
id: workspace-package-names
3123
run: |
@@ -38,21 +30,12 @@ jobs:
3830
needs: prepare
3931
strategy:
4032
matrix:
41-
node-version: [20.x]
33+
node-version: [22.x]
4234
steps:
43-
- uses: actions/checkout@v4
44-
- name: Install Node.js ${{ matrix.node-version }}
45-
uses: actions/setup-node@v4
46-
with:
47-
node-version: ${{ matrix.node-version }}
48-
- name: Install Yarn
49-
run: corepack enable
50-
- name: Restore Yarn cache
51-
uses: actions/setup-node@v4
35+
- name: Checkout and setup environment
36+
uses: MetaMask/action-checkout-and-setup@v1
5237
with:
53-
node-version: ${{ matrix.node-version }}
54-
cache: yarn
55-
- run: yarn --immutable
38+
is-high-risk-environment: false
5639
- run: yarn lint
5740
- name: Require clean working directory
5841
shell: bash
@@ -68,22 +51,13 @@ jobs:
6851
needs: prepare
6952
strategy:
7053
matrix:
71-
node-version: [20.x]
54+
node-version: [22.x]
7255
package-name: ${{ fromJson(needs.prepare.outputs.child-workspace-package-names) }}
7356
steps:
74-
- uses: actions/checkout@v4
75-
- name: Install Node.js ${{ matrix.node-version }}
76-
uses: actions/setup-node@v4
77-
with:
78-
node-version: ${{ matrix.node-version }}
79-
- name: Install Yarn
80-
run: corepack enable
81-
- name: Restore Yarn cache
82-
uses: actions/setup-node@v4
57+
- name: Checkout and setup environment
58+
uses: MetaMask/action-checkout-and-setup@v1
8359
with:
84-
node-version: ${{ matrix.node-version }}
85-
cache: yarn
86-
- run: yarn --immutable
60+
is-high-risk-environment: false
8761
- run: yarn workspace ${{ matrix.package-name }} changelog:validate
8862
- name: Require clean working directory
8963
shell: bash
@@ -99,21 +73,12 @@ jobs:
9973
needs: prepare
10074
strategy:
10175
matrix:
102-
node-version: [20.x]
76+
node-version: [22.x]
10377
steps:
104-
- uses: actions/checkout@v4
105-
- name: Install Node.js ${{ matrix.node-version }}
106-
uses: actions/setup-node@v4
78+
- name: Checkout and setup environment
79+
uses: MetaMask/action-checkout-and-setup@v1
10780
with:
108-
node-version: ${{ matrix.node-version }}
109-
- name: Install Yarn
110-
run: corepack enable
111-
- name: Restore Yarn cache
112-
uses: actions/setup-node@v4
113-
with:
114-
node-version: ${{ matrix.node-version }}
115-
cache: yarn
116-
- run: yarn --immutable
81+
is-high-risk-environment: false
11782
- run: yarn build
11883
- name: Require clean working directory
11984
shell: bash
@@ -129,22 +94,13 @@ jobs:
12994
needs: prepare
13095
strategy:
13196
matrix:
132-
node-version: [18.x, 20.x]
97+
node-version: [18.x, 20.x, 22.x]
13398
package-name: ${{ fromJson(needs.prepare.outputs.child-workspace-package-names) }}
13499
steps:
135-
- uses: actions/checkout@v4
136-
- name: Install Node.js ${{ matrix.node-version }}
137-
uses: actions/setup-node@v4
138-
with:
139-
node-version: ${{ matrix.node-version }}
140-
- name: Install Yarn
141-
run: corepack enable
142-
- name: Restore Yarn cache
143-
uses: actions/setup-node@v4
100+
- name: Checkout and setup environment
101+
uses: MetaMask/action-checkout-and-setup@v1
144102
with:
145-
node-version: ${{ matrix.node-version }}
146-
cache: yarn
147-
- run: yarn --immutable
103+
is-high-risk-environment: false
148104
- run: yarn test:scripts
149105
- run: yarn workspace ${{ matrix.package-name }} run test
150106
- name: Require clean working directory

.github/workflows/main.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
name: Check workflows
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v3
13+
- uses: actions/checkout@v4
1414
- name: Download actionlint
1515
id: download-actionlint
1616
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/7fdc9630cc360ea1a469eed64ac6d78caeda1234/scripts/download-actionlint.bash) 1.6.25
@@ -19,6 +19,18 @@ jobs:
1919
run: ${{ steps.download-actionlint.outputs.executable }} -color
2020
shell: bash
2121

22+
analyse-code:
23+
name: Code scanner
24+
needs: check-workflows
25+
uses: ./.github/workflows/security-code-scanner.yml
26+
permissions:
27+
actions: read
28+
contents: read
29+
security-events: write
30+
secrets:
31+
SECURITY_SCAN_METRICS_TOKEN: ${{ secrets.SECURITY_SCAN_METRICS_TOKEN }}
32+
APPSEC_BOT_SLACK_WEBHOOK: ${{ secrets.APPSEC_BOT_SLACK_WEBHOOK }}
33+
2234
lint-build-test:
2335
name: Lint, build, and test
2436
needs: check-workflows
@@ -59,7 +71,9 @@ jobs:
5971
all-jobs-complete:
6072
name: All jobs complete
6173
runs-on: ubuntu-latest
62-
needs: lint-build-test
74+
needs:
75+
- analyse-code
76+
- lint-build-test
6377
outputs:
6478
passed: ${{ steps.set-output.outputs.passed }}
6579
steps:

.github/workflows/publish-preview.yml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,10 @@ jobs:
3535
env:
3636
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3737
PR_NUMBER: ${{ github.event.issue.number }}
38-
- name: Install 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-
- name: Install Yarn
43-
run: corepack enable
44-
- name: Restore Yarn cache
45-
uses: actions/setup-node@v4
46-
with:
47-
node-version-file: '.nvmrc'
48-
cache: yarn
49-
- run: yarn --immutable
41+
is-high-risk-environment: true
5042
- name: Get commit SHA
5143
id: commit-sha
5244
run: echo "COMMIT_SHA=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"

.github/workflows/publish-release.yml

Lines changed: 28 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -14,85 +14,60 @@ jobs:
1414
contents: write
1515
runs-on: ubuntu-latest
1616
steps:
17-
- uses: actions/checkout@v4
17+
- name: Checkout and setup environment
18+
uses: MetaMask/action-checkout-and-setup@v1
1819
with:
19-
ref: ${{ github.sha }}
20-
- name: Install Node
21-
uses: actions/setup-node@v4
22-
with:
23-
node-version-file: '.nvmrc'
24-
- name: Install Yarn
25-
run: corepack enable
26-
- name: Restore Yarn cache
27-
uses: actions/setup-node@v4
28-
with:
29-
node-version-file: '.nvmrc'
30-
cache: yarn
31-
- uses: actions/cache@v4
32-
with:
33-
path: |
34-
./packages/**/dist
35-
./node_modules/.yarn-state.yml
36-
key: ${{ github.sha }}
20+
is-high-risk-environment: true
3721
- uses: MetaMask/action-publish-release@v3
3822
env:
3923
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40-
- run: yarn --immutable
4124
- run: yarn build
25+
- name: Upload build artifacts
26+
uses: actions/upload-artifact@v4
27+
with:
28+
name: publish-release-artifacts-${{ github.sha }}
29+
include-hidden-files: true
30+
retention-days: 4
31+
path: |
32+
./packages/**/dist
33+
./node_modules/.yarn-state.yml
4234
4335
publish-npm-dry-run:
36+
name: Dry run publish to NPM
4437
runs-on: ubuntu-latest
4538
needs: publish-release
4639
steps:
47-
- uses: actions/checkout@v4
40+
- name: Checkout and setup environment
41+
uses: MetaMask/action-checkout-and-setup@v1
4842
with:
43+
is-high-risk-environment: true
4944
ref: ${{ github.sha }}
50-
- name: Install Node
51-
uses: actions/setup-node@v4
45+
- name: Restore build artifacts
46+
uses: actions/download-artifact@v4
5247
with:
53-
node-version-file: '.nvmrc'
54-
- name: Install Yarn
55-
run: corepack enable
56-
- uses: actions/cache@v4
57-
with:
58-
path: |
59-
./packages/**/dist
60-
./node_modules/.yarn-state.yml
61-
key: ${{ github.sha }}
62-
fail-on-cache-miss: true
63-
- name: Dry Run Publish
64-
# omit npm-token token to perform dry run publish
48+
name: publish-release-artifacts-${{ github.sha }}
49+
- name: Dry run publish to NPM
6550
uses: MetaMask/action-npm-publish@v5
6651
with:
6752
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
6853
subteam: S042S7RE4AE # @metamask-npm-publishers
69-
env:
70-
SKIP_PREPACK: true
7154

7255
publish-npm:
56+
name: Publish to NPM
7357
environment: npm-publish
7458
runs-on: ubuntu-latest
7559
needs: publish-npm-dry-run
7660
steps:
77-
- uses: actions/checkout@v4
61+
- name: Checkout and setup environment
62+
uses: MetaMask/action-checkout-and-setup@v1
7863
with:
64+
is-high-risk-environment: true
7965
ref: ${{ github.sha }}
80-
- name: Install Node
81-
uses: actions/setup-node@v4
66+
- name: Restore build artifacts
67+
uses: actions/download-artifact@v4
8268
with:
83-
node-version-file: '.nvmrc'
84-
- name: Install Yarn
85-
run: corepack enable
86-
- uses: actions/cache@v4
87-
with:
88-
path: |
89-
./packages/**/dist
90-
./node_modules/.yarn-state.yml
91-
key: ${{ github.sha }}
92-
fail-on-cache-miss: true
93-
- name: Publish
69+
name: publish-release-artifacts-${{ github.sha }}
70+
- name: Publish to NPM
9471
uses: MetaMask/action-npm-publish@v5
9572
with:
9673
npm-token: ${{ secrets.NPM_TOKEN }}
97-
env:
98-
SKIP_PREPACK: true
Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,47 @@
11
name: MetaMask Security Code Scanner
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
pull_request:
8-
branches:
9-
- main
4+
workflow_call:
5+
secrets:
6+
SECURITY_SCAN_METRICS_TOKEN:
7+
required: false
8+
APPSEC_BOT_SLACK_WEBHOOK:
9+
required: false
1010
workflow_dispatch:
1111

1212
jobs:
1313
run-security-scan:
14+
name: Run security scan
1415
runs-on: ubuntu-latest
1516
permissions:
1617
actions: read
1718
contents: read
1819
security-events: write
1920
steps:
20-
- name: MetaMask Security Code Scanner
21-
uses: MetaMask/Security-Code-Scanner@main
21+
- name: Analyse code
22+
uses: MetaMask/action-security-code-scanner@v1
2223
with:
2324
repo: ${{ github.repository }}
2425
paths_ignored: |
26+
.storybook/
27+
'**/__snapshots__/'
28+
'**/*.snap'
29+
'**/*.stories.js'
30+
'**/*.stories.tsx'
31+
'**/*.test.browser.ts*'
32+
'**/*.test.js*'
33+
'**/*.test.ts*'
34+
'**/fixtures/'
35+
'**/jest.config.js'
36+
'**/jest.environment.js'
37+
'**/mocks/'
2538
'**/test*/'
2639
docs/
27-
'**/*.test.js'
28-
'**/*.test.ts'
29-
node_modules
40+
e2e/
3041
merged-packages/
31-
'**/jest.environment.js'
32-
project_metrics_token: ${{secrets.SECURITY_SCAN_METRICS_TOKEN}}
42+
node_modules
43+
storybook/
44+
test*/
45+
rules_excluded: example
46+
project_metrics_token: ${{ secrets.SECURITY_SCAN_METRICS_TOKEN }}
3347
slack_webhook: ${{ secrets.APPSEC_BOT_SLACK_WEBHOOK }}

0 commit comments

Comments
 (0)