-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/MetaMask/metamask-mobile in…
…to morph/checkbox-update
- Loading branch information
Showing
13 changed files
with
269 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# PR Labeling Guidelines | ||
To maintain a consistent and efficient development workflow, we have set specific label guidelines for all pull requests (PRs). Please ensure you adhere to the following instructions: | ||
|
||
### Mandatory Labels: | ||
- **Internal Developers**: Every PR raised by an internal developer must include a label prefixed with `team-` (e.g., `team-mobile-ux`, `team-mobile-platform`, etc.). This indicates the respective internal team responsible for the PR. | ||
|
||
- **External Contributors**: PRs from contributors outside the organization must have the `external-contributor` label. | ||
|
||
It's essential to ensure that PRs have the appropriate labels before they are considered for merging. | ||
|
||
### Prohibited Labels: | ||
Any PR that includes one of the following labels can not be merged: | ||
|
||
- **needs-qa**: The PR requires a full manual QA prior to being added to a release. | ||
- **QA'd but questions**: The PR has been checked by QA, but there are pending questions or clarifications needed on minor issues that were found. | ||
- **issues-found**: The PR has been checked by QA or other reviewers, and appeared to include issues that need to be addressed. | ||
- **need-ux-ds-review**: The PR requires a review from the User Experience or Design System teams. | ||
- **blocked**: There are unresolved dependencies or other issues blocking the progress of this PR. | ||
- **stale**: The PR has not had recent activity in the last 90 days. It will be closed in 7 days. | ||
- **DO-NOT-MERGE**: The PR should not be merged under any circumstances. | ||
|
||
To maintain code quality and project integrity, it's crucial to respect these label guidelines. Please ensure you review and update labels appropriately throughout the PR lifecycle. | ||
|
||
Thank you for your cooperation! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import * as core from '@actions/core'; | ||
import { context, getOctokit } from '@actions/github'; | ||
import { GitHub } from '@actions/github/lib/utils'; | ||
|
||
main().catch((error: Error): void => { | ||
console.error(error); | ||
process.exit(1); | ||
}); | ||
|
||
async function main(): Promise<void> { | ||
// "GITHUB_TOKEN" is an automatically generated, repository-specific access token provided by GitHub Actions. | ||
const githubToken = process.env.GITHUB_TOKEN; | ||
if (!githubToken) { | ||
core.setFailed('GITHUB_TOKEN not found'); | ||
process.exit(1); | ||
} | ||
|
||
// Initialise octokit, required to call Github GraphQL API | ||
const octokit: InstanceType<typeof GitHub> = getOctokit(githubToken); | ||
|
||
// Retrieve pull request info from context | ||
const prRepoOwner = context.repo.owner; | ||
const prRepoName = context.repo.repo; | ||
const prNumber = context.payload.pull_request?.number; | ||
if (!prNumber) { | ||
core.setFailed('Pull request number not found'); | ||
process.exit(1); | ||
} | ||
|
||
// Retrieve pull request labels | ||
const prLabels = await retrievePullRequestLabels(octokit, prRepoOwner, prRepoName, prNumber); | ||
|
||
const preventMergeLabels = ["needs-qa", "QA'd but questions", "issues-found", "need-ux-ds-review", "blocked", "stale", "DO-NOT-MERGE"]; | ||
|
||
let hasTeamLabel = false; | ||
|
||
// Check pull request has at least required QA label and team label | ||
for (const label of prLabels) { | ||
if (label.startsWith("team-") || label === "external-contributor") { | ||
console.log(`PR contains a team label as expected: ${label}`); | ||
hasTeamLabel = true; | ||
} | ||
if (preventMergeLabels.includes(label)) { | ||
throw new Error(`PR cannot be merged because it still contains this label: ${label}`); | ||
} | ||
if (hasTeamLabel) { | ||
return; | ||
} | ||
} | ||
|
||
// Otherwise, throw an arror to prevent from merging | ||
let errorMessage = ''; | ||
if (!hasTeamLabel) { | ||
errorMessage += 'No team labels found on the PR. '; | ||
} | ||
errorMessage += `Please make sure the PR is appropriately labeled before merging it.\n\nSee labeling guidelines for more detail: https://github.com/MetaMask/metamask-mobile/blob/main/.github/coding_guidelines/LABELING_GUIDELINES.md`; | ||
throw new Error(errorMessage); | ||
|
||
} | ||
|
||
// This function retrieves the pull request on a specific repo | ||
async function retrievePullRequestLabels(octokit: InstanceType<typeof GitHub>, repoOwner: string, repoName: string, prNumber: number): Promise<string[]> { | ||
|
||
const retrievePullRequestLabelsQuery = ` | ||
query RetrievePullRequestLabels($repoOwner: String!, $repoName: String!, $prNumber: Int!) { | ||
repository(owner: $repoOwner, name: $repoName) { | ||
pullRequest(number: $prNumber) { | ||
labels(first: 100) { | ||
nodes { | ||
name | ||
} | ||
} | ||
} | ||
} | ||
} | ||
`; | ||
|
||
const retrievePullRequestLabelsResult: { | ||
repository: { | ||
pullRequest: { | ||
labels: { | ||
nodes: { | ||
name: string; | ||
}[]; | ||
} | ||
}; | ||
}; | ||
} = await octokit.graphql(retrievePullRequestLabelsQuery, { | ||
repoOwner, | ||
repoName, | ||
prNumber, | ||
}); | ||
|
||
const pullRequestLabels = retrievePullRequestLabelsResult?.repository?.pullRequest?.labels?.nodes?.map(labelObject => labelObject?.name); | ||
|
||
return pullRequestLabels || []; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: "Check PR has required labels" | ||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
types: | ||
- opened | ||
- reopened | ||
- synchronize | ||
- labeled | ||
- unlabeled | ||
|
||
jobs: | ||
check-pr-labels: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
pull-requests: read | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 # This is needed to checkout all branches | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version-file: '.nvmrc' | ||
cache: yarn | ||
|
||
- name: Install dependencies | ||
run: yarn --immutable | ||
|
||
- name: Check PR has required labels | ||
id: check-pr-has-required-labels | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: npm run check-pr-has-required-labels |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
'use strict'; | ||
|
||
import { Regression } from '../../tags'; | ||
import TestHelpers from '../../helpers'; | ||
|
||
import AmountView from '../../pages/AmountView'; | ||
import SendView from '../../pages/SendView'; | ||
import TransactionConfirmationView from '../../pages/TransactionConfirmView'; | ||
import { | ||
importWalletWithRecoveryPhrase, | ||
addLocalhostNetwork, | ||
} from '../../viewHelper'; | ||
import TabBarComponent from '../../pages/TabBarComponent'; | ||
import WalletActionsModal from '../../pages/modals/WalletActionsModal'; | ||
import Accounts from '../../../wdio/helpers/Accounts'; | ||
import Ganache from '../../../app/util/test/ganache'; | ||
import root from '../../../locales/languages/en.json'; | ||
|
||
const validAccount = Accounts.getValidAccount(); | ||
const MULTISIG_ADDRESS = '0x0C1DD822d1Ddf78b0b702df7BF9fD0991D6255A1'; | ||
const AMOUNT_TO_SEND = '0.12345'; | ||
const TOKEN_NAME = root.unit.eth; | ||
|
||
describe(Regression('Send tests'), () => { | ||
let ganacheServer; | ||
beforeAll(async () => { | ||
jest.setTimeout(2500000); | ||
if (device.getPlatform() === 'android') { | ||
await device.reverseTcpPort('8081'); // because on android we need to expose the localhost ports to run ganache | ||
await device.reverseTcpPort('8545'); | ||
} | ||
ganacheServer = new Ganache(); | ||
await ganacheServer.start({ mnemonic: validAccount.seedPhrase }); | ||
}); | ||
|
||
afterAll(async () => { | ||
await ganacheServer.quit(); | ||
}); | ||
|
||
it('Send ETH to a Multisig address from inside MetaMask wallet', async () => { | ||
await importWalletWithRecoveryPhrase(); | ||
await addLocalhostNetwork(); | ||
|
||
await TabBarComponent.tapActions(); | ||
await WalletActionsModal.tapSendButton(); | ||
|
||
await SendView.inputAddress(MULTISIG_ADDRESS); | ||
await SendView.tapNextButton(); | ||
|
||
await AmountView.typeInTransactionAmount(AMOUNT_TO_SEND); | ||
await AmountView.tapNextButton(); | ||
|
||
await TransactionConfirmationView.tapConfirmButton(); | ||
await TabBarComponent.tapActivity(); | ||
|
||
await TestHelpers.checkIfElementByTextIsVisible( | ||
AMOUNT_TO_SEND + ' ' + TOKEN_NAME, | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.