Skip to content

Commit 26aae33

Browse files
authored
Merge pull request #28805 from MetaMask/Version-v12.9.0
chore: Version v12.9.0
2 parents 884d810 + 8d86aea commit 26aae33

File tree

736 files changed

+43461
-14110
lines changed

Some content is hidden

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

736 files changed

+43461
-14110
lines changed

.circleci/config.yml

+35-6
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:20.17-browsers
6+
- image: cimg/node:20.18-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:20.17-browsers
12+
- image: cimg/node:20.18-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:20.17-browsers
24+
- image: cimg/node:20.18-browsers
2525
resource_class: medium+
2626
environment:
2727
NODE_OPTIONS: --max_old_space_size=4096
@@ -103,9 +103,11 @@ workflows:
103103
test_and_release:
104104
when:
105105
not:
106-
matches:
107-
pattern: /^l10n_crowdin_action$/
108-
value: << pipeline.git.branch >>
106+
or:
107+
- matches:
108+
pattern: /^l10n_crowdin_action$/
109+
value: << pipeline.git.branch >>
110+
- equal: [rerun-from-failed, << pipeline.schedule.name >>]
109111
jobs:
110112
- create_release_pull_request:
111113
<<: *rc_branch_only
@@ -176,6 +178,7 @@ workflows:
176178
- prep-build-test-mmi:
177179
requires:
178180
- prep-deps
181+
- check-mmi-trigger
179182
- prep-build-test-mmi-playwright:
180183
requires:
181184
- prep-deps
@@ -356,6 +359,18 @@ workflows:
356359
requires:
357360
- prep-build-ts-migration-dashboard
358361

362+
rerun-from-failed:
363+
when:
364+
equal: [rerun-from-failed, << pipeline.schedule.name >>]
365+
jobs:
366+
- prep-deps
367+
- rerun-workflows-from-failed:
368+
filters:
369+
branches:
370+
only: develop
371+
requires:
372+
- prep-deps
373+
359374
locales_only:
360375
when:
361376
matches:
@@ -789,6 +804,7 @@ jobs:
789804
- run: corepack enable
790805
- attach_workspace:
791806
at: .
807+
- run: *check-mmi-trigger
792808
- run:
793809
name: Build extension for testing
794810
command: yarn build:test:mmi
@@ -930,6 +946,17 @@ jobs:
930946
paths:
931947
- development/ts-migration-dashboard/build/final
932948

949+
rerun-workflows-from-failed:
950+
executor: node-browsers-small
951+
steps:
952+
- run: *shallow-git-clone-and-enable-vnc
953+
- run: sudo corepack enable
954+
- attach_workspace:
955+
at: .
956+
- run:
957+
name: Rerun workflows from failed
958+
command: yarn ci-rerun-from-failed
959+
933960
test-yarn-dedupe:
934961
executor: node-browsers-small
935962
steps:
@@ -1172,6 +1199,7 @@ jobs:
11721199
- run: sudo corepack enable
11731200
- attach_workspace:
11741201
at: .
1202+
- run: *check-mmi-trigger
11751203
- run:
11761204
name: Move test build to dist
11771205
command: mv ./dist-test-mmi ./dist
@@ -1261,6 +1289,7 @@ jobs:
12611289
- run: sudo corepack enable
12621290
- attach_workspace:
12631291
at: .
1292+
- run: *check-mmi-trigger
12641293
- run:
12651294
name: Move test build to dist
12661295
command: mv ./dist-test-mmi ./dist

.circleci/scripts/check_mmi_trigger.sh

+6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ if [ -z "$CIRCLE_PULL_REQUEST" ] || [ -z "$GITHUB_TOKEN" ]; then
99
exit 0
1010
fi
1111

12+
if [[ $CIRCLE_BRANCH = 'develop' || $CIRCLE_BRANCH = 'master' || $CIRCLE_BRANCH =~ ^Version-v[0-9.]* ]]; then
13+
echo "Long-running branch detected, running MMI tests."
14+
echo "run_mmi_tests=true" > mmi_trigger.env
15+
exit 0
16+
fi
17+
1218
# Extract PR number from the pull request URL
1319
PR_NUMBER=$(echo "$CIRCLE_PULL_REQUEST" | awk -F'/' '{print $NF}')
1420

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
const CIRCLE_TOKEN = process.env.API_V2_TOKEN;
2+
3+
interface Actor {
4+
login: string;
5+
avatar_url: string | null;
6+
}
7+
8+
interface Trigger {
9+
received_at: string;
10+
type: string;
11+
actor: Actor;
12+
}
13+
14+
interface VCS {
15+
origin_repository_url: string;
16+
target_repository_url: string;
17+
revision: string;
18+
provider_name: string;
19+
branch: string;
20+
}
21+
22+
interface WorkflowItem {
23+
id: string;
24+
errors: string[];
25+
project_slug: string;
26+
updated_at: string;
27+
number: number;
28+
state: string;
29+
created_at: string;
30+
trigger: Trigger;
31+
vcs: VCS;
32+
}
33+
34+
interface CircleCIResponse {
35+
next_page_token: string | null;
36+
items: WorkflowItem[];
37+
}
38+
39+
interface WorkflowStatusItem {
40+
pipeline_id: string;
41+
id: string;
42+
name: string;
43+
project_slug: string;
44+
tag?: string;
45+
status: string;
46+
started_by: string;
47+
pipeline_number: number;
48+
created_at: string;
49+
stopped_at: string;
50+
}
51+
52+
interface WorkflowStatusResponse {
53+
next_page_token: string | null;
54+
items: WorkflowStatusItem[];
55+
}
56+
57+
/**
58+
* Fetches the last 20 CircleCI workflows for the given branch.
59+
* Note: the API returns the first 20 workflows by default.
60+
* If we wanted to get older workflows, we would need to use the 'page-token' we would get in the first response
61+
* and perform a subsequent request with the 'page-token' parameter.
62+
* This seems unnecessary as of today, as the amount of daily PRs merged to develop is not that high.
63+
*
64+
* @returns {Promise<WorkflowItem[]>} A promise that resolves to an array of workflow items.
65+
* @throws Will throw an error if the CircleCI token is not defined or if the HTTP request fails.
66+
*/
67+
async function getCircleCiWorkflowsByBranch(branch: string): Promise<WorkflowItem[]> {
68+
if (!CIRCLE_TOKEN) {
69+
throw new Error('CircleCI token is not defined');
70+
}
71+
72+
const url = `https://circleci.com/api/v2/project/github/${process.env.CIRCLE_PROJECT_USERNAME}/${process.env.CIRCLE_PROJECT_REPONAME}/pipeline?branch=${branch}`;
73+
const options = {
74+
method: 'GET',
75+
headers: {
76+
'Content-Type': 'application/json',
77+
}
78+
};
79+
80+
try {
81+
const response = await fetch(url, options);
82+
if (!response.ok) {
83+
const errorBody = await response.text();
84+
console.error('HTTP error response:', errorBody);
85+
throw new Error(`HTTP error! status: ${response.status}`);
86+
}
87+
const body = await response.json();
88+
console.log('Circle Ci workflows fetched successfully!');
89+
return body.items;
90+
} catch (error) {
91+
console.error('Error:', error);
92+
throw error;
93+
}
94+
}
95+
96+
/**
97+
* Fetches the status of a specific CircleCI workflow.
98+
*
99+
* @param {string} workflowId - The ID of the workflow to fetch the status for.
100+
* @returns {Promise<WorkflowStatusResponse>} A promise that resolves to the workflow status response.
101+
* @throws Will throw an error if the CircleCI token is not defined or if the HTTP request fails.
102+
*/
103+
async function getWorkflowStatusById(workflowId: string): Promise<WorkflowStatusResponse> {
104+
if (!CIRCLE_TOKEN) {
105+
throw new Error('CircleCI token is not defined');
106+
}
107+
108+
const url = `https://circleci.com/api/v2/pipeline/${workflowId}/workflow`;
109+
const options = {
110+
method: 'GET',
111+
headers: {
112+
'Content-Type': 'application/json',
113+
}
114+
};
115+
116+
try {
117+
console.log(`Fetching workflow ${workflowId}...`);
118+
119+
const response = await fetch(url, options);
120+
if (!response.ok) {
121+
const errorBody = await response.text();
122+
console.error('HTTP error response:', errorBody);
123+
throw new Error(`HTTP error! status: ${response.status}`);
124+
}
125+
const workflowStatus = await response.json();
126+
127+
console.log(`Number of runs: ${workflowStatus.items.length}`);
128+
console.log(`Workflow status from last run: ${workflowStatus.items[0].status}`);
129+
130+
return workflowStatus;
131+
132+
} catch (error) {
133+
console.error('Error:', error);
134+
throw error;
135+
}
136+
}
137+
138+
/**
139+
* Reruns a CircleCI workflow by its ID.
140+
*
141+
* @param {string} workflowId - The ID of the workflow to rerun.
142+
* @throws Will throw an error if the CircleCI token is not defined or if the HTTP request fails.
143+
*/
144+
async function rerunWorkflowById(workflowId: string) {
145+
if (!CIRCLE_TOKEN) {
146+
throw new Error('CircleCI token is not defined');
147+
}
148+
149+
const url = `https://circleci.com/api/v2/workflow/${workflowId}/rerun`;
150+
const options = {
151+
method: 'POST',
152+
headers: {
153+
'Content-Type': 'application/json',
154+
'Circle-Token': CIRCLE_TOKEN,
155+
},
156+
body: JSON.stringify({
157+
enable_ssh: false,
158+
from_failed: true,
159+
sparse_tree: false, // mutually exclusive with the from_failed parameter
160+
})
161+
};
162+
163+
try {
164+
console.log(`Rerunning workflow ${workflowId}...`);
165+
const response = await fetch(url, options);
166+
if (!response.ok) {
167+
const errorBody = await response.text();
168+
console.error('HTTP error response:', errorBody);
169+
throw new Error(`HTTP error! status: ${response.status}`);
170+
}
171+
const body = await response.json();
172+
console.log('Workflow rerun successfully!');
173+
console.log(body);
174+
} catch (error) {
175+
console.error('Error:', error);
176+
}
177+
}
178+
179+
/**
180+
* Re-runs failed CircleCI workflows from develop branch.
181+
* The workflow will only be re-runed if:
182+
* 1. It has the status of 'failed'
183+
* 2. It has only been run once
184+
* 3. It is among the most recent 20 workflows
185+
* 4. It was triggered by the 'github-merge-queue[bot]' user
186+
*
187+
* @throws Will throw an error if fetching the workflows or re-running a workflow fails.
188+
*/
189+
async function rerunFailedWorkflowsFromDevelop() {
190+
console.log('Getting Circle Ci workflows from develop branch...');
191+
const workflows = await getCircleCiWorkflowsByBranch('develop');
192+
193+
console.log('Assessing if any of the workflows needs to be rerun...');
194+
for (const item of workflows) {
195+
if (item.trigger.actor.login === 'github-merge-queue[bot]') {
196+
const workflowStatus = await getWorkflowStatusById(item.id);
197+
198+
if (workflowStatus.items.length === 1 && workflowStatus.items[0].status === 'failed') {
199+
await rerunWorkflowById(workflowStatus.items[0].id);
200+
console.log(`Rerun workflow with ID: ${workflowStatus.items[0].id}`);
201+
}
202+
}
203+
}
204+
console.log('Task completed successfully!');
205+
}
206+
207+
rerunFailedWorkflowsFromDevelop()
208+
.catch((error) => {
209+
console.error(error);
210+
process.exitCode = 1;
211+
});

.github/workflows/sonarcloud.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ name: SonarCloud
88
on:
99
workflow_run:
1010
workflows:
11-
- Run tests
11+
- Main
1212
types:
1313
- completed
1414

.nvmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v20.17
1+
v20.18

0 commit comments

Comments
 (0)