Skip to content

Commit 46a3b8b

Browse files
authored
Sync GitHub workflows with module template (#365)
This commit ensures that the GitHub workflows (minus anything documentation-related) and other files in `.github` are synced with the module template. - Add pull request template - Add compatibility test - Use `checkout-and-setup` action, avoid the use of `actions/cache` for publishing - Bump to `action-create-release-pr` v4 - This may address a bug where if the changelog is updated fully before attempting to create an RC, the Create Pull Request workflow cannot be run. v1 is likely using an old version of `@metamask/auto-changelog`. - Bump to `action-publish-release` v3 - Bump to `action-npm-publish` v5 - Bump to `action-security-code-scanner` v1 - Notify Slack when new release is ready for approval - Remove unused `get-release-version` step
1 parent 2946ebe commit 46a3b8b

File tree

7 files changed

+131
-103
lines changed

7 files changed

+131
-103
lines changed

.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: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!--
2+
Thanks for your contribution! Take a moment to answer these questions so that reviewers have the information they need to properly understand your changes:
3+
4+
* What is the current state of things and why does it need to change?
5+
* What is the solution your changes offer and how does it work?
6+
7+
Are there any issues or other links reviewers should consult to understand this pull request better? For instance:
8+
9+
* Fixes #12345
10+
* See: #67890
11+
-->

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

Lines changed: 48 additions & 36 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,18 @@ 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
62-
- name: Validate RC changelog
63-
if: ${{ startsWith(github.head_ref, 'release/') }}
64-
run: yarn auto-changelog validate --rc
65-
- name: Validate changelog
66-
if: ${{ !startsWith(github.head_ref, 'release/') }}
67-
run: yarn auto-changelog validate
6857
- name: Require clean working directory
6958
shell: bash
7059
run: |
@@ -75,21 +64,44 @@ jobs:
7564
7665
test:
7766
name: Test
67+
needs: prepare
68+
runs-on: ubuntu-latest
69+
strategy:
70+
matrix:
71+
node-version: [18.x, 20.x, 22.x]
72+
steps:
73+
- name: Checkout and setup environment
74+
uses: MetaMask/action-checkout-and-setup@v1
75+
with:
76+
is-high-risk-environment: false
77+
node-version: ${{ matrix.node-version }}
78+
- run: yarn test
79+
- name: Require clean working directory
80+
shell: bash
81+
run: |
82+
if ! git diff --exit-code; then
83+
echo "Working tree dirty at end of job"
84+
exit 1
85+
fi
86+
87+
compatibility-test:
88+
name: Compatibility test
89+
needs: prepare
7890
runs-on: ubuntu-latest
79-
needs:
80-
- prepare
8191
strategy:
8292
matrix:
8393
node-version: [18.x, 20.x, 22.x]
8494
steps:
85-
- uses: actions/checkout@v3
86-
- name: Use Node.js ${{ matrix.node-version }}
87-
uses: actions/setup-node@v3
95+
- name: Checkout and setup environment
96+
uses: MetaMask/action-checkout-and-setup@v1
8897
with:
98+
is-high-risk-environment: false
8999
node-version: ${{ matrix.node-version }}
90-
cache: 'yarn'
91-
- run: yarn --immutable --immutable-cache
100+
- name: Install dependencies via Yarn
101+
run: rm yarn.lock && YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn
92102
- run: yarn test
103+
- name: Restore lockfile
104+
run: git restore yarn.lock
93105
- name: Require clean working directory
94106
shell: bash
95107
run: |

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

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
default: 'main'
99
required: true
1010
release-type:
11-
description: 'A SemVer version diff, i.e. major, minor, patch, prerelease etc. Mutually exclusive with "release-version".'
11+
description: 'A SemVer version diff, i.e. major, minor, or patch. Mutually exclusive with "release-version".'
1212
required: false
1313
release-version:
1414
description: 'A specific version to bump to. Mutually exclusive with "release-type".'
@@ -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: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,30 @@ 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
16-
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/7fdc9630cc360ea1a469eed64ac6d78caeda1234/scripts/download-actionlint.bash) 1.6.22
19+
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/7fdc9630cc360ea1a469eed64ac6d78caeda1234/scripts/download-actionlint.bash) 1.6.23
1720
shell: bash
1821
- name: Check workflow files
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 }}
@@ -73,3 +89,4 @@ jobs:
7389
uses: ./.github/workflows/publish-release.yml
7490
secrets:
7591
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
92+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

.github/workflows/publish-release.yml

Lines changed: 32 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -5,88 +5,74 @@ on:
55
secrets:
66
NPM_TOKEN:
77
required: true
8-
8+
SLACK_WEBHOOK_URL:
9+
required: true
910
jobs:
1011
publish-release:
1112
permissions:
1213
contents: write
1314
runs-on: ubuntu-latest
1415
steps:
15-
- uses: actions/checkout@v3
16+
- name: Checkout and setup environment
17+
uses: MetaMask/action-checkout-and-setup@v1
1618
with:
19+
is-high-risk-environment: true
1720
ref: ${{ github.sha }}
18-
- name: Setup Node.js
19-
uses: actions/setup-node@v3
20-
with:
21-
node-version-file: '.nvmrc'
22-
- uses: MetaMask/action-publish-release@v2
21+
- uses: MetaMask/action-publish-release@v3
2322
env:
2423
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25-
- name: Install
26-
run: |
27-
yarn install
28-
yarn build
29-
- uses: actions/cache@v3
30-
id: restore-build
24+
- run: yarn build
25+
- name: Upload build artifacts
26+
uses: actions/upload-artifact@v4
3127
with:
28+
name: publish-release-artifacts-${{ github.sha }}
29+
retention-days: 4
30+
include-hidden-files: true
3231
path: |
3332
./dist
3433
./node_modules/.yarn-state.yml
35-
key: ${{ github.sha }}
3634
3735
publish-npm-dry-run:
38-
runs-on: ubuntu-latest
3936
needs: publish-release
37+
runs-on: ubuntu-latest
4038
steps:
41-
- uses: actions/checkout@v3
39+
- name: Checkout and setup environment
40+
uses: MetaMask/action-checkout-and-setup@v1
4241
with:
42+
is-high-risk-environment: true
4343
ref: ${{ github.sha }}
44-
- uses: actions/cache@v3
45-
id: restore-build
44+
- name: Restore build artifacts
45+
uses: actions/download-artifact@v4
4646
with:
47-
path: |
48-
./dist
49-
./node_modules/.yarn-state.yml
50-
key: ${{ github.sha }}
47+
name: publish-release-artifacts-${{ github.sha }}
5148
- name: Dry Run Publish
5249
# omit npm-token token to perform dry run publish
53-
uses: MetaMask/action-npm-publish@v2
50+
uses: MetaMask/action-npm-publish@v5
51+
with:
52+
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
53+
subteam: S042S7RE4AE # @metamask-npm-publishers
5454
env:
5555
SKIP_PREPACK: true
5656

5757
publish-npm:
58-
environment: npm-publish
59-
runs-on: ubuntu-latest
6058
needs: publish-npm-dry-run
59+
runs-on: ubuntu-latest
60+
environment: npm-publish
6161
steps:
62-
- uses: actions/checkout@v3
62+
- name: Checkout and setup environment
63+
uses: MetaMask/action-checkout-and-setup@v1
6364
with:
65+
is-high-risk-environment: true
6466
ref: ${{ github.sha }}
65-
- uses: actions/cache@v3
66-
id: restore-build
67+
- name: Restore build artifacts
68+
uses: actions/download-artifact@v4
6769
with:
68-
path: |
69-
./dist
70-
./node_modules/.yarn-state.yml
71-
key: ${{ github.sha }}
70+
name: publish-release-artifacts-${{ github.sha }}
7271
- name: Publish
73-
uses: MetaMask/action-npm-publish@v2
72+
uses: MetaMask/action-npm-publish@v5
7473
with:
7574
# This `NPM_TOKEN` needs to be manually set per-repository.
7675
# Look in the repository settings under "Environments", and set this token in the `npm-publish` environment.
7776
npm-token: ${{ secrets.NPM_TOKEN }}
7877
env:
7978
SKIP_PREPACK: true
80-
81-
get-release-version:
82-
runs-on: ubuntu-latest
83-
needs: publish-npm
84-
outputs:
85-
RELEASE_VERSION: ${{ steps.get-release-version.outputs.RELEASE_VERSION }}
86-
steps:
87-
- uses: actions/checkout@v3
88-
with:
89-
ref: ${{ github.sha }}
90-
- id: get-release-version
91-
shell: bash
92-
run: ./scripts/get.sh ".version" "RELEASE_VERSION"

.github/workflows/security-code-scanner.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
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+
- name: Analyse code
2122
uses: MetaMask/action-security-code-scanner@v1
2223
with:
2324
repo: ${{ github.repository }}

0 commit comments

Comments
 (0)