Skip to content

Commit 1ff3d42

Browse files
authored
Merge branch 'main' into tabs-styling-update
2 parents 9aa545c + a0a1f78 commit 1ff3d42

File tree

512 files changed

+23964
-6124
lines changed

Some content is hidden

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

512 files changed

+23964
-6124
lines changed

.circleci/config.yml

+39-33
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ version: 2.1
33
executors:
44
node-browsers-small:
55
docker:
6-
- image: cimg/node:22.13-browsers
6+
- image: cimg/node:22.14-browsers
77
resource_class: small
88
environment:
99
NODE_OPTIONS: --max_old_space_size=2048
1010
node-browsers-medium:
1111
docker:
12-
- image: cimg/node:22.13-browsers
12+
- image: cimg/node:22.14-browsers
1313
resource_class: medium
1414
environment:
1515
NODE_OPTIONS: --max_old_space_size=3072
@@ -21,7 +21,7 @@ executors:
2121
NODE_OPTIONS: --max_old_space_size=6144
2222
node-browsers-medium-plus:
2323
docker:
24-
- image: cimg/node:22.13-browsers
24+
- image: cimg/node:22.14-browsers
2525
resource_class: medium+
2626
environment:
2727
NODE_OPTIONS: --max_old_space_size=4096
@@ -159,6 +159,10 @@ workflows:
159159
requires:
160160
- prep-build-test
161161
- get-changed-files-with-git-diff
162+
- test-api-specs-multichain:
163+
requires:
164+
- prep-build-test-flask
165+
- get-changed-files-with-git-diff
162166
- test-e2e-chrome-multiple-providers:
163167
requires:
164168
- prep-build-test
@@ -272,26 +276,6 @@ workflows:
272276
requires:
273277
- prep-deps
274278

275-
locales_only:
276-
when:
277-
matches:
278-
pattern: /^l10n_crowdin_action$/
279-
value: << pipeline.git.branch >>
280-
jobs:
281-
- prep-deps
282-
- get-changed-files-with-git-diff
283-
- validate-locales-only:
284-
requires:
285-
- prep-deps
286-
- get-changed-files-with-git-diff
287-
- test-lint:
288-
requires:
289-
- prep-deps
290-
- all-tests-pass:
291-
requires:
292-
- test-lint
293-
- validate-locales-only
294-
295279
jobs:
296280
create_release_pull_request:
297281
executor: node-browsers-medium
@@ -364,7 +348,7 @@ jobs:
364348
at: .
365349
- run:
366350
name: Get changed files with git diff
367-
command: yarn git-diff-default-branch
351+
command: yarn tsx .circleci/scripts/git-diff-default-branch.ts
368352
- persist_to_workspace:
369353
root: .
370354
paths:
@@ -373,15 +357,6 @@ jobs:
373357
path: changed-files
374358
destination: changed-files
375359

376-
validate-locales-only:
377-
executor: node-browsers-small
378-
steps:
379-
- run: *shallow-git-clone-and-enable-vnc
380-
- run: sudo corepack enable
381-
- attach_workspace:
382-
at: .
383-
- run: yarn tsx .circleci/scripts/validate-locales-only.ts
384-
385360
prep-build:
386361
executor: node-linux-medium
387362
steps:
@@ -703,6 +678,37 @@ jobs:
703678
- store_test_results:
704679
path: test/test-results/e2e
705680

681+
test-api-specs-multichain:
682+
executor: node-browsers-medium-plus
683+
steps:
684+
- run: *shallow-git-clone-and-enable-vnc
685+
- run: sudo corepack enable
686+
- attach_workspace:
687+
at: .
688+
- run:
689+
name: Move test build to dist
690+
command: mv ./dist-test-flask ./dist
691+
- run:
692+
name: Move test zips to builds
693+
command: mv ./builds-test-flask ./builds
694+
- gh/install
695+
- run:
696+
name: test:api-specs-multichain
697+
command: .circleci/scripts/test-run-e2e.sh yarn test:api-specs-multichain
698+
no_output_timeout: 5m
699+
- run:
700+
name: Comment on PR
701+
command: |
702+
if [ -f html-report-multichain/index.html ]; then
703+
gh pr comment "${CIRCLE_PR_NUMBER}" --body ":x: Multichain API Spec Test Failed. View the report [here](https://output.circle-artifacts.com/output/job/${CIRCLE_WORKFLOW_JOB_ID}/artifacts/${CIRCLE_NODE_INDEX}/html-report-multichain/index.html)."
704+
else
705+
echo "Multichain API Spec Report not found!"
706+
fi
707+
when: on_fail
708+
- store_artifacts:
709+
path: html-report-multichain
710+
destination: html-report-multichain
711+
706712
test-api-specs:
707713
executor: node-browsers-medium-plus
708714
steps:

.circleci/scripts/bundle-stats-commit.sh

+27-32
Original file line numberDiff line numberDiff line change
@@ -38,43 +38,38 @@ git config --global user.email "[email protected]"
3838

3939
git config --global user.name "MetaMask Bot"
4040

41-
git clone [email protected]:MetaMask/extension_bundlesize_stats.git temp
42-
43-
{
44-
echo " '${CIRCLE_SHA1}': ";
45-
cat test-artifacts/chrome/bundle_size_stats.json;
46-
echo ", ";
47-
} >> temp/stats/bundle_size_data.temp.js
48-
49-
cp temp/stats/bundle_size_data.temp.js temp/stats/bundle_size_data.js
50-
51-
echo " }" >> temp/stats/bundle_size_data.js
52-
53-
if [ -f temp/stats/bundle_size_data.json ]; then
54-
# copy bundle_size_data.json in bundle_size_data.temp.json without last 2 lines
55-
head -$(($(wc -l < temp/stats/bundle_size_data.json) - 2)) temp/stats/bundle_size_data.json > bundle_size_stats.temp.json
56-
57-
{
58-
echo "},";
59-
echo "\"$CIRCLE_SHA1\":";
60-
cat test-artifacts/chrome/bundle_size_stats.json;
61-
echo "}";
62-
} >> bundle_size_stats.temp.json
63-
else
64-
{
65-
echo "{";
66-
echo "\"$CIRCLE_SHA1\":";
67-
cat test-artifacts/chrome/bundle_size_stats.json;
68-
echo "}";
69-
} > bundle_size_stats.temp.json
41+
git clone --depth=1 [email protected]:MetaMask/extension_bundlesize_stats.git temp
42+
43+
BUNDLE_SIZE_FILE="test-artifacts/chrome/bundle_size_stats.json"
44+
STATS_FILE="temp/stats/bundle_size_data.json"
45+
TEMP_FILE="temp/stats/bundle_size_data.temp.json"
46+
47+
# Ensure the JSON file exists
48+
if [[ ! -f "$STATS_FILE" ]]; then
49+
echo "{}" > "$STATS_FILE"
7050
fi
7151

72-
jq . bundle_size_stats.temp.json > temp/stats/bundle_size_data.json
73-
rm bundle_size_stats.temp.json
52+
# Validate JSON files before modification
53+
jq . "$STATS_FILE" > /dev/null || { echo "Error: Existing stats JSON is invalid"; exit 1; }
54+
jq . "$BUNDLE_SIZE_FILE" > /dev/null || { echo "Error: New bundle size JSON is invalid"; exit 1; }
55+
56+
# Check if the SHA already exists in the stats file
57+
if jq -e "has(\"$CIRCLE_SHA1\")" "$STATS_FILE" > /dev/null; then
58+
echo "SHA $CIRCLE_SHA1 already exists in stats file. No new commit needed."
59+
exit 0
60+
fi
61+
62+
# Append new bundle size data correctly using jq
63+
jq --arg sha "$CIRCLE_SHA1" --argjson data "$(cat "$BUNDLE_SIZE_FILE")" \
64+
'. + {($sha): $data}' "$STATS_FILE" > "$TEMP_FILE"
65+
66+
# Overwrite the original JSON file with the corrected version
67+
mv "$TEMP_FILE" "$STATS_FILE"
7468

7569
cd temp
7670

77-
git add .
71+
# Only add the JSON file
72+
git add stats/bundle_size_data.json
7873

7974
git commit --message "Adding bundle size at commit: ${CIRCLE_SHA1}"
8075

.depcheckrc.yml

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ ignores:
2323
- '@metamask/forwarder'
2424
- '@metamask/phishing-warning' # statically hosted as part of some e2e tests
2525
- '@metamask/test-dapp'
26+
- '@metamask/test-dapp-multichain'
2627
- '@metamask/design-tokens' # Only imported in index.css
2728
- '@tsconfig/node22' # required dynamically by TS, used in tsconfig.json
2829
- '@sentry/cli' # invoked as `sentry-cli`

.github/CODEOWNERS

+3
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,6 @@ ui/components/app/nfts-items @MetaMask/metamask-assets
135135
ui/components/app/nfts-tab @MetaMask/metamask-assets
136136
ui/components/ui/deprecated-networks @MetaMask/metamask-assets
137137
ui/components/ui/nft-collection-image @MetaMask/metamask-assets
138+
139+
# Extension Platform
140+
yarnrc.yml @MetaMask/extension-platform
+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
import fs from 'fs';
2+
import path from 'path';
3+
import { context, getOctokit } from '@actions/github';
4+
import * as core from '@actions/core';
5+
6+
// Get PR number from GitHub Actions environment variables
7+
const PR_NUMBER = context.payload.pull_request?.number;
8+
9+
const CHANGED_FILES_DIR = 'changed-files';
10+
11+
const octokit = getOctokit(process.env.GITHUB_TOKEN || '');
12+
13+
type PRInfo = {
14+
base: {
15+
ref: string;
16+
};
17+
body: string;
18+
labels: { name: string }[];
19+
};
20+
21+
/**
22+
* Get JSON info about the given pull request using Octokit
23+
*
24+
* @returns PR information from GitHub
25+
*/
26+
async function getPrInfo(): Promise<PRInfo | null> {
27+
if (!PR_NUMBER) {
28+
return null;
29+
}
30+
31+
const { owner, repo } = context.repo;
32+
33+
return (
34+
await octokit.request(`GET /repos/${owner}/${repo}/pulls/${PR_NUMBER}`)
35+
).data;
36+
}
37+
38+
/**
39+
* Get the list of files changed in the pull request using GraphQL
40+
*
41+
* @returns List of files changed in the PR
42+
*/
43+
async function getPrFilesChanged() {
44+
const { owner, repo } = context.repo;
45+
46+
const response = await octokit.graphql({
47+
query: `
48+
{
49+
repository(owner: "${owner}", name: "${repo}") {
50+
pullRequest(number: ${PR_NUMBER}) {
51+
files(first: 100) {
52+
nodes {
53+
changeType
54+
path,
55+
}
56+
}
57+
}
58+
}
59+
}`,
60+
});
61+
62+
return response.repository.pullRequest.files.nodes;
63+
}
64+
65+
function writePrBodyAndInfoToFile(prInfo: PRInfo) {
66+
const prBodyPath = path.resolve(CHANGED_FILES_DIR, 'pr-body.txt');
67+
const labels = prInfo.labels.map((label) => label.name).join(', ');
68+
const updatedPrBody = `PR labels: {${labels}}\nPR base: {${
69+
prInfo.base.ref
70+
}}\n${prInfo.body.trim()}`;
71+
fs.writeFileSync(prBodyPath, updatedPrBody);
72+
core.info(`PR body and info saved to ${prBodyPath}`);
73+
}
74+
75+
/**
76+
* Main run function, stores the output of git diff and the body of the matching PR to a file.
77+
*
78+
* @returns Returns a promise that resolves when the git diff output and PR body is successfully stored.
79+
*/
80+
async function storeGitDiffOutputAndPrBody() {
81+
try {
82+
// Create the directory
83+
fs.mkdirSync(CHANGED_FILES_DIR, { recursive: true });
84+
85+
core.info(`Determining whether to run git diff...`);
86+
if (!PR_NUMBER) {
87+
core.info('Not a PR, skipping git diff');
88+
return;
89+
}
90+
91+
const prInfo = await getPrInfo();
92+
93+
const baseRef = prInfo?.base.ref;
94+
if (!baseRef) {
95+
core.info('Not a PR, skipping git diff');
96+
return;
97+
}
98+
// We perform git diff even if the PR base is not main or skip-e2e-quality-gate label is applied
99+
// because we rely on the git diff results for other jobs
100+
core.info('Attempting to get git diff...');
101+
const diffOutput = JSON.stringify(await getPrFilesChanged());
102+
core.info(diffOutput);
103+
104+
// Store the output of git diff
105+
const outputPath = path.resolve(CHANGED_FILES_DIR, 'changed-files.json');
106+
fs.writeFileSync(outputPath, diffOutput);
107+
core.info(`Git diff results saved to ${outputPath}`);
108+
109+
writePrBodyAndInfoToFile(prInfo);
110+
111+
core.info('success');
112+
} catch (error: any) {
113+
core.setFailed(`Failed to process git diff: ${error.message}`);
114+
}
115+
}
116+
117+
// If main module (i.e. this is the TS file that was run directly)
118+
if (require.main === module) {
119+
storeGitDiffOutputAndPrBody();
120+
}

0 commit comments

Comments
 (0)