Skip to content

Commit f8dd9f5

Browse files
authored
Merge pull request #27996 from MetaMask/Version-v12.6.0
Version v12.6.0
2 parents 83bfd33 + f644102 commit f8dd9f5

File tree

1,044 files changed

+42587
-27749
lines changed

Some content is hidden

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

1,044 files changed

+42587
-27749
lines changed

.circleci/config.yml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,9 @@ workflows:
118118
- prep-deps
119119
- get-changed-files-with-git-diff:
120120
filters:
121-
branches:
122-
ignore:
123-
- master
124-
requires:
125-
- prep-deps
121+
branches:
122+
ignore:
123+
- master
126124
- test-deps-audit:
127125
requires:
128126
- prep-deps
@@ -360,11 +358,10 @@ workflows:
360358
value: << pipeline.git.branch >>
361359
jobs:
362360
- prep-deps
363-
- get-changed-files-with-git-diff:
364-
requires:
365-
- prep-deps
361+
- get-changed-files-with-git-diff
366362
- validate-locales-only:
367363
requires:
364+
- prep-deps
368365
- get-changed-files-with-git-diff
369366
- test-lint:
370367
requires:
@@ -501,7 +498,6 @@ jobs:
501498
- run: sudo corepack enable
502499
- attach_workspace:
503500
at: .
504-
- gh/install
505501
- run:
506502
name: Get changed files with git diff
507503
command: npx tsx .circleci/scripts/git-diff-develop.ts
@@ -1012,7 +1008,7 @@ jobs:
10121008
command: ./development/shellcheck.sh
10131009

10141010
test-lint-lockfile:
1015-
executor: node-browsers-medium
1011+
executor: node-browsers-medium-plus
10161012
steps:
10171013
- run: *shallow-git-clone-and-enable-vnc
10181014
- run: sudo corepack enable
@@ -1254,7 +1250,7 @@ jobs:
12541250
command: mv ./builds-test-flask-mv2 ./builds
12551251
- run:
12561252
name: test:e2e:firefox:flask
1257-
command: ENABLE_MV3=false .circleci/scripts/test-run-e2e.sh yarn test:e2e:firefox:flask
1253+
command: .circleci/scripts/test-run-e2e.sh yarn test:e2e:firefox:flask
12581254
no_output_timeout: 5m
12591255
- store_artifacts:
12601256
path: test-artifacts
@@ -1397,7 +1393,7 @@ jobs:
13971393
command: mv ./builds-test-mv2 ./builds
13981394
- run:
13991395
name: test:e2e:firefox
1400-
command: ENABLE_MV3=false .circleci/scripts/test-run-e2e.sh yarn test:e2e:firefox
1396+
command: .circleci/scripts/test-run-e2e.sh yarn test:e2e:firefox
14011397
no_output_timeout: 5m
14021398
- store_artifacts:
14031399
path: test-artifacts
Lines changed: 64 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,42 @@
1-
import { hasProperty } from '@metamask/utils';
21
import { exec as execCallback } from 'child_process';
32
import fs from 'fs';
43
import path from 'path';
54
import { promisify } from 'util';
65

76
const exec = promisify(execCallback);
87

8+
// The CIRCLE_PR_NUMBER variable is only available on forked Pull Requests
9+
const PR_NUMBER =
10+
process.env.CIRCLE_PR_NUMBER ||
11+
process.env.CIRCLE_PULL_REQUEST?.split('/').pop();
12+
913
const MAIN_BRANCH = 'develop';
14+
const SOURCE_BRANCH = `refs/pull/${PR_NUMBER}/head`;
15+
16+
const CHANGED_FILES_DIR = 'changed-files';
17+
18+
type PRInfo = {
19+
base: {
20+
ref: string;
21+
};
22+
body: string;
23+
};
1024

1125
/**
12-
* Get the target branch for the given pull request.
26+
* Get JSON info about the given pull request
1327
*
14-
* @returns The name of the branch targeted by the PR.
28+
* @returns JSON info from GitHub
1529
*/
16-
async function getBaseRef(): Promise<string | null> {
17-
if (!process.env.CIRCLE_PULL_REQUEST) {
30+
async function getPrInfo(): Promise<PRInfo | null> {
31+
if (!PR_NUMBER) {
1832
return null;
1933
}
2034

21-
// We're referencing the CIRCLE_PULL_REQUEST environment variable within the script rather than
22-
// passing it in because this makes it easier to use Bash parameter expansion to extract the
23-
// PR number from the URL.
24-
const result = await exec(`gh pr view --json baseRefName "\${CIRCLE_PULL_REQUEST##*/}" --jq '.baseRefName'`);
25-
const baseRef = result.stdout.trim();
26-
return baseRef;
35+
return await (
36+
await fetch(
37+
`https://api.github.com/repos/${process.env.CIRCLE_PROJECT_USERNAME}/${process.env.CIRCLE_PROJECT_REPONAME}/pulls/${PR_NUMBER}`,
38+
)
39+
).json();
2740
}
2841

2942
/**
@@ -34,8 +47,10 @@ async function getBaseRef(): Promise<string | null> {
3447
*/
3548
async function fetchWithDepth(depth: number): Promise<boolean> {
3649
try {
37-
await exec(`git fetch --depth ${depth} origin develop`);
38-
await exec(`git fetch --depth ${depth} origin ${process.env.CIRCLE_BRANCH}`);
50+
await exec(`git fetch --depth ${depth} origin "${MAIN_BRANCH}"`);
51+
await exec(
52+
`git fetch --depth ${depth} origin "${SOURCE_BRANCH}:${SOURCE_BRANCH}"`,
53+
);
3954
return true;
4055
} catch (error: unknown) {
4156
console.error(`Failed to fetch with depth ${depth}:`, error);
@@ -59,18 +74,16 @@ async function fetchUntilMergeBaseFound() {
5974
await exec(`git merge-base origin/HEAD HEAD`);
6075
return;
6176
} catch (error: unknown) {
62-
if (
63-
error instanceof Error &&
64-
hasProperty(error, 'code') &&
65-
error.code === 1
66-
) {
67-
console.error(`Error 'no merge base' encountered with depth ${depth}. Incrementing depth...`);
77+
if (error instanceof Error && 'code' in error) {
78+
console.error(
79+
`Error 'no merge base' encountered with depth ${depth}. Incrementing depth...`,
80+
);
6881
} else {
6982
throw error;
7083
}
7184
}
7285
}
73-
await exec(`git fetch --unshallow origin develop`);
86+
await exec(`git fetch --unshallow origin "${MAIN_BRANCH}"`);
7487
}
7588

7689
/**
@@ -82,55 +95,69 @@ async function fetchUntilMergeBaseFound() {
8295
*/
8396
async function gitDiff(): Promise<string> {
8497
await fetchUntilMergeBaseFound();
85-
const { stdout: diffResult } = await exec(`git diff --name-only origin/HEAD...${process.env.CIRCLE_BRANCH}`);
98+
const { stdout: diffResult } = await exec(
99+
`git diff --name-only "origin/HEAD...${SOURCE_BRANCH}"`,
100+
);
86101
if (!diffResult) {
87-
throw new Error('Unable to get diff after full checkout.');
102+
throw new Error('Unable to get diff after full checkout.');
88103
}
89104
return diffResult;
90105
}
91106

107+
function writePrBodyToFile(prBody: string) {
108+
const prBodyPath = path.resolve(CHANGED_FILES_DIR, 'pr-body.txt');
109+
fs.writeFileSync(prBodyPath, prBody.trim());
110+
console.log(`PR body saved to ${prBodyPath}`);
111+
}
112+
92113
/**
93-
* Stores the output of git diff to a file.
114+
* Main run function, stores the output of git diff and the body of the matching PR to a file.
94115
*
95-
* @returns Returns a promise that resolves when the git diff output is successfully stored.
116+
* @returns Returns a promise that resolves when the git diff output and PR body is successfully stored.
96117
*/
97-
async function storeGitDiffOutput() {
118+
async function storeGitDiffOutputAndPrBody() {
98119
try {
99120
// Create the directory
100121
// This is done first because our CirleCI config requires that this directory is present,
101122
// even if we want to skip this step.
102-
const outputDir = 'changed-files';
103-
fs.mkdirSync(outputDir, { recursive: true });
123+
fs.mkdirSync(CHANGED_FILES_DIR, { recursive: true });
104124

105-
console.log(`Determining whether this run is for a PR targetting ${MAIN_BRANCH}`)
106-
if (!process.env.CIRCLE_PULL_REQUEST) {
107-
console.log("Not a PR, skipping git diff");
125+
console.log(
126+
`Determining whether this run is for a PR targeting ${MAIN_BRANCH}`,
127+
);
128+
if (!PR_NUMBER) {
129+
console.log('Not a PR, skipping git diff');
108130
return;
109131
}
110132

111-
const baseRef = await getBaseRef();
112-
if (baseRef === null) {
113-
console.log("Not a PR, skipping git diff");
133+
const prInfo = await getPrInfo();
134+
135+
const baseRef = prInfo?.base.ref;
136+
if (!baseRef) {
137+
console.log('Not a PR, skipping git diff');
114138
return;
115139
} else if (baseRef !== MAIN_BRANCH) {
116140
console.log(`This is for a PR targeting '${baseRef}', skipping git diff`);
141+
writePrBodyToFile(prInfo.body);
117142
return;
118143
}
119144

120-
console.log("Attempting to get git diff...");
145+
console.log('Attempting to get git diff...');
121146
const diffOutput = await gitDiff();
122147
console.log(diffOutput);
123148

124149
// Store the output of git diff
125-
const outputPath = path.resolve(outputDir, 'changed-files.txt');
150+
const outputPath = path.resolve(CHANGED_FILES_DIR, 'changed-files.txt');
126151
fs.writeFileSync(outputPath, diffOutput.trim());
127-
128152
console.log(`Git diff results saved to ${outputPath}`);
153+
154+
writePrBodyToFile(prInfo.body);
155+
129156
process.exit(0);
130157
} catch (error: any) {
131158
console.error('An error occurred:', error.message);
132159
process.exit(1);
133160
}
134161
}
135162

136-
storeGitDiffOutput();
163+
storeGitDiffOutputAndPrBody();

.circleci/scripts/test-run-e2e-timeout-minutes.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { filterE2eChangedFiles } from '../../test/e2e/changedFilesUtil';
22

33
const changedOrNewTests = filterE2eChangedFiles();
44

5-
//15 minutes, plus 3 minutes for every changed file, up to a maximum of 30 minutes
6-
const extraTime = Math.min(15 + changedOrNewTests.length * 3, 30);
5+
// 20 minutes, plus 3 minutes for every changed file, up to a maximum of 30 minutes
6+
const extraTime = Math.min(20 + changedOrNewTests.length * 3, 30);
77

88
console.log(extraTime);

.depcheckrc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ ignores:
8080
- '@babel/plugin-transform-logical-assignment-operators'
8181
# trezor
8282
- 'ts-mixer'
83+
- '@testing-library/dom'
8384

8485
# files depcheck should not parse
8586
ignorePatterns:

.eslintrc.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,16 +307,18 @@ module.exports = {
307307
{
308308
files: [
309309
'**/__snapshots__/*.snap',
310-
'app/scripts/controllers/app-state.test.js',
310+
'app/scripts/controllers/app-state-controller.test.ts',
311311
'app/scripts/controllers/mmi-controller.test.ts',
312+
'app/scripts/controllers/alert-controller.test.ts',
312313
'app/scripts/metamask-controller.actions.test.js',
313314
'app/scripts/detect-multiple-instances.test.js',
314315
'app/scripts/controllers/bridge.test.ts',
315316
'app/scripts/controllers/swaps/**/*.test.js',
316317
'app/scripts/controllers/swaps/**/*.test.ts',
317318
'app/scripts/controllers/metametrics.test.js',
318319
'app/scripts/controllers/permissions/**/*.test.js',
319-
'app/scripts/controllers/preferences.test.js',
320+
'app/scripts/controllers/preferences-controller.test.ts',
321+
'app/scripts/controllers/account-tracker-controller.test.ts',
320322
'app/scripts/lib/**/*.test.js',
321323
'app/scripts/metamask-controller.test.js',
322324
'app/scripts/migrations/*.test.js',

.github/workflows/fitness-functions.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ name: Fitness Functions CI
22

33
on:
44
pull_request:
5-
types: [assigned, opened, synchronize, reopened]
5+
types:
6+
- opened
7+
- reopened
8+
- synchronize
69

710
jobs:
811
build:
912
runs-on: ubuntu-latest
10-
1113
steps:
1214
- name: Checkout code
1315
uses: actions/checkout@v4

.github/workflows/main.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,15 @@ name: Main
22

33
on:
44
push:
5-
branches: [develop, master]
5+
branches:
6+
- develop
7+
- master
68
pull_request:
9+
types:
10+
- opened
11+
- reopened
12+
- synchronize
13+
merge_group:
714

815
jobs:
916
check-workflows:
@@ -21,11 +28,16 @@ jobs:
2128
run: ${{ steps.download-actionlint.outputs.executable }} -color
2229
shell: bash
2330

31+
run-tests:
32+
name: Run tests
33+
uses: ./.github/workflows/run-tests.yml
34+
2435
all-jobs-completed:
2536
name: All jobs completed
2637
runs-on: ubuntu-latest
2738
needs:
2839
- check-workflows
40+
- run-tests
2941
outputs:
3042
PASSED: ${{ steps.set-output.outputs.PASSED }}
3143
steps:
@@ -37,7 +49,8 @@ jobs:
3749
name: All jobs pass
3850
if: ${{ always() }}
3951
runs-on: ubuntu-latest
40-
needs: all-jobs-completed
52+
needs:
53+
- all-jobs-completed
4154
steps:
4255
- name: Check that all jobs have passed
4356
run: |

0 commit comments

Comments
 (0)