-
-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Q3 2022 repository standardization (#25)
Standardizes this repository per the module template as of Q3 2022. All changes are copied over directly from the template, except for the tests, which have been rewritten. A couple of notes: - I didn't bother rewriting the tests for JSON-RPC notifications, as that functionality will be implemented in a completely different manner in #24 has been merged. - CI has been switched from CircleCI to GitHub Actions.
- Loading branch information
Showing
23 changed files
with
4,162 additions
and
1,005 deletions.
There are no files selected for viewing
66 changes: 0 additions & 66 deletions
66
merged-packages/json-rpc-middleware-stream/.circleci/config.yml
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
merged-packages/json-rpc-middleware-stream/.circleci/scripts/collect-har-artifact.sh
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
merged-packages/json-rpc-middleware-stream/.circleci/scripts/deps-install.sh
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,27 @@ | ||
module.exports = { | ||
parserOptions: { | ||
ecmaVersion: 2018, | ||
}, | ||
plugins: [ | ||
'json', | ||
], | ||
extends: [ | ||
'@metamask/eslint-config', | ||
'@metamask/eslint-config/config/nodejs', | ||
'@metamask/eslint-config/config/typescript', | ||
], | ||
overrides: [{ | ||
files: [ | ||
'*.js', | ||
'*.json', | ||
], | ||
parserOptions: { | ||
sourceType: 'script', | ||
root: true, | ||
|
||
extends: ['@metamask/eslint-config'], | ||
|
||
overrides: [ | ||
{ | ||
files: ['*.ts'], | ||
extends: ['@metamask/eslint-config-typescript'], | ||
}, | ||
|
||
{ | ||
files: ['*.js'], | ||
parserOptions: { | ||
sourceType: 'script', | ||
}, | ||
extends: ['@metamask/eslint-config-nodejs'], | ||
}, | ||
rules: { | ||
'@typescript-eslint/no-require-imports': 'off', | ||
'@typescript-eslint/no-var-requires': 'off', | ||
|
||
{ | ||
files: ['*.test.ts', '*.test.js'], | ||
extends: ['@metamask/eslint-config-jest'], | ||
}, | ||
}], | ||
ignorePatterns: [ | ||
'!eslintrc.js', | ||
'dist/', | ||
'node_modules/', | ||
], | ||
|
||
ignorePatterns: ['!.eslintrc.js', '!.prettierrc.js', 'dist/'], | ||
}; |
15 changes: 15 additions & 0 deletions
15
merged-packages/json-rpc-middleware-stream/.github/dependabot.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Please see the documentation for all configuration options: | ||
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: 'npm' | ||
directory: '/' | ||
schedule: | ||
interval: 'daily' | ||
time: '06:00' | ||
allow: | ||
- dependency-name: '@metamask/*' | ||
target-branch: 'main' | ||
versioning-strategy: 'increase-if-necessary' | ||
open-pull-requests-limit: 10 |
56 changes: 56 additions & 0 deletions
56
merged-packages/json-rpc-middleware-stream/.github/workflows/build-test.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: Build, Lint, and Test | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
|
||
jobs: | ||
build-lint-test: | ||
name: Build, Lint, and Test | ||
runs-on: ubuntu-20.04 | ||
strategy: | ||
matrix: | ||
node-version: [14.x, 16.x] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: Get Yarn cache directory | ||
run: echo "::set-output name=YARN_CACHE_DIR::$(yarn cache dir)" | ||
id: yarn-cache-dir | ||
- name: Get Yarn version | ||
run: echo "::set-output name=YARN_VERSION::$(yarn --version)" | ||
id: yarn-version | ||
- name: Cache yarn dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: ${{ steps.yarn-cache-dir.outputs.YARN_CACHE_DIR }} | ||
key: yarn-cache-${{ runner.os }}-${{ steps.yarn-version.outputs.YARN_VERSION }}-${{ hashFiles('yarn.lock') }} | ||
- run: yarn --frozen-lockfile | ||
- run: yarn allow-scripts | ||
- run: yarn build | ||
- run: yarn lint | ||
- run: yarn test | ||
- name: Validate RC changelog | ||
if: ${{ startsWith(github.head_ref, 'release/') }} | ||
run: yarn auto-changelog validate --rc | ||
- name: Validate changelog | ||
if: ${{ !startsWith(github.head_ref, 'release/') }} | ||
run: yarn auto-changelog validate | ||
- name: Require clean working directory | ||
shell: bash | ||
run: | | ||
if ! git diff --exit-code; then | ||
echo "Working tree dirty at end of job" | ||
exit 1 | ||
fi | ||
all-jobs-pass: | ||
name: All jobs pass | ||
runs-on: ubuntu-20.04 | ||
needs: | ||
- build-lint-test | ||
steps: | ||
- run: echo "Great success!" |
50 changes: 50 additions & 0 deletions
50
merged-packages/json-rpc-middleware-stream/.github/workflows/create-release-pr.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Create Release Pull Request | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
base-branch: | ||
description: 'The base branch for git operations and the pull request.' | ||
default: 'main' | ||
required: true | ||
release-type: | ||
description: 'A SemVer version diff, i.e. major, minor, patch, prerelease etc. Mutually exclusive with "release-version".' | ||
required: false | ||
release-version: | ||
description: 'A specific version to bump to. Mutually exclusive with "release-type".' | ||
required: false | ||
|
||
jobs: | ||
create-release-pr: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
# This is to guarantee that the most recent tag is fetched. | ||
# This can be configured to a more reasonable value by consumers. | ||
fetch-depth: 0 | ||
# We check out the specified branch, which will be used as the base | ||
# branch for all git operations and the release PR. | ||
ref: ${{ github.event.inputs.base-branch }} | ||
- name: Get Node.js version | ||
id: nvm | ||
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc) | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: ${{ steps.nvm.outputs.NODE_VERSION }} | ||
- uses: MetaMask/action-create-release-pr@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
release-type: ${{ github.event.inputs.release-type }} | ||
release-version: ${{ github.event.inputs.release-version }} | ||
artifacts-path: gh-action__release-authors | ||
# Upload the release author artifact for use in subsequent workflows | ||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: release-authors | ||
path: gh-action__release-authors | ||
if-no-files-found: error |
29 changes: 29 additions & 0 deletions
29
merged-packages/json-rpc-middleware-stream/.github/workflows/publish-release.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Publish Release | ||
|
||
on: | ||
pull_request: | ||
types: [closed] | ||
|
||
jobs: | ||
publish-release: | ||
permissions: | ||
contents: write | ||
if: | | ||
github.event.pull_request.merged == true && | ||
startsWith(github.event.pull_request.head.ref, 'release/') | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
# We check out the release pull request's base branch, which will be | ||
# used as the base branch for all git operations. | ||
ref: ${{ github.event.pull_request.base.ref }} | ||
- name: Get Node.js version | ||
id: nvm | ||
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc) | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: ${{ steps.nvm.outputs.NODE_VERSION }} | ||
- uses: MetaMask/action-publish-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
29 changes: 29 additions & 0 deletions
29
merged-packages/json-rpc-middleware-stream/.github/workflows/require-additional-reviewer.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Require Additional Reviewer for Releases | ||
|
||
on: | ||
pull_request: | ||
pull_request_review: | ||
|
||
jobs: | ||
require-additional-reviewer: | ||
permissions: | ||
actions: read | ||
contents: read | ||
pull-requests: read | ||
statuses: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
# If the base branch has been merged into the release branch, we | ||
# need to find the earliest common ancestor commit of the base and | ||
# release branches. | ||
fetch-depth: 0 | ||
# We want the head / feature branch to be checked out, and we will | ||
# compare it to the base branch in the action. | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
- uses: MetaMask/action-require-additional-reviewer@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
read-org-token: ${{ secrets.ORG_READER }} |
Oops, something went wrong.