Skip to content

Commit

Permalink
Merge branch 'main' into STAKE-705-fe-show-user-historic-reward-payouts
Browse files Browse the repository at this point in the history
  • Loading branch information
nickewansmith authored Jan 12, 2025
2 parents 6072e09 + 8873337 commit 512a37e
Show file tree
Hide file tree
Showing 516 changed files with 23,567 additions and 8,197 deletions.
1 change: 1 addition & 0 deletions .depcheckrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ ignores:
- '@react-native-community/slider'
- 'patch-package'
- '@lavamoat/allow-scripts'
- '@lavamoat/git-safe-dependencies'
- 'babel-plugin-inline-import'
# This is used on the patch for TokenRatesController of Assets controllers, for we to be able to use the last version of it
- cockatiel
Expand Down
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ module.exports = {
{
files: [
'app/components/UI/Name/**/*.{js,ts,tsx}',
'app/components/UI/SimulationDetails/**/*.{js,ts,tsx}',
'app/components/hooks/DisplayName/**/*.{js,ts,tsx}'
],
rules: {
Expand Down
6 changes: 5 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ app/store/migrations/ @MetaMask/mobile-pla
bitrise.yml @MetaMask/mobile-platform
yarn.lock @MetaMask/mobile-platform
ios/Podfile.lock @MetaMask/mobile-platform
app/components/Views/BrowserTab/BrowserTab.tsx @MetaMask/mobile-platform

# Ramps Team
app/components/UI/Ramp/ @MetaMask/ramp
Expand All @@ -47,7 +48,7 @@ app/util/walletconnect.js @MetaMask/sdk-devs

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

# Swaps Team
app/components/UI/Swaps @MetaMask/swaps-engineers
Expand Down Expand Up @@ -76,6 +77,9 @@ patches/react-native+0.*.patch @MetaMask/supply-chain
**/snaps/** @MetaMask/snaps-devs
**/Snaps/** @MetaMask/snaps-devs

# Wallet API Platform Team
app/core/RPCMethods/ @MetaMask/wallet-api-platform-engineers

# Staking Team
app/components/UI/Stake @MetaMask/metamask-staking

Expand Down
3 changes: 2 additions & 1 deletion .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ body:
- In production (default)
- In beta
- During release testing
- On the development branch
- On main branch
- On a feature branch
validations:
required: true
- type: input
Expand Down
3 changes: 2 additions & 1 deletion .github/guidelines/LABELING_GUIDELINES.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ To merge your PR one of the following QA labels are required:
- **Run E2E Smoke**: This label will kick-off E2E testing and trigger a check to make sure the E2E tests pass.

### Optional labels:
- **regression-develop**: This label can manually be added to a bug report issue at the time of its creation if the bug is present on the development branch, i.e., `main`, but is not yet released in production.
- **regression-main**: This label can manually be added to a bug report issue at the time of its creation if the bug is present on the development branch, i.e., `main`, but is not yet released in production.
- **feature-branch-bug**: This label can manually be added to a bug report issue at the time of its creation if the bug is present on a feature branch, i.e., before merging to `main`.

### Labels prohibited when PR needs to be merged:
Any PR that includes one of the following labels can not be merged:
Expand Down
238 changes: 114 additions & 124 deletions .github/scripts/bitrise/run-bitrise-e2e-check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,107 @@ import {
} from '../scripts.types';
import axios from 'axios';

let octokitInstance: InstanceType<typeof GitHub> | null = null;
let owner: string;
let repo: string;

main().catch((error: Error): void => {
console.error(error);
process.exit(1);
});



function getOctokitInstance(): InstanceType<typeof GitHub> {
if (!octokitInstance) {
const githubToken = process.env.GITHUB_TOKEN;
if (!githubToken) {
throw new Error("GitHub token is not set in the environment variables");
}
octokitInstance = getOctokit(githubToken);
}
return octokitInstance;
}

async function upsertStatusCheck(
statusCheckName: string,
commitHash: string,
status: StatusCheckStatusType,
conclusion: CompletedConclusionType | undefined,
summary: string
): Promise<void> {
const octokit = getOctokitInstance();

// List existing checks
const listResponse = await octokit.rest.checks.listForRef({
owner,
repo,
ref: commitHash,
});

if (listResponse.status !== 200) {
core.setFailed(
`Failed to list checks for commit ${commitHash}, received status code ${listResponse.status}`,
);
process.exit(1);
}

const existingCheck = listResponse.data.check_runs.find(check => check.name === statusCheckName);

if (existingCheck) {
console.log(`Check already exists: ${existingCheck.name}, updating...`);
// Update the existing check
const updateCheckResponse = await octokit.rest.checks.update({
owner,
repo,
check_run_id: existingCheck.id,
name: statusCheckName,
status: status,
conclusion: conclusion,
output: {
title: `${statusCheckName} Status Check`,
summary: summary,
},
});

if (updateCheckResponse.status !== 200) {
core.setFailed(
`Failed to update '${statusCheckName}' check with status ${status} for commit ${commitHash}, got status code ${updateCheckResponse.status}`,
);
process.exit(1);
}

console.log(`Updated existing check: ${statusCheckName} with id ${existingCheck.id} & status ${status} for commit ${commitHash}`);



} else {
console.log(`Check does not exist: ${statusCheckName}, creating...`);
// Create a new status check
const createCheckResponse = await octokit.rest.checks.create({
owner,
repo,
name: statusCheckName,
head_sha: commitHash,
status: status,
conclusion: conclusion,
started_at: new Date().toISOString(),
output: {
title: `${statusCheckName} Status Check`,
summary: summary,
},
});

if (createCheckResponse.status !== 201) {
core.setFailed(
`Failed to create '${statusCheckName}' check with status ${status} for commit ${commitHash}, got status code ${createCheckResponse.status}`,
);
process.exit(1);
}

console.log(`Created check: ${statusCheckName} with id ${createCheckResponse.data.id} & status ${status} for commit ${commitHash}`);
}
}
// Determine whether E2E should run and provide the associated reason
function shouldRunBitriseE2E(antiLabel: boolean, hasSmokeTestLabel: boolean, isDocs: boolean, isFork: boolean, isMergeQueue: boolean): [boolean, string] {

Expand Down Expand Up @@ -43,7 +139,11 @@ async function main(): Promise<void> {
const e2ePipeline = process.env.E2E_PIPELINE;
const workflowName = process.env.WORKFLOW_NAME;
const triggerAction = context.payload.action as PullRequestTriggerType;
const { owner, repo, number: pullRequestNumber } = context.issue;
// Assuming context.issue comes populated with owner and repo, as typical with GitHub Actions
const { owner: contextOwner, repo: contextRepo, number: pullRequestNumber } = context.issue;
owner = contextOwner;
repo = contextRepo;

const removeAndApplyInstructions = `Remove and re-apply the "${e2eLabel}" label to trigger a E2E smoke test on Bitrise.`;
const mergeFromMainCommitMessagePrefix = `Merge branch 'main' into`;
const pullRequestLink = `https://github.com/MetaMask/metamask-mobile/pull/${pullRequestNumber}`;
Expand Down Expand Up @@ -80,7 +180,7 @@ async function main(): Promise<void> {
const mqCommitHash = context.payload?.merge_group?.head_sha;


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

const { data: prData } = await octokit.rest.pulls.get({
owner,
Expand Down Expand Up @@ -114,67 +214,18 @@ async function main(): Promise<void> {
if (!mergeQueue && !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}.`,
},
});

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);
await upsertStatusCheck(statusCheckName, latestCommitHash, StatusCheckStatusType.Completed,
CompletedConclusionType.Failure, `Failed due to missing labels. Please apply either ${e2eLabel} or ${antiLabel}.`);
return
}

if (!shouldRun) {
console.log(
`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,
started_at: new Date().toISOString(),
output: {
title: statusCheckTitle,
summary: `Skip run since ${reason}`,
},
});

if (createStatusCheckResponse.status === 201) {
console.log(
`Created '${statusCheckName}' check with skipped status for commit ${latestCommitHash}`,
);
} else {
core.setFailed(
`Failed to create '${statusCheckName}' check with skipped status for commit ${latestCommitHash} with status code ${createStatusCheckResponse.status}`,
);
process.exit(1);
}
await upsertStatusCheck(statusCheckName, latestCommitHash, StatusCheckStatusType.Completed, CompletedConclusionType.Success,
`Skip run since ${reason}`);
return;
}

Expand Down Expand Up @@ -314,29 +365,9 @@ 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,
name: statusCheckName,
head_sha: latestCommitHash,
status: StatusCheckStatusType.InProgress,
started_at: new Date().toISOString(),
output: {
title: statusCheckTitle,
summary: `Test runs in progress... You can view them at ${buildLink}`,
},
});
await upsertStatusCheck( statusCheckName, latestCommitHash, StatusCheckStatusType.InProgress, undefined, `Test runs in progress... You can view them at ${buildLink}`);


if (createStatusCheckResponse.status === 201) {
console.log(
`Created '${statusCheckName}' check for commit ${latestCommitHash}`,
);
} else {
core.setFailed(
`Failed to create '${statusCheckName}' check for commit ${latestCommitHash} with status code ${createStatusCheckResponse.status}`,
);
process.exit(1);
}
return;
}

Expand Down Expand Up @@ -383,31 +414,11 @@ async function main(): Promise<void> {
if (!bitriseComment) {

console.log(`Bitrise comment not detected for commit ${latestCommitHash}`);
// Post fail status
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: `No Bitrise comment found for commit ${latestCommitHash}. Try re-applying the '${e2eLabel}' label.`,
},
});

if (createStatusCheckResponse.status === 201) {
console.log(
`Created '${statusCheckName}' check for commit ${latestCommitHash}`,
);
} else {
core.setFailed(
`Failed to create '${statusCheckName}' check for commit ${latestCommitHash} with status code ${createStatusCheckResponse.status}`,
);
process.exit(1);
}
await upsertStatusCheck(statusCheckName, latestCommitHash, StatusCheckStatusType.Completed,
CompletedConclusionType.Failure,
`No Bitrise comment found for commit ${latestCommitHash}. Try re-applying the '${e2eLabel}' label.`);

return;
}

Expand Down Expand Up @@ -498,27 +509,6 @@ async function main(): Promise<void> {
}

// Post status check
const createStatusCheckResponse = await octokit.rest.checks.create({
owner,
repo,
name: statusCheckName,
head_sha: latestCommitHash,
started_at: new Date().toISOString(),
output: {
title: statusCheckTitle,
summary: statusMessage,
},
...checkStatus,
});
await upsertStatusCheck(statusCheckName, latestCommitHash, checkStatus.status, checkStatus.conclusion, statusMessage);

if (createStatusCheckResponse.status === 201) {
console.log(
`Created '${statusCheckName}' check for commit ${latestCommitHash}`,
);
} else {
core.setFailed(
`Failed to create '${statusCheckName}' check for commit ${latestCommitHash} with status code ${createStatusCheckResponse.status}`,
);
process.exit(1);
}
}
Loading

0 comments on commit 512a37e

Please sign in to comment.