Skip to content

Commit 90024f9

Browse files
authored
Standardise workflows per the module template as of April 2023 (#82)
* Standardise workflows per the module template as of April 2023 * Enable Dependabot to update '@metamask/*' npm packages daily This commit adds a Dependabot configuration file to the repository to enable daily checks for new versions of '@metamask/*' npm packages, updating them if needed, and opening a maximum of 10 pull requests with these updates. The configuration file uses the 'increase-if-necessary' versioning strategy to ensure that only necessary version bumps are considered for update. * Update build matrix in GitHub Actions Remove Node.js 14.x from the build matrix since it's no longer supported. The build matrix now includes only Node.js 16.x, 18.x, and 19.x.
1 parent e6a9162 commit 90024f9

File tree

10 files changed

+234
-238
lines changed

10 files changed

+234
-238
lines changed

.github/dependabot.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Please see the documentation for all configuration options:
2+
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
3+
4+
version: 2
5+
updates:
6+
- package-ecosystem: 'npm'
7+
directory: '/'
8+
schedule:
9+
interval: 'daily'
10+
time: '06:00'
11+
allow:
12+
- dependency-name: '@metamask/*'
13+
target-branch: 'main'
14+
versioning-strategy: 'increase-if-necessary'
15+
open-pull-requests-limit: 10
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: Build, Lint, and Test
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
prepare:
8+
name: Prepare
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
- name: Use Node.js
13+
uses: actions/setup-node@v3
14+
with:
15+
node-version-file: '.nvmrc'
16+
cache: 'yarn'
17+
- name: Install Yarn dependencies
18+
run: yarn --immutable
19+
20+
build:
21+
name: Build
22+
runs-on: ubuntu-latest
23+
needs:
24+
- prepare
25+
strategy:
26+
matrix:
27+
node-version: [16.x, 18.x, 19.x]
28+
steps:
29+
- uses: actions/checkout@v3
30+
- name: Use Node.js ${{ matrix.node-version }}
31+
uses: actions/setup-node@v3
32+
with:
33+
node-version: ${{ matrix.node-version }}
34+
cache: 'yarn'
35+
- run: yarn --immutable --immutable-cache
36+
- run: yarn build
37+
- name: Require clean working directory
38+
shell: bash
39+
run: |
40+
if ! git diff --exit-code; then
41+
echo "Working tree dirty at end of job"
42+
exit 1
43+
fi
44+
45+
lint:
46+
name: Lint
47+
runs-on: ubuntu-latest
48+
needs:
49+
- prepare
50+
strategy:
51+
matrix:
52+
node-version: [16.x, 18.x, 19.x]
53+
steps:
54+
- uses: actions/checkout@v3
55+
- name: Use Node.js ${{ matrix.node-version }}
56+
uses: actions/setup-node@v3
57+
with:
58+
node-version: ${{ matrix.node-version }}
59+
cache: 'yarn'
60+
- run: yarn --immutable --immutable-cache
61+
- 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
68+
- name: Require clean working directory
69+
shell: bash
70+
run: |
71+
if ! git diff --exit-code; then
72+
echo "Working tree dirty at end of job"
73+
exit 1
74+
fi
75+
76+
test:
77+
name: Test
78+
runs-on: ubuntu-latest
79+
needs:
80+
- prepare
81+
strategy:
82+
matrix:
83+
node-version: [16.x, 18.x, 19.x]
84+
steps:
85+
- uses: actions/checkout@v3
86+
- name: Use Node.js ${{ matrix.node-version }}
87+
uses: actions/setup-node@v3
88+
with:
89+
node-version: ${{ matrix.node-version }}
90+
cache: 'yarn'
91+
- run: yarn --immutable --immutable-cache
92+
- run: yarn test
93+
- name: Require clean working directory
94+
shell: bash
95+
run: |
96+
if ! git diff --exit-code; then
97+
echo "Working tree dirty at end of job"
98+
exit 1
99+
fi

.github/workflows/build-test.yml

Lines changed: 0 additions & 148 deletions
This file was deleted.

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

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,13 @@ jobs:
2929
# We check out the specified branch, which will be used as the base
3030
# branch for all git operations and the release PR.
3131
ref: ${{ github.event.inputs.base-branch }}
32-
- name: Get Node.js version
33-
id: nvm
34-
run: echo "NODE_VERSION=$(cat .nvmrc)" >> "$GITHUB_OUTPUT"
35-
- uses: actions/setup-node@v3
32+
- name: Setup Node.js
33+
uses: actions/setup-node@v3
3634
with:
37-
node-version: ${{ steps.nvm.outputs.NODE_VERSION }}
35+
node-version-file: '.nvmrc'
3836
- uses: MetaMask/action-create-release-pr@v1
3937
env:
4038
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4139
with:
4240
release-type: ${{ github.event.inputs.release-type }}
4341
release-version: ${{ github.event.inputs.release-version }}
44-
artifacts-path: gh-action__release-authors
45-
# Upload the release author artifact for use in subsequent workflows
46-
- uses: actions/upload-artifact@v3
47-
with:
48-
name: release-authors
49-
path: gh-action__release-authors
50-
if-no-files-found: error

.github/workflows/main.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Main
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
jobs:
9+
check-workflows:
10+
name: Check workflows
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
- name: Download actionlint
15+
id: download-actionlint
16+
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/7fdc9630cc360ea1a469eed64ac6d78caeda1234/scripts/download-actionlint.bash) 1.6.23
17+
shell: bash
18+
- name: Check workflow files
19+
run: ${{ steps.download-actionlint.outputs.executable }} -color
20+
shell: bash
21+
22+
build-lint-test:
23+
name: Build, lint, and test
24+
uses: ./.github/workflows/build-lint-test.yml
25+
26+
all-jobs-completed:
27+
name: All jobs completed
28+
runs-on: ubuntu-latest
29+
needs:
30+
- check-workflows
31+
- build-lint-test
32+
outputs:
33+
PASSED: ${{ steps.set-output.outputs.PASSED }}
34+
steps:
35+
- name: Set PASSED output
36+
id: set-output
37+
run: echo "PASSED=true" >> "$GITHUB_OUTPUT"
38+
39+
all-jobs-pass:
40+
name: All jobs pass
41+
if: ${{ always() }}
42+
runs-on: ubuntu-latest
43+
needs: all-jobs-completed
44+
steps:
45+
- name: Check that all jobs have passed
46+
run: |
47+
passed="${{ needs.all-jobs-completed.outputs.PASSED }}"
48+
if [[ $passed != "true" ]]; then
49+
exit 1
50+
fi
51+
52+
is-release:
53+
# Filtering by `push` events ensures that we only release from the `main` branch, which is a
54+
# requirement for our npm publishing environment.
55+
# The commit author should always be 'github-actions' for releases created by the
56+
# 'create-release-pr' workflow, so we filter by that as well to prevent accidentally
57+
# triggering a release.
58+
if: github.event_name == 'push' && startsWith(github.event.head_commit.author.name, 'github-actions')
59+
needs: all-jobs-pass
60+
outputs:
61+
IS_RELEASE: ${{ steps.is-release.outputs.IS_RELEASE }}
62+
runs-on: ubuntu-latest
63+
steps:
64+
- uses: MetaMask/action-is-release@v1
65+
id: is-release
66+
67+
publish-release:
68+
needs: is-release
69+
if: needs.is-release.outputs.IS_RELEASE == 'true'
70+
name: Publish release
71+
permissions:
72+
contents: write
73+
uses: ./.github/workflows/publish-release.yml
74+
secrets:
75+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
76+
PUBLISH_DOCS_TOKEN: ${{ secrets.PUBLISH_DOCS_TOKEN }}

0 commit comments

Comments
 (0)