Skip to content

Commit 161bf0e

Browse files
authored
Merge pull request #25586 from MetaMask/Version-v12.1.0
Version v12.1.0
2 parents ef7fa43 + 7848f3c commit 161bf0e

File tree

821 files changed

+40820
-28853
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

821 files changed

+40820
-28853
lines changed

.circleci/config.yml

Lines changed: 88 additions & 195 deletions
Large diffs are not rendered by default.

.depcheckrc.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ ignores:
3939
- 'wait-on'
4040
- 'tsx' # used in .devcontainer
4141
- 'prettier-eslint' # used by the Prettier ESLint VSCode extension
42-
# development tool
43-
- 'nyc'
4442
# storybook
4543
- '@storybook/cli'
4644
- '@storybook/core'

.devcontainer/download-builds.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,12 @@ async function getBuilds(branch: string, jobNames: string[]) {
4545

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

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

52-
const artifacts = (await response.json()).items;
53+
const artifacts = await response.json();
5354

5455
if (!artifacts || artifacts.length === 0) {
5556
return [];

.eslintrc.js

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ module.exports = {
4646
'development/**/*.js',
4747
'test/e2e/**/*.js',
4848
'test/helpers/*.js',
49-
'test/lib/wait-until-called.js',
5049
'test/run-unit-tests.js',
51-
'test/merge-coverage.js',
5250
],
5351
extends: [
5452
path.resolve(__dirname, '.eslintrc.base.js'),
@@ -94,8 +92,6 @@ module.exports = {
9492
'test/stub/**/*.js',
9593
'test/unit-global/**/*.js',
9694
],
97-
// TODO: Convert these files to modern JS
98-
excludedFiles: ['test/lib/wait-until-called.js'],
9995
extends: [
10096
path.resolve(__dirname, '.eslintrc.base.js'),
10197
path.resolve(__dirname, '.eslintrc.node.js'),
@@ -261,26 +257,7 @@ module.exports = {
261257
* Mocha library.
262258
*/
263259
{
264-
files: [
265-
'**/*.test.js',
266-
'test/lib/wait-until-called.js',
267-
'test/e2e/**/*.spec.js',
268-
],
269-
excludedFiles: [
270-
'app/scripts/controllers/app-state.test.js',
271-
'app/scripts/controllers/mmi-controller.test.js',
272-
'app/scripts/controllers/permissions/**/*.test.js',
273-
'app/scripts/controllers/preferences.test.js',
274-
'app/scripts/lib/**/*.test.js',
275-
'app/scripts/metamask-controller.test.js',
276-
'app/scripts/migrations/*.test.js',
277-
'app/scripts/platforms/*.test.js',
278-
'development/**/*.test.js',
279-
'shared/**/*.test.js',
280-
'ui/**/*.test.js',
281-
'ui/__mocks__/*.js',
282-
'test/e2e/helpers.test.js',
283-
],
260+
files: ['test/e2e/**/*.spec.js', 'test/unit-global/*.test.js'],
284261
extends: ['@metamask/eslint-config-mocha'],
285262
rules: {
286263
// In Mocha tests, it is common to use `this` to store values or do
@@ -293,13 +270,19 @@ module.exports = {
293270
* Jest tests
294271
*
295272
* These are files that make use of globals and syntax introduced by the
296-
* Jest library. The files in this section should match the Mocha excludedFiles section.
273+
* Jest library.
274+
* TODO: This list of files is incomplete, and should be replaced with globs that match the
275+
* Jest config.
297276
*/
298277
{
299278
files: [
300279
'**/__snapshots__/*.snap',
301280
'app/scripts/controllers/app-state.test.js',
302281
'app/scripts/controllers/mmi-controller.test.ts',
282+
'app/scripts/metamask-controller.actions.test.js',
283+
'app/scripts/detect-multiple-instances.test.js',
284+
'app/scripts/controllers/swaps.test.js',
285+
'app/scripts/controllers/metametrics.test.js',
303286
'app/scripts/controllers/permissions/**/*.test.js',
304287
'app/scripts/controllers/preferences.test.js',
305288
'app/scripts/lib/**/*.test.js',
@@ -383,7 +366,6 @@ module.exports = {
383366
'test/e2e/benchmark.js',
384367
'test/helpers/setup-helper.js',
385368
'test/run-unit-tests.js',
386-
'test/merge-coverage.js',
387369
],
388370
rules: {
389371
'node/no-process-exit': 'off',

.github/ISSUE_TEMPLATE/bug-report.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ body:
2929
id: screenshot-recording
3030
attributes:
3131
label: Screenshots/Recordings
32-
description: Please include screenshots/recordings if applicable! (https://recordit.co/ is recommended)
32+
description: Please include screenshots/recordings if applicable!
3333
- type: textarea
3434
id: reproduce
3535
attributes:

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ contact_links:
44
url: https://community.metamask.io/c/feature-requests-ideas/
55
about: Request new features and vote on the ones that are important to you
66
- name: Get support or ask a question
7-
url: https://metamask.zendesk.com/hc/en-us
7+
url: https://support.metamask.io/
88
about: Use the MetaMask support system to get help and ask questions
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import * as core from '@actions/core';
2+
import { context, getOctokit } from '@actions/github';
3+
import { GitHub } from '@actions/github/lib/utils';
4+
5+
import { retrieveLabel } from './shared/label';
6+
import { Labelable, addLabelByIdToLabelable } from './shared/labelable';
7+
import { retrievePullRequest } from './shared/pull-request';
8+
9+
main().catch((error: Error): void => {
10+
console.error(error);
11+
process.exit(1);
12+
});
13+
14+
async function main(): Promise<void> {
15+
// "GITHUB_TOKEN" is an automatically generated, repository-specific access token provided by GitHub Actions.
16+
// We can't use "GITHUB_TOKEN" here, as its permissions are scoped to the repository where the action is running.
17+
// "GITHUB_TOKEN" does not have access to other repositories, even when they belong to the same organization.
18+
// As we want to get files which are not necessarily located in the same repository,
19+
// we need to create our own "RELEASE_LABEL_TOKEN" with "repo" permissions.
20+
// Such a token allows to access other repositories of the MetaMask organisation.
21+
const personalAccessToken = process.env.RELEASE_LABEL_TOKEN;
22+
if (!personalAccessToken) {
23+
core.setFailed('RELEASE_LABEL_TOKEN not found');
24+
process.exit(1);
25+
}
26+
27+
// Initialise octokit, required to call Github GraphQL API
28+
const octokit: InstanceType<typeof GitHub> = getOctokit(personalAccessToken, {
29+
previews: ['bane'], // The "bane" preview is required for adding, updating, creating and deleting labels.
30+
});
31+
32+
// Retrieve pull request info from context
33+
const pullRequestRepoOwner = context.repo.owner;
34+
const pullRequestRepoName = context.repo.repo;
35+
const pullRequestNumber = context.payload.pull_request?.number;
36+
if (!pullRequestNumber) {
37+
core.setFailed('Pull request number not found');
38+
process.exit(1);
39+
}
40+
41+
// Retrieve pull request
42+
const pullRequest: Labelable = await retrievePullRequest(
43+
octokit,
44+
pullRequestRepoOwner,
45+
pullRequestRepoName,
46+
pullRequestNumber,
47+
);
48+
49+
// Get the team label id based on the author of the pull request
50+
const teamLabelId = await getTeamLabelIdByAuthor(
51+
octokit,
52+
pullRequestRepoOwner,
53+
pullRequestRepoName,
54+
pullRequest.author,
55+
);
56+
57+
// Add the team label by id to the pull request
58+
await addLabelByIdToLabelable(octokit, pullRequest, teamLabelId);
59+
}
60+
61+
// This helper function gets the team label id based on the author of the pull request
62+
const getTeamLabelIdByAuthor = async (
63+
octokit: InstanceType<typeof GitHub>,
64+
repoOwner: string,
65+
repoName: string,
66+
author: string,
67+
): Promise<string> => {
68+
// Retrieve the teams.json file from the repository
69+
const { data } = (await octokit.request(
70+
'GET /repos/{owner}/{repo}/contents/{path}',
71+
{ owner: repoOwner, repo: 'MetaMask-planning', path: 'teams.json' },
72+
)) as { data: { content: string } };
73+
74+
// Parse the teams.json file content to json from base64
75+
const teamMembers: Record<string, string> = JSON.parse(atob(data.content));
76+
77+
// Get the label name based on the author
78+
const labelName = teamMembers[author];
79+
80+
if (!labelName) {
81+
core.setFailed(`Team label not found for author: ${author}`);
82+
process.exit(1);
83+
}
84+
85+
// Retrieve the label id based on the label name
86+
const labelId = await retrieveLabel(octokit, repoOwner, repoName, labelName);
87+
88+
return labelId;
89+
};

.github/scripts/shared/label.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ async function createLabel(
9393
}
9494

9595
// This function retrieves the label on a specific repo
96-
async function retrieveLabel(
96+
export async function retrieveLabel(
9797
octokit: InstanceType<typeof GitHub>,
9898
repoOwner: string,
9999
repoName: string,

.github/scripts/shared/labelable.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ export interface Labelable {
2727
export function findLabel(
2828
labelable: Labelable,
2929
labelToFind: Label,
30-
): {
31-
id: string;
32-
name: string;
33-
} | undefined {
30+
):
31+
| {
32+
id: string;
33+
name: string;
34+
}
35+
| undefined {
3436
// Check if label is present on labelable
35-
return labelable.labels.find(
36-
(label) => label.name === labelToFind.name,
37-
);
37+
return labelable.labels.find((label) => label.name === labelToFind.name);
3838
}
3939

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

54+
await addLabelByIdToLabelable(octokit, labelable, labelId);
55+
}
56+
57+
// This function adds label by id to a labelable object (i.e. a pull request or an issue)
58+
export async function addLabelByIdToLabelable(
59+
octokit: InstanceType<typeof GitHub>,
60+
labelable: Labelable,
61+
labelId: string,
62+
): Promise<void> {
5463
const addLabelsToLabelableMutation = `
5564
mutation AddLabelsToLabelable($labelableId: ID!, $labelIds: [ID!]!) {
5665
addLabelsToLabelable(input: {labelableId: $labelableId, labelIds: $labelIds}) {
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Add team label to PR when it is opened
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
8+
jobs:
9+
add-team-label:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Setup Node.js
13+
uses: actions/setup-node@v4
14+
with:
15+
node-version: 'lts/*'
16+
17+
- run: corepack enable
18+
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0 # This is needed to checkout all branches
23+
24+
- name: Set up Node.js
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version-file: '.nvmrc'
28+
cache: yarn
29+
30+
- name: Install dependencies
31+
run: yarn --immutable
32+
33+
- name: Add team label to PR
34+
id: add-team-label-to-pr
35+
env:
36+
RELEASE_LABEL_TOKEN: ${{ secrets.RELEASE_LABEL_TOKEN }}
37+
run: yarn run add-team-label-to-pr

0 commit comments

Comments
 (0)