Skip to content

Commit

Permalink
Merge branch 'main' into jb-fix-onboarding-modal
Browse files Browse the repository at this point in the history
  • Loading branch information
jonybur authored Jul 18, 2024
2 parents 7c25a02 + 96d6399 commit c21ca73
Show file tree
Hide file tree
Showing 504 changed files with 16,266 additions and 12,376 deletions.
13 changes: 13 additions & 0 deletions .android.env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
export MM_FOX_CODE="EXAMPLE_FOX_CODE"
export MM_BRANCH_KEY_TEST=
export MM_BRANCH_KEY_LIVE=
export METAMASK_BUILD_TYPE=
# Firebase
export FCM_CONFIG_API_KEY=
export FCM_CONFIG_AUTH_DOMAIN=
export FCM_CONFIG_PROJECT_ID=
export FCM_CONFIG_STORAGE_BUCKET=
export FCM_CONFIG_MESSAGING_SENDER_ID=
export FCM_CONFIG_APP_ID=
export GOOGLE_SERVICES_B64=
#Notifications Feature Announcements
export FEATURES_ANNOUNCEMENTS_ACCESS_TOKEN=
export FEATURES_ANNOUNCEMENTS_SPACE_ID=

12 changes: 12 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ body:
label: Error messages or log output
description: Please copy and paste any relevant error messages or log output. This will be automatically formatted, so there is no need for backticks.
render: shell
- type: dropdown
id: stage
attributes:
label: Detection stage
description: At what stage was the bug detected?
options:
- In production (default)
- In beta
- During release testing
- On the development branch
validations:
required: true
- type: input
id: version
attributes:
Expand Down
6 changes: 4 additions & 2 deletions .github/guidelines/LABELING_GUIDELINES.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ It's essential to ensure that PRs have the appropriate labels before they are co
### 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.
- **No QA/E2E only**: If the PR does not require any manual QA effort, this label must be added. However, prior to merging, you must ensure end-to-end test runs in Bitrise are successful.

- **Spot check on release build**: If PR does not require feature QA but needs non-automated verification, this label must be added. Furthermore, when that label is added, you must provide test scenarios in the description section, as well as add screenshots, and or recordings of what was tested.

Once PR has been tested by QA (only if the PR was labeled with `needs-qa`):
To merge your PR one of the following QA labels are required:
- **QA Passed**: If the PR was labeled with `needs-qa`, this label must be added once QA has signed off
- **No QA Needed**: If the PR does not require any QA effort. This label should only be used in case you are updating a README or other files that does not impact the building or runtime of the application.
- **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.
Expand Down
13 changes: 11 additions & 2 deletions .github/scripts/check-pr-has-required-labels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,29 +50,38 @@ async function main(): Promise<void> {
'DO-NOT-MERGE',
];
let hasTeamLabel = false;
let hasQALabel = false;

// Check pull request has at least required QA label and team label
for (const label of pullRequestLabels) {
if (label.startsWith('team-') || label === externalContributorLabel.name) {
console.log(`PR contains a team label as expected: ${label}`);
hasTeamLabel = true;
}
if (label.includes('Run Smoke E2E') || label.includes('No QA Needed') || label.includes('QA Passed') ) {
console.log(`PR contains a QA label as expected: ${label}`);
hasQALabel = true;
}
if (preventMergeLabels.includes(label)) {
core.setFailed(
`PR cannot be merged because it still contains this label: ${label}`,
);
process.exit(1);
}
if (hasTeamLabel) {
if (hasTeamLabel && hasQALabel) {
return;
}
}

// Otherwise, throw an arror to prevent from merging
// Otherwise, throw an error to prevent from merging
let errorMessage = '';
if (!hasTeamLabel) {
errorMessage += 'No team labels found on the PR. ';
}

if (!hasQALabel) {
errorMessage += 'No \'Run E2E Smoke\' or \'No QA Needed\' or \'QA Passed\' label. ';
}
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/guidelines/LABELING_GUIDELINES.md`;
core.setFailed(errorMessage);
process.exit(1);
Expand Down
137 changes: 95 additions & 42 deletions .github/scripts/check-template-and-add-labels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ import {
import { TemplateType, templates } from './shared/template';
import { retrievePullRequest } from './shared/pull-request';

enum RegressionStage {
Development,
Testing,
Beta,
Production
}

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

main().catch((error: Error): void => {
Expand Down Expand Up @@ -105,23 +112,9 @@ async function main(): Promise<void> {
invalidIssueTemplateLabel,
);

// Extract release version from bug report issue body (if existing)
const releaseVersion = extractReleaseVersionFromBugReportIssueBody(
labelable.body,
);
// Add regression label to the bug report issue
addRegressionLabelToIssue(octokit, labelable);

// Add regression prod label to the bug report issue if release version was found in issue body
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(
`No release version was found in body of bug report issue ${labelable?.number}.`,
);
}
} 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-mobile/blob/main/.github/scripts/shared/template.ts#L14-L37";
Expand Down Expand Up @@ -200,6 +193,28 @@ function extractTemplateTypeFromBody(body: string): TemplateType {
return TemplateType.None;
}

// This helper function extracts regression stage (Development, Testing, Production) from bug report issue's body.
function extractRegressionStageFromBugReportIssueBody(
body: string,
): RegressionStage | undefined {
const detectionStageRegex = /### Detection stage\s*\n\s*(.*)/i;
const match = body.match(detectionStageRegex);
const extractedAnswer = match ? match[1].trim() : undefined;

switch (extractedAnswer) {
case 'On the development branch':
return RegressionStage.Development;
case 'During release testing':
return RegressionStage.Testing;
case 'In beta':
return RegressionStage.Beta;
case 'In production (default)':
return RegressionStage.Production;
default:
return undefined;
}
}

// This helper function extracts release version from bug report issue's body.
function extractReleaseVersionFromBugReportIssueBody(
body: string,
Expand All @@ -220,49 +235,54 @@ function extractReleaseVersionFromBugReportIssueBody(
return version;
}

// This function adds the correct "regression-prod-x.y.z" label to the issue, and removes other ones
async function addRegressionProdLabelToIssue(
// This function adds the correct regression label to the issue, and removes other ones
async function addRegressionLabelToIssue(
octokit: InstanceType<typeof GitHub>,
releaseVersion: string,
issue: Labelable,
): Promise<void> {
// Craft regression prod label to add
const regressionProdLabel: Label = {
name: `regression-prod-${releaseVersion}`,
color: '5319E7', // violet
description: `Regression bug that was found in production in release ${releaseVersion}`,
};

let regressionProdLabelFound: boolean = false;
const regressionProdLabelsToBeRemoved: {
// Extract regression stage from bug report issue body (if existing)
const regressionStage = extractRegressionStageFromBugReportIssueBody(
issue.body,
);

// Extract release version from bug report issue body (if existing)
const releaseVersion = extractReleaseVersionFromBugReportIssueBody(
issue.body,
);

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

let regressionLabelFound: boolean = false;
const regressionLabelsToBeRemoved: {
id: string;
name: string;
}[] = [];

// Loop over issue's labels, to see if regression labels are either missing, or to be removed
issue?.labels?.forEach((label) => {
if (label?.name === regressionProdLabel.name) {
regressionProdLabelFound = true;
} else if (label?.name?.startsWith('regression-prod-')) {
regressionProdLabelsToBeRemoved.push(label);
if (label?.name === regressionLabel.name) {
regressionLabelFound = true;
} else if (label?.name?.startsWith('regression-')) {
regressionLabelsToBeRemoved.push(label);
}
});

// Add regression prod label to the issue if missing
if (regressionProdLabelFound) {
if (regressionLabelFound) {
console.log(
`Issue ${issue?.number} already has ${regressionProdLabel.name} label.`,
`Issue ${issue?.number} already has ${regressionLabel.name} label.`,
);
} else {
console.log(
`Add ${regressionProdLabel.name} label to issue ${issue?.number}.`,
`Add ${regressionLabel.name} label to issue ${issue?.number}.`,
);
await addLabelToLabelable(octokit, issue, regressionProdLabel);
await addLabelToLabelable(octokit, issue, regressionLabel);
}

// Remove other regression prod label from the issue
await Promise.all(
regressionProdLabelsToBeRemoved.map((label) => {
regressionLabelsToBeRemoved.map((label) => {
removeLabelFromLabelable(octokit, issue, label?.id);
}),
);
Expand Down Expand Up @@ -294,9 +314,42 @@ 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.startsWith('regression-RC')));
// This function crafts appropriate label, corresponding to regression stage and release version.
function craftRegressionLabel(regressionStage: RegressionStage | undefined, releaseVersion: string | undefined): Label {
switch (regressionStage) {
case RegressionStage.Development:
return {
name: `regression-develop`,
color: '5319E7', // violet
description: `Regression bug that was found on development branch, but not yet present in production`,
};

case RegressionStage.Testing:
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.`,
};

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.`,
};

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.`,
};

default:
return {
name: `regression-*`,
color: 'EDEDED', // grey
description: `TODO: Unknown regression stage. Please replace with correct regression label: 'regression-develop', 'regression-RC-x.y.z', or 'regression-prod-x.y.z' label, where 'x.y.z' is the number of the release where bug was found.`,
};
}
}
19 changes: 11 additions & 8 deletions .github/workflows/create-release-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ on:
version-number:
description: 'A natural version number. eg: 862'
required: true

previous-version-tag:
description: 'Previous release version tag. eg: v7.7.0'
required: true
jobs:
create-release-pr:
runs-on: ubuntu-latest
Expand All @@ -34,20 +36,21 @@ jobs:
# The workaround is to use a personal access token (BUG_REPORT_TOKEN) instead of
# the default GITHUB_TOKEN for the checkout action.
token: ${{ secrets.BUG_REPORT_TOKEN }}
- name: Get Node.js version
id: nvm
run: echo "NODE_VERSION=$(cat .nvmrc)" >> "$GITHUB_OUTPUT"
- uses: actions/setup-node@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ steps.nvm.outputs.NODE_VERSION }}
node-version-file: '.nvmrc'
cache: yarn
- name: Install dependencies
run: yarn --immutable
- name: Set Versions
id: set-versions
shell: bash
run: SEMVER_VERSION=${{ github.event.inputs.semver-version }} VERSION_NUMBER=${{ github.event.inputs.version-number }} yarn create-release
run: SEMVER_VERSION=${{ github.event.inputs.semver-version }} VERSION_NUMBER=${{ github.event.inputs.version-number }} yarn set-version
- name: Create Release PR
id: create-release-pr
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./scripts/create-release-pr.sh ${{ github.event.inputs.semver-version }}
./scripts/create-release-pr.sh ${{ github.event.inputs.previous-version-tag }} ${{ github.event.inputs.semver-version }}
3 changes: 2 additions & 1 deletion .github/workflows/run-bitrise-e2e-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ jobs:
- uses: actions/checkout@v3
- name: Determine whether this PR is from a fork
id: is-fork
run: echo "IS_FORK=$(gh pr view --json isCrossRepository --jq '.isCrossRepository' "${{ github.event.number }}" )" >> "$GITHUB_OUTPUT"
run: echo "IS_FORK=$(gh pr view --json isCrossRepository --jq '.isCrossRepository' "${PR_NUMBER}" )" >> "$GITHUB_OUTPUT"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.number || github.event.issue.number }}

run-bitrise-e2e-check:
needs: is-fork-pull-request
Expand Down
Loading

0 comments on commit c21ca73

Please sign in to comment.