Skip to content

Commit

Permalink
Merge branch 'main' into fix/cherry-pick-node-version
Browse files Browse the repository at this point in the history
  • Loading branch information
sethkfman authored Nov 16, 2023
2 parents 4c7db1a + 3e5c9da commit 60161f7
Show file tree
Hide file tree
Showing 435 changed files with 20,169 additions and 5,214 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ body:
attributes:
label: Version
description: What version of MetaMask are you running? You can find the version in "Settings" > "About"
placeholder: "7.1.0"
validations:
required: true
- type: dropdown
Expand Down
4 changes: 4 additions & 0 deletions .github/guidelines/LABELING_GUIDELINES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ To maintain a consistent and efficient development workflow, we have set specifi

It's essential to ensure that PRs have the appropriate labels before they are considered for merging.

### Mandatory release version labels:
- **release-x.y.z**: This label is automatically added to a PR and its linked issues upon the PR's merge. The `x.y.z` in the label represents the version in which the changes from the PR will be included. This label is auto-generated by a [GitHub action](../workflows/add-release-label.yml), which determines the version by incrementing the minor version number from the most recent release. Manual intervention is only required in specific cases. For instance, if a merged PR is cherry-picked into a release branch, typically done to address Release Candidate (RC) bugs, the label would need to be manually updated to reflect the correct version.
- **regression-prod-x.y.z**: This label is automatically added to a bug report issue at the time of its creation. The `x.y.z` in the label represents the version in which the bug first appeared. This label is auto-generated by a [GitHub action](../workflows/check-template-and-add-labels.yml), which determines the `x.y.z` value based on the version information provided in the bug report issue form. Manual intervention is only necessary under certain circumstances. For example, if a user submits a bug report and specifies the version they are currently using, but the bug was actually introduced in a prior version, the label would need to be manually updated to accurately reflect the version where the bug originated.

### Mandatory QA labels:
Every PR shall include one the QA labels below:
- **needs-qa**: If the PR includes a new features, complex testing steps, or large refactors, this label must be added to indicated PR requires a full manual QA prior being merged and added to a release.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { context, getOctokit } from '@actions/github';
import { GitHub } from '@actions/github/lib/utils';

enum PullRequestTriggerType {
Opened = 'opened',
Reopened = 'reopened',
ReadyForReview = 'ready_for_review',
Labeled = 'labeled',
}
Expand Down Expand Up @@ -34,22 +32,6 @@ async function main(): Promise<void> {
console.log(`Workflow triggered by the event (${triggerAction})`);

switch (triggerAction) {
case PullRequestTriggerType.Opened:
shouldTriggerE2E = !context.payload.pull_request?.draft;
if (!shouldTriggerE2E) {
console.log(`Skipping E2E smoke since opened PR is in draft.`);
} else {
console.log(`Starting E2E smoke since opened PR is ready for review.`);
}
break;
case PullRequestTriggerType.Reopened:
shouldTriggerE2E = !context.payload.pull_request?.draft;
if (!shouldTriggerE2E) {
console.log(`Skipping E2E smoke since reopened PR is in draft.`);
} else {
console.log(`Starting E2E smoke since reopened PR is ready for review.`);
}
break;
case PullRequestTriggerType.ReadyForReview:
shouldTriggerE2E = true;
console.log(
Expand Down Expand Up @@ -90,7 +72,7 @@ async function main(): Promise<void> {
process.exit(1);
}
} catch (error) {
console.log(`Error occured when applying label: ${error}`);
core.setFailed(`Error occured when applying label: ${error}`);
process.exit(1);
}
}
Expand Down
41 changes: 36 additions & 5 deletions .github/scripts/check-template-and-add-labels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import {
import { TemplateType, templates } from './shared/template';
import { retrievePullRequest } from './shared/pull-request';

const knownBots = ["metamaskbot", "dependabot", "github-actions", "sentry-io"];

main().catch((error: Error): void => {
console.error(error);
process.exit(1);
Expand Down Expand Up @@ -81,6 +83,12 @@ async function main(): Promise<void> {
labelable.body,
);

// 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.`);
process.exit(0); // Stop the process and exit with a success status code
}

if (labelable.type === LabelableType.Issue) {
if (templateType === TemplateType.GeneralIssue) {
console.log("Issue matches 'general-issue.yml' template.");
Expand All @@ -103,7 +111,11 @@ async function main(): Promise<void> {
);

// Add regression prod label to the bug report issue if release version was found in issue body
if (releaseVersion) {
if(isReleaseCandidateIssue(labelable)) {
console.log(
`Issue ${labelable?.number} is not a production issue. Regression prod label is not needed.`,
);
} else if (releaseVersion) {
await addRegressionProdLabelToIssue(octokit, releaseVersion, labelable);
} else {
console.log(
Expand All @@ -112,7 +124,7 @@ async function main(): Promise<void> {
}
} else {
const errorMessage =
"Issue body does not match any of expected templates ('general-issue.yml' or 'bug-report.yml').";
"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-mobile/blob/main/.github/scripts/shared/template.ts#L14-L37";
console.log(errorMessage);

// Add label to indicate issue doesn't match any template
Expand All @@ -132,7 +144,7 @@ async function main(): Promise<void> {
);
} else {
const errorMessage =
"PR body does not match template ('pull-request-template.md').";
`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-mobile/blob/main/.github/scripts/shared/template.ts#L40-L47`;
console.log(errorMessage);

// Add label to indicate PR body doesn't match template
Expand All @@ -142,9 +154,21 @@ async function main(): Promise<void> {
invalidPullRequestTemplateLabel,
);

// TODO: Remove these two lines in January 2024. By then, most PRs will match the new PR template, and we'll want the action to fail if they don't.
// For now, we're in a transition period and Github action shall add an annotation in case PR doesn't match template, but shall not fail.
// Indeed, many PRs were created before the new PR template was introduced and don't match the template for now.
core.error(errorMessage, {
title: invalidPullRequestTemplateLabel.name,
file: '.github/scripts/shared/template.ts',
startLine: 40,
endLine: 47,
}); // This creates an annotation on the PR
process.exit(0);

// TODO: Uncomment these two lines in January 2024. By then, most PRs will match the new PR template, and we'll want the action to fail if they don't.
// Github action shall fail in case PR doesn't match template
core.setFailed(errorMessage);
process.exit(1);
// core.setFailed(errorMessage); // This creates a failure status for the action
// process.exit(1);
}
} else {
core.setFailed(
Expand Down Expand Up @@ -269,3 +293,10 @@ async function userBelongsToMetaMaskOrg(

return Boolean(userBelongsToMetaMaskOrgResult?.user?.organization?.id);
}

// This function checks if issue is a release candidate (RC) issue, discovered during release regression testing phase. If so, it means it is not a production issue.
function isReleaseCandidateIssue(
issue: Labelable,
): boolean {
return Boolean(issue.labels.find(label => label.name === 'regression-RC'));
}
2 changes: 0 additions & 2 deletions .github/scripts/shared/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ const prTemplateTitles = [
'## **Related issues**',
'## **Manual testing steps**',
'## **Screenshots/Recordings**',
'### **Before**',
'### **After**',
'## **Pre-merge author checklist**',
'## **Pre-merge reviewer checklist**',
];
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check-bitrise-e2e-smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Check Bitrise E2E Smoke Tests

on:
pull_request:
types: [opened, reopened, ready_for_review, labeled]
types: [ready_for_review, labeled]

env:
E2E_LABEL: 'Run Smoke E2E'
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# osx
.DS_Store
# don't save asdf tools-version config as nvm is prioritized.
.tool-versions

# xcode
build/
Expand Down
6 changes: 6 additions & 0 deletions .js.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,9 @@ export WALLET_CONNECT_PROJECT_ID=""
export BLOCKAID_FILE_CDN=""
export BLOCKAID_PUBLIC_KEY=""
export MM_BLOCKAID_UI_ENABLED=""

# Default PORT for metro
export WATCHER_PORT=8081

# Environment: "production", "pre-release" or "local"
export METAMASK_ENVIRONMENT=""
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v16
v18
4 changes: 2 additions & 2 deletions .storybook/storybook.requires.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,6 @@ const getStories = () => {
"./app/component-library/components/BottomSheets/BottomSheetHeader/BottomSheetHeader.stories.tsx": require("../app/component-library/components/BottomSheets/BottomSheetHeader/BottomSheetHeader.stories.tsx"),
"./app/component-library/components/Navigation/TabBar/TabBar.stories.tsx": require("../app/component-library/components/Navigation/TabBar/TabBar.stories.tsx"),
"./app/component-library/components/Navigation/TabBarItem/TabBarItem.stories.tsx": require("../app/component-library/components/Navigation/TabBarItem/TabBarItem.stories.tsx"),
"./app/component-library/components/Select/MultiSelect/MultiSelectItem/MultiSelectItem.stories.tsx": require("../app/component-library/components/Select/MultiSelect/MultiSelectItem/MultiSelectItem.stories.tsx"),
"./app/component-library/components/Select/Select/SelectItem/SelectItem.stories.tsx": require("../app/component-library/components/Select/Select/SelectItem/SelectItem.stories.tsx"),
"./app/component-library/components/Pickers/PickerAccount/PickerAccount.stories.tsx": require("../app/component-library/components/Pickers/PickerAccount/PickerAccount.stories.tsx"),
"./app/component-library/components/Pickers/PickerNetwork/PickerNetwork.stories.tsx": require("../app/component-library/components/Pickers/PickerNetwork/PickerNetwork.stories.tsx"),
"./app/component-library/components/Cells/Cell/Cell.stories.tsx": require("../app/component-library/components/Cells/Cell/Cell.stories.tsx"),
Expand All @@ -154,6 +152,8 @@ const getStories = () => {
"./app/component-library/components/Form/TextField/TextField.stories.tsx": require("../app/component-library/components/Form/TextField/TextField.stories.tsx"),
"./app/component-library/components/Form/TextFieldSearch/TextFieldSearch.stories.tsx": require("../app/component-library/components/Form/TextFieldSearch/TextFieldSearch.stories.tsx"),
"./app/component-library/components/List/ListItem/ListItem.stories.tsx": require("../app/component-library/components/List/ListItem/ListItem.stories.tsx"),
"./app/component-library/components/List/ListItemMultiSelect/ListItemMultiSelect.stories.tsx": require("../app/component-library/components/List/ListItemMultiSelect/ListItemMultiSelect.stories.tsx"),
"./app/component-library/components/List/ListItemSelect/ListItemSelect.stories.tsx": require("../app/component-library/components/List/ListItemSelect/ListItemSelect.stories.tsx"),
"./app/component-library/components/Texts/Text/Text.stories.tsx": require("../app/component-library/components/Texts/Text/Text.stories.tsx"),
"./app/component-library/components/Texts/TextWithPrefixIcon/TextWithPrefixIcon.stories.tsx": require("../app/component-library/components/Texts/TextWithPrefixIcon/TextWithPrefixIcon.stories.tsx"),
"./app/component-library/components/Overlay/Overlay.stories.tsx": require("../app/component-library/components/Overlay/Overlay.stories.tsx"),
Expand Down
Loading

0 comments on commit 60161f7

Please sign in to comment.