Skip to content
This repository was archived by the owner on Nov 9, 2023. It is now read-only.

Commit 75d2d37

Browse files
authored
Improve module template compliance (#100)
This PR updates various repository features for module template compliance. This repository should be fully compliant as of this PR, except for tests, which will be addressed in a follow-up. Notable changes include: - Updates the ESLint config and related dependencies - Adds `@lavamoat/allow-scripts` and the `setup` package script - Migrates from CircleCI to GitHub Actions - Bumps the minimum Node version to 14
1 parent d38b71a commit 75d2d37

29 files changed

+1571
-620
lines changed

.circleci/config.yml

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

.circleci/scripts/collect-har-artifact.sh

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

.circleci/scripts/deps-install.sh

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

.editorconfig

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
# http://editorconfig.org
21
root = true
32

43
[*]
5-
charset = utf-8
6-
end_of_line = lf
7-
indent_size = 2
84
indent_style = space
9-
insert_final_newline = true
5+
indent_size = 2
6+
end_of_line = lf
7+
charset = utf-8
108
trim_trailing_whitespace = true
11-
12-
[*.md]
13-
indent_size = 4
9+
insert_final_newline = true

.eslintrc.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
module.exports = {
22
root: true,
33

4-
plugins: ['import'],
5-
6-
extends: ['@metamask/eslint-config', '@metamask/eslint-config-nodejs'],
7-
8-
rules: {
9-
'prefer-object-spread': 'off',
10-
},
4+
extends: ['@metamask/eslint-config'],
115

126
overrides: [
137
{
148
files: ['*.ts'],
159
extends: ['@metamask/eslint-config-typescript'],
1610
},
11+
12+
{
13+
files: ['*.js'],
14+
parserOptions: {
15+
sourceType: 'script',
16+
},
17+
extends: ['@metamask/eslint-config-nodejs'],
18+
},
19+
1720
{
1821
files: ['test/*'],
1922
extends: ['@metamask/eslint-config-mocha'],
23+
parserOptions: {
24+
ecmaVersion: 2020,
25+
},
2026
},
2127
],
2228

.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

.github/workflows/build-test.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Build, Lint, and Test
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
jobs:
9+
build-lint-test:
10+
name: Build, Lint, and Test
11+
runs-on: ubuntu-20.04
12+
strategy:
13+
matrix:
14+
node-version: [14.x, 16.x]
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Use Node.js ${{ matrix.node-version }}
18+
uses: actions/setup-node@v2
19+
with:
20+
node-version: ${{ matrix.node-version }}
21+
- name: Get Yarn cache directory
22+
run: echo "::set-output name=YARN_CACHE_DIR::$(yarn cache dir)"
23+
id: yarn-cache-dir
24+
- name: Get Yarn version
25+
run: echo "::set-output name=YARN_VERSION::$(yarn --version)"
26+
id: yarn-version
27+
- name: Cache yarn dependencies
28+
uses: actions/cache@v2
29+
with:
30+
path: ${{ steps.yarn-cache-dir.outputs.YARN_CACHE_DIR }}
31+
key: yarn-cache-${{ runner.os }}-${{ steps.yarn-version.outputs.YARN_VERSION }}-${{ hashFiles('yarn.lock') }}
32+
- run: yarn --frozen-lockfile
33+
- run: yarn allow-scripts
34+
- run: yarn build
35+
- run: yarn lint
36+
- run: yarn test
37+
- name: Validate RC changelog
38+
if: ${{ startsWith(github.head_ref, 'release/') }}
39+
run: yarn auto-changelog validate --rc
40+
- name: Validate changelog
41+
if: ${{ !startsWith(github.head_ref, 'release/') }}
42+
run: yarn auto-changelog validate
43+
- name: Require clean working directory
44+
shell: bash
45+
run: |
46+
if ! git diff --exit-code; then
47+
echo "Working tree dirty after building"
48+
exit 1
49+
fi
50+
all-jobs-pass:
51+
name: All jobs pass
52+
runs-on: ubuntu-20.04
53+
needs:
54+
- build-lint-test
55+
steps:
56+
- run: echo "Great success!"
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Create Release Pull Request
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
base-branch:
7+
description: 'The base branch for git operations and the pull request.'
8+
default: 'main'
9+
required: true
10+
release-type:
11+
description: 'A SemVer version diff, i.e. major, minor, patch, prerelease etc. Mutually exclusive with "release-version".'
12+
required: false
13+
release-version:
14+
description: 'A specific version to bump to. Mutually exclusive with "release-type".'
15+
required: false
16+
17+
jobs:
18+
create-release-pr:
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: write
22+
pull-requests: write
23+
steps:
24+
- uses: actions/checkout@v2
25+
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.
28+
fetch-depth: 0
29+
# We check out the specified branch, which will be used as the base
30+
# branch for all git operations and the release PR.
31+
ref: ${{ github.event.inputs.base-branch }}
32+
- name: Get Node.js version
33+
id: nvm
34+
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc)
35+
- uses: actions/setup-node@v2
36+
with:
37+
node-version: ${{ steps.nvm.outputs.NODE_VERSION }}
38+
- uses: MetaMask/action-create-release-pr@v1
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
with:
42+
release-type: ${{ github.event.inputs.release-type }}
43+
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@v2
47+
with:
48+
name: release-authors
49+
path: gh-action__release-authors
50+
if-no-files-found: error
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Publish Release
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
7+
jobs:
8+
publish-release:
9+
permissions:
10+
contents: write
11+
if: |
12+
github.event.pull_request.merged == true &&
13+
startsWith(github.event.pull_request.head.ref, 'release/')
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v2
17+
with:
18+
# We check out the release pull request's base branch, which will be
19+
# used as the base branch for all git operations.
20+
ref: ${{ github.event.pull_request.base.ref }}
21+
- name: Get Node.js version
22+
id: nvm
23+
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc)
24+
- uses: actions/setup-node@v2
25+
with:
26+
node-version: ${{ steps.nvm.outputs.NODE_VERSION }}
27+
- uses: MetaMask/action-publish-release@v1
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Require Additional Reviewer for Releases
2+
3+
on:
4+
pull_request:
5+
pull_request_review:
6+
7+
jobs:
8+
require-additional-reviewer:
9+
permissions:
10+
actions: read
11+
contents: read
12+
pull-requests: read
13+
statuses: write
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v2
17+
with:
18+
# If the base branch has been merged into the release branch, we
19+
# need to find the earliest common ancestor commit of the base and
20+
# release branches.
21+
fetch-depth: 0
22+
# We want the head / feature branch to be checked out, and we will
23+
# compare it to the base branch in the action.
24+
ref: ${{ github.event.pull_request.head.ref }}
25+
- uses: MetaMask/action-require-additional-reviewer@v1
26+
env:
27+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
with:
29+
read-org-token: ${{ secrets.ORG_READER }}

0 commit comments

Comments
 (0)