Skip to content

Commit

Permalink
Merge branch 'main' into chloe-tests-dapp
Browse files Browse the repository at this point in the history
  • Loading branch information
chloeYue authored Feb 7, 2025
2 parents 2823ea7 + 335b3bb commit 84ea252
Show file tree
Hide file tree
Showing 424 changed files with 6,084 additions and 24,174 deletions.
57 changes: 40 additions & 17 deletions .github/scripts/check-template-and-add-labels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,17 @@ enum RegressionStage {
DevelopmentMain,
Testing,
Beta,
Production
Production,
}

const knownBots = ["metamaskbot", "dependabot", "github-actions", "sentry-io", "devin-ai-integration"];
const knownBots = [
'metamaskbot',
'dependabot',
'github-actions',
'sentry-io',
'devin-ai-integration',
'runway-github',
];

main().catch((error: Error): void => {
console.error(error);
Expand Down Expand Up @@ -83,7 +90,10 @@ async function main(): Promise<void> {
}

// If author is not part of the MetaMask organisation
if (!knownBots.includes(labelable?.author) && !(await userBelongsToMetaMaskOrg(octokit, labelable?.author))) {
if (
!knownBots.includes(labelable?.author) &&
!(await userBelongsToMetaMaskOrg(octokit, labelable?.author))
) {
// Add external contributor label to the issue
await addLabelToLabelable(octokit, labelable, externalContributorLabel);
}
Expand All @@ -95,16 +105,21 @@ async function main(): Promise<void> {

// If labelable's author is a bot we skip the template checks as bots don't use templates
if (knownBots.includes(labelable.author)) {
console.log(`${labelable.type === LabelableType.PullRequest ? 'PR' : 'Issue'} was created by a bot (${labelable.author}). Skip template checks.`);
console.log(
`${
labelable.type === LabelableType.PullRequest ? 'PR' : 'Issue'
} was created by a bot (${labelable.author}). Skip template checks.`,
);
process.exit(0); // Stop the process and exit with a success status code
}

if (labelable.type === LabelableType.Issue) {

// If labelable is a flaky test report, no template is needed (we just add a link to circle.ci in the description), we skip the template checks
const flakyTestsLabelFound = findLabel(labelable, flakyTestsLabel);
if (flakyTestsLabelFound?.id) {
console.log(`Issue ${labelable?.number} was created to report a flaky test. Issue's description doesn't need to match issue template in that case as the issue's description only includes a link redirecting to circle.ci. Skip template checks.`);
console.log(
`Issue ${labelable?.number} was created to report a flaky test. Issue's description doesn't need to match issue template in that case as the issue's description only includes a link redirecting to circle.ci. Skip template checks.`,
);
await removeLabelFromLabelableIfPresent(
octokit,
labelable,
Expand All @@ -130,7 +145,6 @@ async function main(): Promise<void> {

// Add regression label to the bug report issue
addRegressionLabelToIssue(octokit, labelable);

} else {
const errorMessage =
"Issue body does not match any of expected templates ('general-issue.yml' or 'bug-report.yml').\n\nMake sure issue's body includes all section titles.\n\nSections titles are listed here: https://github.com/MetaMask/metamask-extension/blob/main/.github/scripts/shared/template.ts#L14-L37";
Expand All @@ -152,8 +166,7 @@ async function main(): Promise<void> {
invalidPullRequestTemplateLabel,
);
} else {
const errorMessage =
`PR body does not match template ('pull-request-template.md').\n\nMake sure PR's body includes all section titles.\n\nSections titles are listed here: https://github.com/MetaMask/metamask-extension/blob/main/.github/scripts/shared/template.ts#L40-L47`;
const errorMessage = `PR body does not match template ('pull-request-template.md').\n\nMake sure PR's body includes all section titles.\n\nSections titles are listed here: https://github.com/MetaMask/metamask-extension/blob/main/.github/scripts/shared/template.ts#L40-L47`;
console.log(errorMessage);

// Add label to indicate PR body doesn't match template
Expand Down Expand Up @@ -269,7 +282,10 @@ async function addRegressionLabelToIssue(
);

// Craft regression label to add
const regressionLabel: Label = craftRegressionLabel(regressionStage, releaseVersion);
const regressionLabel: Label = craftRegressionLabel(
regressionStage,
releaseVersion,
);

let regressionLabelFound: boolean = false;
const regressionLabelsToBeRemoved: {
Expand All @@ -292,9 +308,7 @@ async function addRegressionLabelToIssue(
`Issue ${issue?.number} already has ${regressionLabel.name} label.`,
);
} else {
console.log(
`Add ${regressionLabel.name} label to issue ${issue?.number}.`,
);
console.log(`Add ${regressionLabel.name} label to issue ${issue?.number}.`);
await addLabelToLabelable(octokit, issue, regressionLabel);
}

Expand Down Expand Up @@ -333,7 +347,10 @@ async function userBelongsToMetaMaskOrg(
}

// This function crafts appropriate label, corresponding to regression stage and release version.
function craftRegressionLabel(regressionStage: RegressionStage | undefined, releaseVersion: string | undefined): Label {
function craftRegressionLabel(
regressionStage: RegressionStage | undefined,
releaseVersion: string | undefined,
): Label {
switch (regressionStage) {
case RegressionStage.DevelopmentFeature:
return {
Expand All @@ -353,21 +370,27 @@ function craftRegressionLabel(regressionStage: RegressionStage | undefined, rele
return {
name: `regression-RC-${releaseVersion || '*'}`,
color: '744C11', // orange
description: releaseVersion ? `Regression bug that was found in release candidate (RC) for release ${releaseVersion}` : `TODO: Unknown release version. Please replace with correct 'regression-RC-x.y.z' label, where 'x.y.z' is the number of the release where bug was found.`,
description: releaseVersion
? `Regression bug that was found in release candidate (RC) for release ${releaseVersion}`
: `TODO: Unknown release version. Please replace with correct 'regression-RC-x.y.z' label, where 'x.y.z' is the number of the release where bug was found.`,
};

case RegressionStage.Beta:
return {
name: `regression-beta-${releaseVersion || '*'}`,
color: 'D94A83', // pink
description: releaseVersion ? `Regression bug that was found in beta in release ${releaseVersion}` : `TODO: Unknown release version. Please replace with correct 'regression-beta-x.y.z' label, where 'x.y.z' is the number of the release where bug was found.`,
description: releaseVersion
? `Regression bug that was found in beta in release ${releaseVersion}`
: `TODO: Unknown release version. Please replace with correct 'regression-beta-x.y.z' label, where 'x.y.z' is the number of the release where bug was found.`,
};

case RegressionStage.Production:
return {
name: `regression-prod-${releaseVersion || '*'}`,
color: '5319E7', // violet
description: releaseVersion ? `Regression bug that was found in production in release ${releaseVersion}` : `TODO: Unknown release version. Please replace with correct 'regression-prod-x.y.z' label, where 'x.y.z' is the number of the release where bug was found.`,
description: releaseVersion
? `Regression bug that was found in production in release ${releaseVersion}`
: `TODO: Unknown release version. Please replace with correct 'regression-prod-x.y.z' label, where 'x.y.z' is the number of the release where bug was found.`,
};

default:
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/update-lavamoat-policies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:
matrix:
# Ensure this is synchronized with the list below in the "commit-updated-policies" job
# and with the build type list in `builds.yml`
build-type: [main, beta, flask]
build-type: [main, beta, flask, mmi]
name: Update LavaMoat ${{ matrix.build-type }} application policy
runs-on: ubuntu-latest
needs:
Expand Down Expand Up @@ -154,7 +154,7 @@ jobs:
path: lavamoat/build-system
key: cache-build-${{ needs.prepare.outputs.COMMIT_SHA }}
fail-on-cache-miss: true
# One restore step per build type: [main, beta, flask]
# One restore step per build type: [main, beta, flask, mmi]
# Ensure this is synchronized with the list above in the "update-lavamoat-webapp-policy" job
# and with the build type list in `builds.yml`
- name: Restore main application policy
Expand All @@ -175,6 +175,12 @@ jobs:
path: lavamoat/browserify/flask
key: cache-flask-${{ needs.prepare.outputs.COMMIT_SHA }}
fail-on-cache-miss: true
- name: Restore MMI application policy
uses: actions/cache/restore@v4
with:
path: lavamoat/browserify/mmi
key: cache-mmi-${{ needs.prepare.outputs.COMMIT_SHA }}
fail-on-cache-miss: true
- name: Check whether there are policy changes
id: policy-changes
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/validate-lavamoat-policy-webapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
build-type: [main, beta, flask]
build-type: [main, beta, flask, mmi]
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down
12 changes: 12 additions & 0 deletions .madgerc
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
{
"excludeRegExp": [
"/.[^/]*\/test\/.[^/]*/u",
"/.[^/]*\/tests\/.[^/]*/u",
"/.[^/]*\/[^/]*.test.[^/]*/u",
"/.[^/]*\/[^/]*.spec.[^/]*/u",
"/.[^/]*\/stories\/.[^/]*/u",
"/.[^/]*\/storybook\/.[^/]*/u",
"/.[^/]*\/[^/]*.stories.[^/]*/u"
],
"fileExtensions": ["js", "jsx", "ts", "tsx"],
"tsConfig": "tsconfig.json",
"webpackConfig": "webpack.config.js",
"detectiveOptions": {
"es6": {
"skipTypeImports": true
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
diff --git a/dist/assetsUtil.cjs b/dist/assetsUtil.cjs
index 017fb94055b64f99c75f8d54b763a501bdd03e97..34396ba143e3ebcb04fa2c80f7a35d1abd06710e 100644
--- a/dist/assetsUtil.cjs
+++ b/dist/assetsUtil.cjs
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
+function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }
exports.getKeyByValue = exports.fetchTokenContractExchangeRates = exports.reduceInBatchesSerially = exports.divideIntoBatches = exports.ethersBigNumberToBN = exports.addUrlProtocolPrefix = exports.getFormattedIpfsUrl = exports.getIpfsCIDv1AndPath = exports.removeIpfsProtocolPrefix = exports.isTokenListSupportedForNetwork = exports.isTokenDetectionSupportedForNetwork = exports.SupportedStakedBalanceNetworks = exports.SupportedTokenDetectionNetworks = exports.formatIconUrlWithProxy = exports.formatAggregatorNames = exports.hasNewCollectionFields = exports.compareNftMetadata = exports.TOKEN_PRICES_BATCH_SIZE = void 0;
const controller_utils_1 = require("@metamask/controller-utils");
const utils_1 = require("@metamask/utils");
@@ -233,7 +234,7 @@ async function getIpfsCIDv1AndPath(ipfsUrl) {
const index = url.indexOf('/');
const cid = index !== -1 ? url.substring(0, index) : url;
const path = index !== -1 ? url.substring(index) : undefined;
- const { CID } = await import("multiformats");
+ const { CID } = _interopRequireWildcard(require("multiformats"));
// We want to ensure that the CID is v1 (https://docs.ipfs.io/concepts/content-addressing/#identifier-formats)
// because most cid v0s appear to be incompatible with IPFS subdomains
return {
Loading

0 comments on commit 84ea252

Please sign in to comment.