Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
aefhm authored Dec 5, 2024
2 parents 443e801 + a907380 commit f156e35
Show file tree
Hide file tree
Showing 1,048 changed files with 51,562 additions and 28,006 deletions.
2 changes: 2 additions & 0 deletions .e2e.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ export MM_TEST_ACCOUNT_SRP='word1 word... word12'
export MM_TEST_ACCOUNT_ADDRESS='0x...'
export MM_TEST_ACCOUNT_PRIVATE_KEY=''
export IS_TEST="true"
# Temporary mechanism to enable security alerts API prior to release.
export MM_SECURITY_ALERTS_API_ENABLED="true"
27 changes: 27 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,33 @@ module.exports = {
'@metamask/design-tokens/color-no-hex': 'off',
},
},
{
files: [
'app/components/UI/Name/**/*.{js,ts,tsx}',
'app/components/hooks/DisplayName/**/*.{js,ts,tsx}'
],
rules: {
'no-restricted-syntax': [
'error',
{
selector: `ImportSpecifier[imported.name=/${[
'selectChainId',
'selectNetworkClientId',
'selectNetworkStatus',
'selectNickname',
'selectProviderConfig',
'selectProviderType',
'selectRpcUrl',
'selectSelectedNetworkClientId',
'selectTicker'
]
.map((method) => `(${method})`)
.join('|')}/]`,
message: 'Avoid using global network selectors in confirmations',
},
],
},
},
],

globals: {
Expand Down
84 changes: 47 additions & 37 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -7,54 +7,65 @@
app/component-library/ @MetaMask/design-system-engineers

# Platform Team
patches/ @MetaMask/mobile-platform
app/core/Engine.ts @MetaMask/mobile-platform
app/core/Engine.test.js @MetaMask/mobile-platform
app/core/Analytics/ @MetaMask/mobile-platform
app/util/metrics/ @MetaMask/mobile-platform
app/components/hooks/useMetrics/ @MetaMask/mobile-platform

# Supply Chain Team
bitrise.yml @MetaMask/supply-chain @MetaMask/mobile-platform
yarn.lock @MetaMask/supply-chain @MetaMask/mobile-platform
ios/Podfile.lock @MetaMask/supply-chain @MetaMask/mobile-platform
.github/CODEOWNERS @MetaMask/mobile-platform
patches/ @MetaMask/mobile-platform
app/core/Engine/Engine.ts @MetaMask/mobile-platform
app/core/Engine/Engine.test.ts @MetaMask/mobile-platform
app/core/Engine/index.ts @MetaMask/mobile-platform
app/core/Engine/types.ts @MetaMask/mobile-platform
app/core/Engine/controllers/RemoteFeatureFlagController/ @MetaMask/mobile-platform
app/core/Analytics/ @MetaMask/mobile-platform
app/util/metrics/ @MetaMask/mobile-platform
app/components/hooks/useMetrics/ @MetaMask/mobile-platform
app/selectors/featureFlagController/* @MetaMask/mobile-platform
app/selectors/featureFlagController/minimumAppVersion/ @MetaMask/mobile-platform
app/store/migrations/ @MetaMask/mobile-platform
bitrise.yml @MetaMask/mobile-platform
yarn.lock @MetaMask/mobile-platform
ios/Podfile.lock @MetaMask/mobile-platform

# Ramps Team
app/components/UI/Ramp/ @MetaMask/ramp @MetaMask/mobile-platform
app/reducers/fiatOrders/ @MetaMask/ramp @MetaMask/mobile-platform
app/components/UI/Ramp/ @MetaMask/ramp
app/reducers/fiatOrders/ @MetaMask/ramp

# Confirmation Team
app/components/Views/confirmations @MetaMask/confirmations @MetaMask/mobile-platform
ppom @MetaMask/confirmations @MetaMask/mobile-platform
app/components/Views/confirmations @MetaMask/confirmations
ppom @MetaMask/confirmations

# All below files are maintained by the SDK team because they contain SDK related code, WalletConnect integrations, or critical SDK flows.
app/actions/sdk @MetaMask/sdk-devs @MetaMask/mobile-platform
app/components/Approvals/WalletConnectApproval @MetaMask/sdk-devs @MetaMask/mobile-platform
app/components/Views/SDK @MetaMask/sdk-devs @MetaMask/mobile-platform
app/components/Views/WalletConnectSessions @MetaMask/sdk-devs @MetaMask/mobile-platform
app/core/BackgroundBridge/WalletConnectPort.ts @MetaMask/sdk-devs @MetaMask/mobile-platform
app/core/DeeplinkManager @MetaMask/sdk-devs @MetaMask/mobile-platform
app/core/RPCMethods/RPCMethodMiddleware.ts @MetaMask/sdk-devs @MetaMask/mobile-platform
app/core/SDKConnect @MetaMask/sdk-devs @MetaMask/mobile-platform
app/core/WalletConnect @MetaMask/sdk-devs @MetaMask/mobile-platform
app/reducers/sdk @MetaMask/sdk-devs @MetaMask/mobile-platform
app/util/walletconnect.js @MetaMask/sdk-devs @MetaMask/mobile-platform
app/actions/sdk @MetaMask/sdk-devs
app/components/Approvals/WalletConnectApproval @MetaMask/sdk-devs
app/components/Views/SDK @MetaMask/sdk-devs
app/components/Views/WalletConnectSessions @MetaMask/sdk-devs
app/core/BackgroundBridge/WalletConnectPort.ts @MetaMask/sdk-devs
app/core/DeeplinkManager @MetaMask/sdk-devs
app/core/RPCMethods/RPCMethodMiddleware.ts @MetaMask/sdk-devs
app/core/SDKConnect @MetaMask/sdk-devs
app/core/WalletConnect @MetaMask/sdk-devs
app/reducers/sdk @MetaMask/sdk-devs
app/util/walletconnect.js @MetaMask/sdk-devs

# Accounts Team
app/core/Encryptor/ @MetaMask/accounts-engineers
app/core/Encryptor/ @MetaMask/accounts-engineers
app/core/Engine/controllers/accounts @MetaMask/accounts-engineers

# Swaps Team
app/components/UI/Swaps @MetaMask/swaps-engineers @MetaMask/mobile-platform
app/components/UI/Swaps @MetaMask/swaps-engineers

# Notifications Team
app/components/Views/Notifications @MetaMask/notifications @MetaMask/mobile-platform
app/components/Views/Settings/NotificationsSettings @MetaMask/notifications @MetaMask/mobile-platform
app/components/UI/Notifications @MetaMask/notifications @MetaMask/mobile-platform
app/reducers/notification @MetaMask/notifications @MetaMask/mobile-platform
app/actions/notification @MetaMask/notifications @MetaMask/mobile-platform
app/selectors/notification @MetaMask/notifications @MetaMask/mobile-platform
app/util/notifications @MetaMask/notifications @MetaMask/mobile-platform
app/store/util/notifications @MetaMask/notifications @MetaMask/mobile-platform
app/components/Views/Notifications @MetaMask/notifications
app/components/Views/Settings/NotificationsSettings @MetaMask/notifications
app/components/UI/Notifications @MetaMask/notifications
app/reducers/notification @MetaMask/notifications
app/actions/notification @MetaMask/notifications
app/selectors/notification @MetaMask/notifications
app/util/notifications @MetaMask/notifications
app/store/util/notifications @MetaMask/notifications

# Identity Team
app/actions/identity @MetaMask/identity
app/util/identity @MetaMask/identity
app/components/UI/ProfileSyncing @MetaMask/identity

# LavaMoat Team
ses.cjs @MetaMask/supply-chain
Expand Down Expand Up @@ -112,7 +123,6 @@ app/components/Views/QRAccountDisplay @MetaMask/wallet-ux
app/components/Views/QRScanner @MetaMask/wallet-ux
app/components/Views/Settings @MetaMask/wallet-ux
app/components/Views/TermsAndConditions @MetaMask/wallet-ux

app/reducers/experimentalSettings @MetaMask/wallet-ux
app/reducers/modals @MetaMask/wallet-ux
app/reducers/navigation @MetaMask/wallet-ux
Expand Down
104 changes: 98 additions & 6 deletions .github/scripts/bitrise/run-bitrise-e2e-check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,33 @@ main().catch((error: Error): void => {
process.exit(1);
});

// Determine whether E2E should run and provide the associated reason
function shouldRunBitriseE2E(antiLabel: boolean, hasSmokeTestLabel: boolean, isDocs: boolean, isFork: boolean, isMergeQueue: boolean): [boolean, string] {

const conditions = [
{condition: hasSmokeTestLabel, message: "The smoke test label is present.", shouldRun: true},
{condition: isFork, message: "The pull request is from a fork.", shouldRun: false},
{condition: isDocs, message: "The pull request is documentation related.", shouldRun: false},
{condition: isMergeQueue, message: "The pull request is part of a merge queue.", shouldRun: false},
{condition: antiLabel, message: "The pull request has the anti-label.", shouldRun: false}
];

// Iterate through conditions to determine action
for (const {condition, message, shouldRun} of conditions) {
if (condition) {
return [shouldRun, message];
}
}

// Default case if no conditions met
return [false, "Unexpected scenario or no relevant labels found."];
}


async function main(): Promise<void> {
const githubToken = process.env.GITHUB_TOKEN;
const e2eLabel = process.env.E2E_LABEL;
const antiLabel = process.env.NO_E2E_LABEL;
const e2ePipeline = process.env.E2E_PIPELINE;
const workflowName = process.env.WORKFLOW_NAME;
const triggerAction = context.payload.action as PullRequestTriggerType;
Expand All @@ -42,6 +66,17 @@ async function main(): Promise<void> {
process.exit(1);
}

if (!antiLabel) {
core.setFailed('NO_E2E_LABEL not found');
process.exit(1);
}

// Logging for Pipeline debugging
console.log(`Trigger action: ${triggerAction}`);
console.log(`event: ${context.eventName}`);
console.log(`pullRequestNumber: ${pullRequestNumber}`);


const octokit: InstanceType<typeof GitHub> = getOctokit(githubToken);

const { data: prData } = await octokit.rest.pulls.get({
Expand All @@ -50,30 +85,79 @@ async function main(): Promise<void> {
pull_number: pullRequestNumber,
});

const docs = prData.title.startsWith("docs:");

// Get the latest commit hash
const latestCommitHash = prData.head.sha;

// Check if the e2e smoke label is applied
// Grab flags and labels
const labels = prData.labels;
const hasSmokeTestLabel = labels.some((label) => label.name === e2eLabel);
const hasAntiLabel = labels.some((label) => label.name === antiLabel);
const fork = context.payload.pull_request?.head.repo.fork || false;
const mergeQueue = (context.eventName === 'merge_group')


console.log(`Docs: ${docs}`);
console.log(`Fork: ${fork}`);
console.log(`Merge Queue: ${mergeQueue}`);
console.log(`Has smoke test label: ${hasSmokeTestLabel}`);
console.log(`Anti label: ${hasAntiLabel}`);

const [shouldRun, reason] = shouldRunBitriseE2E(hasAntiLabel, hasSmokeTestLabel, docs, fork, mergeQueue);
console.log(`Should run: ${shouldRun}, Reason: ${reason}`);

// One of these two labels must exist if not we bomb out
if (!hasSmokeTestLabel && !hasAntiLabel) {

// Fail Status due to missing labels
const createStatusCheckResponse = await octokit.rest.checks.create({
owner,
repo,
name: statusCheckName,
head_sha: latestCommitHash,
status: StatusCheckStatusType.Completed,
conclusion: CompletedConclusionType.Failure,
started_at: new Date().toISOString(),
output: {
title: statusCheckTitle,
summary: `Failed due to missing labels. Please apply either ${e2eLabel} or ${antiLabel}.`,
},
});

// Pass check since e2e smoke label is not applied
if (!hasSmokeTestLabel) {
if (createStatusCheckResponse.status === 201) {
console.log(
`Created '${statusCheckName}' check with failed status for commit ${latestCommitHash}`,
);
} else {
core.setFailed(
`Failed to create '${statusCheckName}' check with failed status for commit ${latestCommitHash} with status code ${createStatusCheckResponse.status}`,
);
process.exit(1);
}
core.setFailed(
`At least 1 E2E Label must be Applied either ${e2eLabel} or ${antiLabel}`,
);
process.exit(1);
}

if (!shouldRun) {
console.log(
`"${e2eLabel}" label not applied. Skipping Bitrise status check.`,
`Skipping Bitrise status check. due to the following reason: ${reason}`,
);

// Post success status (skipped)
const createStatusCheckResponse = await octokit.rest.checks.create({
owner,
repo,
name: statusCheckName,
head_sha: latestCommitHash,
status: StatusCheckStatusType.Completed,
conclusion: CompletedConclusionType.Success,
conclusion: CompletedConclusionType.Success,
started_at: new Date().toISOString(),
output: {
title: statusCheckTitle,
summary: 'Skip run since no E2E smoke label is applied',
summary: `Skip run since ${reason}`,
},
});

Expand All @@ -95,6 +179,8 @@ async function main(): Promise<void> {
triggerAction === PullRequestTriggerType.Labeled &&
context.payload?.label?.name === e2eLabel
) {

console.log(`Starting Bitrise build for commit ${latestCommitHash}`);
// Configure Bitrise configuration for API call
const data = {
build_params: {
Expand Down Expand Up @@ -222,6 +308,8 @@ async function main(): Promise<void> {
}

// Post pending status
console.log(`Posting pending status for commit ${latestCommitHash}`);

const createStatusCheckResponse = await octokit.rest.checks.create({
owner,
repo,
Expand Down Expand Up @@ -256,6 +344,8 @@ async function main(): Promise<void> {
const lastCommentPage = Math.ceil(
numberOfTotalComments / numberOfCommentsToCheck,
);


const { data: latestCommentBatch } = await octokit.rest.issues.listComments({
owner,
repo,
Expand Down Expand Up @@ -287,6 +377,8 @@ async function main(): Promise<void> {

// Bitrise comment doesn't exist, post fail status
if (!bitriseComment) {

console.log(`Bitrise comment not detected for commit ${latestCommitHash}`);
// Post fail status
const createStatusCheckResponse = await octokit.rest.checks.create({
owner,
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/add-team-label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ on:

jobs:
add-team-label:
uses: metamask/github-tools/.github/workflows/add-team-label.yml@058012b49ff2fbd9649c566ba43b29497f93b21d
permissions:
pull-requests: write
uses: metamask/github-tools/.github/workflows/add-team-label.yml@18af6e4b56a18230d1792480e249ebc50b324927
secrets:
PERSONAL_ACCESS_TOKEN: ${{ secrets.RELEASE_LABEL_TOKEN }}
TEAM_LABEL_TOKEN: ${{ secrets.TEAM_LABEL_TOKEN }}
39 changes: 39 additions & 0 deletions .github/workflows/auto-draft-prs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Auto Draft

on:
pull_request:
types: [opened]
branches:
- main

permissions:
pull-requests: write
contents: read
issues: write

jobs:
process_pr:
runs-on: ubuntu-latest
steps:
- name: Convert PR to Draft and Add Label
uses: actions/github-script@v6
with:
script: |
// Convert PR to draft
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
draft: true
});
// Check if the PR title includes "docs:" or if it's from a fork
if (context.payload.pull_request.title.includes('docs:') || context.payload.pull_request.head.repo.fork) {
// Add label "No E2E Smoke Needed"
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
labels: ['No E2E Smoke Needed']
});
}
4 changes: 1 addition & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ jobs:
- uses: ruby/setup-ruby@a6e6f86333f0a2523ece813039b8b4be04560854 #v1
with:
ruby-version: '3.1.6'
bundler-cache: true
env:
BUNDLE_GEMFILE: ios/Gemfile
- run: yarn setup
Expand Down Expand Up @@ -181,7 +180,6 @@ jobs:
name: ios-bundle
path: ios/main.jsbundle


- name: Push bundle size to mobile_bundlesize_stats repo
run: ./scripts/push-bundle-size.sh
env:
Expand Down Expand Up @@ -325,4 +323,4 @@ jobs:
else
echo "All jobs passed step skipped. Block PR."
exit 1
fi
fi
Loading

0 comments on commit f156e35

Please sign in to comment.