Skip to content

Commit

Permalink
Merge branch 'develop' into bowen/interactiveui
Browse files Browse the repository at this point in the history
  • Loading branch information
bowensanders authored Jun 14, 2024
2 parents 890d45d + 743f5ec commit e57bb82
Show file tree
Hide file tree
Showing 918 changed files with 67,113 additions and 33,594 deletions.
475 changes: 281 additions & 194 deletions .circleci/config.yml

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions .circleci/scripts/bundle-stats-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ git clone [email protected]:MetaMask/extension_bundlesize_stats.git temp

{
echo " '${CIRCLE_SHA1}': ";
cat test-artifacts/chrome/mv3/bundle_size_stats.json;
cat test-artifacts/chrome/bundle_size_stats.json;
echo ", ";
} >> temp/stats/bundle_size_data.temp.js

Expand All @@ -57,14 +57,14 @@ if [ -f temp/stats/bundle_size_data.json ]; then
{
echo "},";
echo "\"$CIRCLE_SHA1\":";
cat test-artifacts/chrome/mv3/bundle_size_stats.json;
cat test-artifacts/chrome/bundle_size_stats.json;
echo "}";
} >> bundle_size_stats.temp.json
else
{
echo "{";
echo "\"$CIRCLE_SHA1\":";
cat test-artifacts/chrome/mv3/bundle_size_stats.json;
cat test-artifacts/chrome/bundle_size_stats.json;
echo "}";
} > bundle_size_stats.temp.json
fi
Expand Down
4 changes: 2 additions & 2 deletions .circleci/scripts/release-create-gh-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ then
release_body="$(awk -v version="${tag##v}" -f .circleci/scripts/show-changelog.awk CHANGELOG.md)"
hub release create \
--attach builds/metamask-chrome-*.zip \
--attach builds/metamask-firefox-*.zip \
--attach builds-mv2/metamask-firefox-*.zip \
--attach builds-flask/metamask-flask-chrome-*.zip \
--attach builds-flask/metamask-flask-firefox-*.zip \
--attach builds-flask-mv2/metamask-flask-firefox-*.zip \
--attach builds-mmi/metamask-mmi-chrome-*.zip \
--attach builds-mmi/metamask-mmi-firefox-*.zip \
--message "Version ${tag##v}" \
Expand Down
5 changes: 3 additions & 2 deletions .devcontainer/download-builds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,12 @@ async function getBuilds(branch: string, jobNames: string[]) {

console.log(`jobName: ${jobName}, jobId: ${jobId}`);

// Using the CircleCI API version 1.1 here, because this endpoint recently started requiring Authorization in v2
const response = await fetch(
`https://circleci.com/api/v2/project/gh/MetaMask/metamask-extension/${jobId}/artifacts`,
`https://circleci.com/api/v1.1/project/gh/MetaMask/metamask-extension/${jobId}/artifacts`,
);

const artifacts = (await response.json()).items;
const artifacts = await response.json();

if (!artifacts || artifacts.length === 0) {
return [];
Expand Down
20 changes: 20 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,23 @@ ui/selectors/institutional @MetaMask/mmi
# Design System to own code for the component-library folder
# Slack handle: @metamask-design-system-team | Slack channel: #metamask-design-system
ui/components/component-library @MetaMask/design-system-engineers

# The Notifications team is responsible for code related to notifications,
# authentication, and profile syncing inside the Extension.

# Controllers
**/controllers/authentication/** @MetaMask/notifications
**/controllers/metamask-notifications/** @MetaMask/notifications
**/controllers/push-platform-notifications/** @MetaMask/notifications
**/controllers/user-storage/** @MetaMask/notifications

# UI
**/metamask-notifications/** @MetaMask/notifications
**/multichain/notification*/** @MetaMask/notifications
**/pages/notification*/** @MetaMask/notifications
**/utils/notification.util.ts @MetaMask/notifications

# Accounts team is responsible for code related with snap management accounts
# Slack handle: @accounts-team-devs | Slack channel: #metamask-accounts-team

app/scripts/lib/snap-keyring @MetaMask/accounts-engineers
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ body:
id: screenshot-recording
attributes:
label: Screenshots/Recordings
description: Please include screenshots/recordings if applicable! (https://recordit.co/ is recommended)
description: Please include screenshots/recordings if applicable!
- type: textarea
id: reproduce
attributes:
Expand Down
1 change: 1 addition & 0 deletions .github/guidelines/LABELING_GUIDELINES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ It's essential to ensure that PRs have the appropriate labels before they are co
### Mandatory release version labels:
- **release-x.y.z**: This label is automatically added to a PR and its linked issues upon the PR's merge. The `x.y.z` in the label represents the version in which the changes from the PR will be included. This label is auto-generated by a [GitHub action](../workflows/add-release-label.yml), which determines the version by incrementing the minor version number from the most recent release. Manual intervention is only required in specific cases. For instance, if a merged PR is cherry-picked into a release branch, typically done to address Release Candidate (RC) bugs, the label would need to be manually updated to reflect the correct version.
- **regression-prod-x.y.z**: This label is automatically added to a bug report issue at the time of its creation. The `x.y.z` in the label represents the version in which the bug first appeared. This label is auto-generated by a [GitHub action](../workflows/check-template-and-add-labels.yml), which determines the `x.y.z` value based on the version information provided in the bug report issue form. Manual intervention is only necessary under certain circumstances. For example, if a user submits a bug report and specifies the version they are currently using, but the bug was actually introduced in a prior version, the label would need to be manually updated to accurately reflect the version where the bug originated.
- **regression-RC-x.y.z**: This label is manually added to a bug report issue by release engineers when a bug is found during release regerssion testing phase. The `x.y.z` in the label represents the release candidate (RC) version in which the bug's been discovered.

### Optional labels:
- **regression-develop**: This label can manually be added to a bug report issue at the time of its creation if the bug is present on the development branch, i.e., `develop`, but is not yet released in production.
Expand Down
2 changes: 1 addition & 1 deletion .github/pull-request-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Fixes:

## **Pre-merge author checklist**

- [ ] Ive followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable
Expand Down
89 changes: 89 additions & 0 deletions .github/scripts/add-team-label-to-pr.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import * as core from '@actions/core';
import { context, getOctokit } from '@actions/github';
import { GitHub } from '@actions/github/lib/utils';

import { retrieveLabel } from './shared/label';
import { Labelable, addLabelByIdToLabelable } from './shared/labelable';
import { retrievePullRequest } from './shared/pull-request';

main().catch((error: Error): void => {
console.error(error);
process.exit(1);
});

async function main(): Promise<void> {
// "GITHUB_TOKEN" is an automatically generated, repository-specific access token provided by GitHub Actions.
// We can't use "GITHUB_TOKEN" here, as its permissions are scoped to the repository where the action is running.
// "GITHUB_TOKEN" does not have access to other repositories, even when they belong to the same organization.
// As we want to get files which are not necessarily located in the same repository,
// we need to create our own "RELEASE_LABEL_TOKEN" with "repo" permissions.
// Such a token allows to access other repositories of the MetaMask organisation.
const personalAccessToken = process.env.RELEASE_LABEL_TOKEN;
if (!personalAccessToken) {
core.setFailed('RELEASE_LABEL_TOKEN not found');
process.exit(1);
}

// Initialise octokit, required to call Github GraphQL API
const octokit: InstanceType<typeof GitHub> = getOctokit(personalAccessToken, {
previews: ['bane'], // The "bane" preview is required for adding, updating, creating and deleting labels.
});

// Retrieve pull request info from context
const pullRequestRepoOwner = context.repo.owner;
const pullRequestRepoName = context.repo.repo;
const pullRequestNumber = context.payload.pull_request?.number;
if (!pullRequestNumber) {
core.setFailed('Pull request number not found');
process.exit(1);
}

// Retrieve pull request
const pullRequest: Labelable = await retrievePullRequest(
octokit,
pullRequestRepoOwner,
pullRequestRepoName,
pullRequestNumber,
);

// Get the team label id based on the author of the pull request
const teamLabelId = await getTeamLabelIdByAuthor(
octokit,
pullRequestRepoOwner,
pullRequestRepoName,
pullRequest.author,
);

// Add the team label by id to the pull request
await addLabelByIdToLabelable(octokit, pullRequest, teamLabelId);
}

// This helper function gets the team label id based on the author of the pull request
const getTeamLabelIdByAuthor = async (
octokit: InstanceType<typeof GitHub>,
repoOwner: string,
repoName: string,
author: string,
): Promise<string> => {
// Retrieve the teams.json file from the repository
const { data } = (await octokit.request(
'GET /repos/{owner}/{repo}/contents/{path}',
{ owner: repoOwner, repo: 'MetaMask-planning', path: 'teams.json' },
)) as { data: { content: string } };

// Parse the teams.json file content to json from base64
const teamMembers: Record<string, string> = JSON.parse(atob(data.content));

// Get the label name based on the author
const labelName = teamMembers[author];

if (!labelName) {
core.setFailed(`Team label not found for author: ${author}`);
process.exit(1);
}

// Retrieve the label id based on the label name
const labelId = await retrieveLabel(octokit, repoOwner, repoName, labelName);

return labelId;
};
2 changes: 1 addition & 1 deletion .github/scripts/check-template-and-add-labels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,5 +313,5 @@ async function userBelongsToMetaMaskOrg(
function isReleaseCandidateIssue(
issue: Labelable,
): boolean {
return Boolean(issue.labels.find(label => label.name === 'regression-RC'));
return Boolean(issue.labels.find(label => label.name.startsWith('regression-RC')));
}
2 changes: 1 addition & 1 deletion .github/scripts/shared/label.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ async function createLabel(
}

// This function retrieves the label on a specific repo
async function retrieveLabel(
export async function retrieveLabel(
octokit: InstanceType<typeof GitHub>,
repoOwner: string,
repoName: string,
Expand Down
23 changes: 16 additions & 7 deletions .github/scripts/shared/labelable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ export interface Labelable {
export function findLabel(
labelable: Labelable,
labelToFind: Label,
): {
id: string;
name: string;
} | undefined {
):
| {
id: string;
name: string;
}
| undefined {
// Check if label is present on labelable
return labelable.labels.find(
(label) => label.name === labelToFind.name,
);
return labelable.labels.find((label) => label.name === labelToFind.name);
}

// This function adds label to a labelable object (i.e. a pull request or an issue)
Expand All @@ -51,6 +51,15 @@ export async function addLabelToLabelable(
label,
);

await addLabelByIdToLabelable(octokit, labelable, labelId);
}

// This function adds label by id to a labelable object (i.e. a pull request or an issue)
export async function addLabelByIdToLabelable(
octokit: InstanceType<typeof GitHub>,
labelable: Labelable,
labelId: string,
): Promise<void> {
const addLabelsToLabelableMutation = `
mutation AddLabelsToLabelable($labelableId: ID!, $labelIds: [ID!]!) {
addLabelsToLabelable(input: {labelableId: $labelableId, labelIds: $labelIds}) {
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/add-release-label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ jobs:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true
steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'

- run: corepack enable
- name: Checkout repository
uses: actions/checkout@v4
with:
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/add-team-label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Add team label to PR when it is opened

on:
pull_request:
types:
- opened

jobs:
add-team-label:
runs-on: ubuntu-latest
steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'

- run: corepack enable

- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # This is needed to checkout all branches

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: yarn

- name: Install dependencies
run: yarn --immutable

- name: Add team label to PR
id: add-team-label-to-pr
env:
RELEASE_LABEL_TOKEN: ${{ secrets.RELEASE_LABEL_TOKEN }}
run: yarn run add-team-label-to-pr
29 changes: 29 additions & 0 deletions .github/workflows/check-attributions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Check Attributions

on:
push:
branches: Version-v*
pull_request:
branches: Version-v*
types:
- opened
- reopened
- synchronize
- ready_for_review

jobs:
check-attributions:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- run: corepack enable
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- name: Install dependencies from cache
run: yarn --immutable
- name: Check attributions changes
run: yarn attributions:check
10 changes: 8 additions & 2 deletions .github/workflows/check-pr-labels.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Check PR has required labels"
name: 'Check PR has required labels'
on:
pull_request:
branches:
Expand All @@ -17,10 +17,16 @@ jobs:
pull-requests: read

steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- run: corepack enable

- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1 # This retrieves only the latest commit.
fetch-depth: 1 # This retrieves only the latest commit.

- name: Set up Node.js
uses: actions/setup-node@v4
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/check-template-and-add-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ jobs:
check-template-and-add-labels:
runs-on: ubuntu-latest
steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- run: corepack enable

- name: Checkout repository
uses: actions/checkout@v4
with:
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/close-bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ jobs:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'Version-v')
steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- run: corepack enable

- name: Checkout repository
uses: actions/checkout@v4
with:
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/codespaces.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ jobs:
name: Generate cache image
runs-on: ubuntu-latest
steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- run: corepack enable

- name: Checkout repository
uses: actions/checkout@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/create-bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
{
"title": "v${{ env.version }} Bug Report",
"body": "This bug report was automatically created by a GitHub action upon the creation of release branch \`Version-v${{ env.version }}\` (release cut).\n\n**Expected actions for release engineers:**\n\n1. Convert this issue into a Zenhub epic and link all bugs identified during the release regression testing phase to this epic.\n\n2. After completing the first regression run, move this epic to \"Regression Completed\" on the [Extension Release Regression board](https://app.zenhub.com/workspaces/extension-release-regression-6478c62d937eaa15e95c33c5/board?filterLogic=any&labels=release-${{ env.version }},release-task).\n\nNote that once the release is prepared for store submission, meaning the \`Version-v${{ env.version }}\` branch merges into \`master\`, another GitHub action will automatically close this epic.",
"labels": ["type-bug", "regression-RC", "release-${{ env.version }}"]
"labels": ["type-bug", "team-extension-platform", "regression-RC-${{ env.version }}"]
}
EOF
)
Expand Down
Loading

0 comments on commit e57bb82

Please sign in to comment.