Skip to content

Commit 929c8e9

Browse files
committed
Update GitHub workflows
- Use `@MetaMask/engineering` as codeowners instead of outdated `@MetaMask/devs` group - Remove 'Examples' section from pull request template - Use the `checkout-and-setup` action to ensure that `actions/cache` is not used within publishing workflows - Add `compatibility-test` step to `build-lint-test` - Bump `action-create-release-pr` to v4 - Bump `action-publish-release` to v3 - Bump `action-npm-publish` to v5 - Bump `actions/checkout` to v4 - Call the security code scanner workflow from `main.yml` - Announce new releases in Slack
1 parent 0fad300 commit 929c8e9

File tree

10 files changed

+129
-106
lines changed

10 files changed

+129
-106
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Lines starting with '#' are comments.
22
# Each line is a file pattern followed by one or more owners.
33

4-
* @MetaMask/devs
4+
* @MetaMask/engineering

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Please see the documentation for all configuration options:
2-
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
2+
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
33

44
version: 2
55
updates:

.github/pull_request_template.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,3 @@ Are there any issues or other links reviewers should consult to understand this
99
* Fixes #12345
1010
* See: #67890
1111
-->
12-
13-
## Examples
14-
15-
<!--
16-
Are there any examples of this change being used in another repository?
17-
18-
When considering changes to the MetaMask module template, it's strongly preferred that the change be experimented with in another repository first. This gives reviewers a better sense of how the change works, making it less likely the change will need to be reverted or adjusted later.
19-
-->

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

Lines changed: 50 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,30 @@ jobs:
77
prepare:
88
name: Prepare
99
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
node-version: [18.x, 20.x, 22.x]
1013
steps:
11-
- uses: actions/checkout@v3
12-
- name: Use Node.js
13-
uses: actions/setup-node@v3
14+
- name: Checkout and setup environment
15+
uses: MetaMask/action-checkout-and-setup@v1
1416
with:
15-
node-version-file: '.nvmrc'
16-
cache: 'yarn'
17-
- name: Install Yarn dependencies
18-
run: yarn --immutable
17+
is-high-risk-environment: false
18+
node-version: ${{ matrix.node-version }}
19+
cache-node-modules: ${{ matrix.node-version == '22.x' }}
1920

2021
build:
2122
name: Build
23+
needs: prepare
2224
runs-on: ubuntu-latest
23-
needs:
24-
- prepare
2525
strategy:
2626
matrix:
27-
node-version: [18.x, 20.x, 22.x]
27+
node-version: [22.x]
2828
steps:
29-
- uses: actions/checkout@v3
30-
- name: Use Node.js ${{ matrix.node-version }}
31-
uses: actions/setup-node@v3
29+
- name: Checkout and setup environment
30+
uses: MetaMask/action-checkout-and-setup@v1
3231
with:
32+
is-high-risk-environment: false
3333
node-version: ${{ matrix.node-version }}
34-
cache: 'yarn'
35-
- run: yarn --immutable --immutable-cache
3634
- run: yarn build
3735
- name: Require clean working directory
3836
shell: bash
@@ -44,27 +42,24 @@ jobs:
4442
4543
lint:
4644
name: Lint
45+
needs: prepare
4746
runs-on: ubuntu-latest
48-
needs:
49-
- prepare
5047
strategy:
5148
matrix:
52-
node-version: [18.x, 20.x, 22.x]
49+
node-version: [22.x]
5350
steps:
54-
- uses: actions/checkout@v3
55-
- name: Use Node.js ${{ matrix.node-version }}
56-
uses: actions/setup-node@v3
51+
- name: Checkout and setup environment
52+
uses: MetaMask/action-checkout-and-setup@v1
5753
with:
54+
is-high-risk-environment: false
5855
node-version: ${{ matrix.node-version }}
59-
cache: 'yarn'
60-
- run: yarn --immutable --immutable-cache
6156
- run: yarn lint
6257
- name: Validate RC changelog
6358
if: ${{ startsWith(github.head_ref, 'release/') }}
64-
run: yarn auto-changelog validate --rc
59+
run: yarn lint:changelog --rc
6560
- name: Validate changelog
6661
if: ${{ !startsWith(github.head_ref, 'release/') }}
67-
run: yarn auto-changelog validate
62+
run: yarn lint:changelog
6863
- name: Require clean working directory
6964
shell: bash
7065
run: |
@@ -75,21 +70,44 @@ jobs:
7570
7671
test:
7772
name: Test
73+
needs: prepare
74+
runs-on: ubuntu-latest
75+
strategy:
76+
matrix:
77+
node-version: [18.x, 20.x, 22.x]
78+
steps:
79+
- name: Checkout and setup environment
80+
uses: MetaMask/action-checkout-and-setup@v1
81+
with:
82+
is-high-risk-environment: false
83+
node-version: ${{ matrix.node-version }}
84+
- run: yarn test
85+
- name: Require clean working directory
86+
shell: bash
87+
run: |
88+
if ! git diff --exit-code; then
89+
echo "Working tree dirty at end of job"
90+
exit 1
91+
fi
92+
93+
compatibility-test:
94+
name: Compatibility test
95+
needs: prepare
7896
runs-on: ubuntu-latest
79-
needs:
80-
- prepare
8197
strategy:
8298
matrix:
8399
node-version: [18.x, 20.x, 22.x]
84100
steps:
85-
- uses: actions/checkout@v3
86-
- name: Use Node.js ${{ matrix.node-version }}
87-
uses: actions/setup-node@v3
101+
- name: Checkout and setup environment
102+
uses: MetaMask/action-checkout-and-setup@v1
88103
with:
104+
is-high-risk-environment: false
89105
node-version: ${{ matrix.node-version }}
90-
cache: 'yarn'
91-
- run: yarn --immutable --immutable-cache
106+
- name: Install dependencies via Yarn
107+
run: rm yarn.lock && YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn
92108
- run: yarn test
109+
- name: Restore lockfile
110+
run: git restore yarn.lock
93111
- name: Require clean working directory
94112
shell: bash
95113
run: |

.github/workflows/create-release-pr.yml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,22 @@ jobs:
2121
contents: write
2222
pull-requests: write
2323
steps:
24-
- uses: actions/checkout@v3
24+
- name: Checkout and setup environment
25+
uses: MetaMask/action-checkout-and-setup@v1
2526
with:
26-
# This is to guarantee that the most recent tag is fetched.
27-
# This can be configured to a more reasonable value by consumers.
27+
is-high-risk-environment: true
28+
29+
# This is to guarantee that the most recent tag is fetched. This can
30+
# be configured to a more reasonable value by consumers.
2831
fetch-depth: 0
32+
2933
# We check out the specified branch, which will be used as the base
3034
# branch for all git operations and the release PR.
3135
ref: ${{ github.event.inputs.base-branch }}
32-
- name: Setup Node.js
33-
uses: actions/setup-node@v3
34-
with:
35-
node-version-file: '.nvmrc'
36-
- uses: MetaMask/action-create-release-pr@v1
37-
env:
38-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
37+
- uses: MetaMask/action-create-release-pr@v4
3938
with:
4039
release-type: ${{ github.event.inputs.release-type }}
4140
release-version: ${{ github.event.inputs.release-version }}
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/main.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ jobs:
1010
name: Check workflows
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v3
13+
- name: Checkout and setup environment
14+
uses: MetaMask/action-checkout-and-setup@v1
15+
with:
16+
is-high-risk-environment: false
1417
- name: Download actionlint
1518
id: download-actionlint
1619
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/7fdc9630cc360ea1a469eed64ac6d78caeda1234/scripts/download-actionlint.bash) 1.6.23
@@ -19,6 +22,18 @@ jobs:
1922
run: ${{ steps.download-actionlint.outputs.executable }} -color
2023
shell: bash
2124

25+
analyse-code:
26+
name: Code scanner
27+
needs: check-workflows
28+
uses: ./.github/workflows/security-code-scanner.yml
29+
permissions:
30+
actions: read
31+
contents: read
32+
security-events: write
33+
secrets:
34+
SECURITY_SCAN_METRICS_TOKEN: ${{ secrets.SECURITY_SCAN_METRICS_TOKEN }}
35+
APPSEC_BOT_SLACK_WEBHOOK: ${{ secrets.APPSEC_BOT_SLACK_WEBHOOK }}
36+
2237
build-lint-test:
2338
name: Build, lint, and test
2439
uses: ./.github/workflows/build-lint-test.yml
@@ -28,6 +43,7 @@ jobs:
2843
runs-on: ubuntu-latest
2944
needs:
3045
- check-workflows
46+
- analyse-code
3147
- build-lint-test
3248
outputs:
3349
PASSED: ${{ steps.set-output.outputs.PASSED }}
@@ -74,3 +90,4 @@ jobs:
7490
secrets:
7591
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
7692
PUBLISH_DOCS_TOKEN: ${{ secrets.PUBLISH_DOCS_TOKEN }}
93+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

.github/workflows/publish-docs.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,10 @@ jobs:
2121
- name: Ensure `destination_dir` is not empty
2222
if: ${{ inputs.destination_dir == '' }}
2323
run: exit 1
24-
- name: Checkout the repository
25-
uses: actions/checkout@v3
26-
- name: Use Node.js
27-
uses: actions/setup-node@v3
24+
- name: Checkout and setup environment
25+
uses: MetaMask/action-checkout-and-setup@v1
2826
with:
29-
node-version-file: '.nvmrc'
30-
cache: 'yarn'
31-
- name: Install npm dependencies
32-
run: yarn --immutable
27+
is-high-risk-environment: true
3328
- name: Run build script
3429
run: yarn build:docs
3530
- name: Deploy to `${{ inputs.destination_dir }}` directory of `gh-pages` branch

.github/workflows/publish-release.yml

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,74 +5,73 @@ on:
55
secrets:
66
NPM_TOKEN:
77
required: true
8+
SLACK_WEBHOOK_URL:
9+
required: true
810
PUBLISH_DOCS_TOKEN:
911
required: true
10-
1112
jobs:
1213
publish-release:
1314
permissions:
1415
contents: write
1516
runs-on: ubuntu-latest
1617
steps:
17-
- uses: actions/checkout@v3
18+
- name: Checkout and setup environment
19+
uses: MetaMask/action-checkout-and-setup@v1
1820
with:
21+
is-high-risk-environment: true
1922
ref: ${{ github.sha }}
20-
- name: Setup Node.js
21-
uses: actions/setup-node@v3
22-
with:
23-
node-version-file: '.nvmrc'
24-
- uses: MetaMask/action-publish-release@v2
23+
- uses: MetaMask/action-publish-release@v3
2524
env:
2625
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27-
- name: Install
28-
run: |
29-
yarn install
30-
yarn build
31-
- uses: actions/cache@v3
32-
id: restore-build
26+
- run: yarn build
27+
- name: Upload build artifacts
28+
uses: actions/upload-artifact@v4
3329
with:
30+
name: publish-release-artifacts-${{ github.sha }}
31+
retention-days: 4
32+
include-hidden-files: true
3433
path: |
3534
./dist
3635
./node_modules/.yarn-state.yml
37-
key: ${{ github.sha }}
3836
3937
publish-npm-dry-run:
40-
runs-on: ubuntu-latest
4138
needs: publish-release
39+
runs-on: ubuntu-latest
4240
steps:
43-
- uses: actions/checkout@v3
41+
- name: Checkout and setup environment
42+
uses: MetaMask/action-checkout-and-setup@v1
4443
with:
44+
is-high-risk-environment: true
4545
ref: ${{ github.sha }}
46-
- uses: actions/cache@v3
47-
id: restore-build
46+
- name: Restore build artifacts
47+
uses: actions/download-artifact@v4
4848
with:
49-
path: |
50-
./dist
51-
./node_modules/.yarn-state.yml
52-
key: ${{ github.sha }}
49+
name: publish-release-artifacts-${{ github.sha }}
5350
- name: Dry Run Publish
5451
# omit npm-token token to perform dry run publish
55-
uses: MetaMask/action-npm-publish@v2
52+
uses: MetaMask/action-npm-publish@v5
53+
with:
54+
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
55+
subteam: S042S7RE4AE # @metamask-npm-publishers
5656
env:
5757
SKIP_PREPACK: true
5858

5959
publish-npm:
60-
environment: npm-publish
61-
runs-on: ubuntu-latest
6260
needs: publish-npm-dry-run
61+
runs-on: ubuntu-latest
62+
environment: npm-publish
6363
steps:
64-
- uses: actions/checkout@v3
64+
- name: Checkout and setup environment
65+
uses: MetaMask/action-checkout-and-setup@v1
6566
with:
67+
is-high-risk-environment: true
6668
ref: ${{ github.sha }}
67-
- uses: actions/cache@v3
68-
id: restore-build
69+
- name: Restore build artifacts
70+
uses: actions/download-artifact@v4
6971
with:
70-
path: |
71-
./dist
72-
./node_modules/.yarn-state.yml
73-
key: ${{ github.sha }}
72+
name: publish-release-artifacts-${{ github.sha }}
7473
- name: Publish
75-
uses: MetaMask/action-npm-publish@v2
74+
uses: MetaMask/action-npm-publish@v5
7675
with:
7776
# This `NPM_TOKEN` needs to be manually set per-repository.
7877
# Look in the repository settings under "Environments", and set this token in the `npm-publish` environment.
@@ -81,21 +80,21 @@ jobs:
8180
SKIP_PREPACK: true
8281

8382
get-release-version:
84-
runs-on: ubuntu-latest
8583
needs: publish-npm
84+
runs-on: ubuntu-latest
8685
outputs:
8786
RELEASE_VERSION: ${{ steps.get-release-version.outputs.RELEASE_VERSION }}
8887
steps:
89-
- uses: actions/checkout@v3
88+
- uses: actions/checkout@v4
9089
with:
9190
ref: ${{ github.sha }}
9291
- id: get-release-version
9392
shell: bash
9493
run: ./scripts/get.sh ".version" "RELEASE_VERSION"
9594

9695
publish-release-to-gh-pages:
97-
needs: get-release-version
9896
name: Publish docs to `${{ needs.get-release-version.outputs.RELEASE_VERSION }}` directory of `gh-pages` branch
97+
needs: get-release-version
9998
permissions:
10099
contents: write
101100
uses: ./.github/workflows/publish-docs.yml
@@ -105,8 +104,8 @@ jobs:
105104
PUBLISH_DOCS_TOKEN: ${{ secrets.PUBLISH_DOCS_TOKEN }}
106105

107106
publish-release-to-latest-gh-pages:
108-
needs: publish-npm
109107
name: Publish docs to `latest` directory of `gh-pages` branch
108+
needs: publish-npm
110109
permissions:
111110
contents: write
112111
uses: ./.github/workflows/publish-docs.yml

0 commit comments

Comments
 (0)