Skip to content

Commit

Permalink
Merge branch 'develop' into optimize-setuplocale
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmurdoch authored Nov 6, 2024
2 parents 5a18b3a + 264a432 commit b49a9a4
Show file tree
Hide file tree
Showing 951 changed files with 42,657 additions and 30,525 deletions.
83 changes: 32 additions & 51 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ aliases:
cat ${HOME}/project/.circleci/scripts/enable-vnc.sh >> ~/.bashrc
fi
# Check if MMI Optional tests should run
- &check-mmi-optional
name: Check if MMI Optional tests should run
# Check if MMI tests should run
- &check-mmi-trigger
name: Check if MMI tests should run
command: |
RUN_MMI_OPTIONAL=$(cat ./RUN_MMI_OPTIONAL)
if [[ "${RUN_MMI_OPTIONAL}" == "true" ]]; then
echo "Running MMI Optional tests"
source mmi_trigger.env
if [ "${run_mmi_tests}" == "true" ]; then
echo "Running MMI tests"
else
echo "Skipping MMI Optional tests"
echo "Skipping MMI tests"
circleci step halt
fi
Expand All @@ -114,7 +114,7 @@ workflows:
- trigger-beta-build:
requires:
- prep-deps
- check-pr-tag
- check-mmi-trigger
- prep-deps
- get-changed-files-with-git-diff:
filters:
Expand Down Expand Up @@ -179,7 +179,7 @@ workflows:
- prep-build-test-mmi-playwright:
requires:
- prep-deps
- check-pr-tag
- check-mmi-trigger
- prep-build-storybook:
requires:
- prep-deps
Expand Down Expand Up @@ -231,7 +231,7 @@ workflows:
requires:
- prep-build-test-mmi
- get-changed-files-with-git-diff
- test-e2e-mmi-playwright - OPTIONAL:
- test-e2e-mmi-playwright:
requires:
- prep-build-test-mmi-playwright
- test-e2e-chrome-rpc-mmi:
Expand Down Expand Up @@ -421,39 +421,6 @@ jobs:
name: Create GitHub Pull Request for version
command: .circleci/scripts/release-create-release-pr.sh

check-pr-tag:
docker:
- image: cimg/base:stable
steps:
- run:
name: Check for MMI Team Tag
command: |
#!/bin/bash
GH_LABEL=team-mmi
if [ -z "$CIRCLE_PULL_REQUESTS" ]; then
echo "Skipping tag check; this is not a PR."
echo "false" > ./RUN_MMI_OPTIONAL
exit 0
fi
echo $CIRCLE_PULL_REQUESTS | sed 's/,/\n/g'
# See if any associated PRs have matching label
HAS_MATCHING_PR=$(echo $CIRCLE_PULL_REQUESTS \
| sed -e 's#,#\n#g' -e 's#/github.com/#/api.github.com/repos/#g' -e 's#/pull/#/pulls/#g' \
| xargs -n1 curl -s \
| jq -s "map((.labels|map(select(.name==\"${GH_LABEL}\"))))|flatten|length > 0")
echo "${GH_LABEL} tag presence: ${HAS_MATCHING_PR}"
# assign the RUN_MMI_OPTIONAL variable
echo "${HAS_MATCHING_PR}" > ./RUN_MMI_OPTIONAL
- persist_to_workspace:
root: .
paths:
- RUN_MMI_OPTIONAL

prep-deps:
executor: node-browsers-medium
steps:
Expand All @@ -477,7 +444,7 @@ jobs:
- gh/install
- run:
name: Install dependencies
command: .circleci/scripts/install-dependencies.sh
command: yarn --immutable
- save_cache:
key: dependency-cache-{{ checksum "/tmp/YARN_VERSION" }}-{{ checksum "yarn.lock" }}
paths:
Expand Down Expand Up @@ -839,7 +806,7 @@ jobs:
- run: corepack enable
- attach_workspace:
at: .
- run: *check-mmi-optional
- run: *check-mmi-trigger
- run:
name: Build MMI extension for Playwright e2e
command: |
Expand All @@ -854,7 +821,6 @@ jobs:
- persist_to_workspace:
root: .
paths:
- RUN_MMI_OPTIONAL
- dist-test-mmi-playwright
- builds-test-mmi-playwright
- store_artifacts:
Expand Down Expand Up @@ -1008,7 +974,7 @@ jobs:
command: ./development/shellcheck.sh

test-lint-lockfile:
executor: node-browsers-medium
executor: node-browsers-medium-plus
steps:
- run: *shallow-git-clone-and-enable-vnc
- run: sudo corepack enable
Expand Down Expand Up @@ -1250,7 +1216,7 @@ jobs:
command: mv ./builds-test-flask-mv2 ./builds
- run:
name: test:e2e:firefox:flask
command: ENABLE_MV3=false .circleci/scripts/test-run-e2e.sh yarn test:e2e:firefox:flask
command: .circleci/scripts/test-run-e2e.sh yarn test:e2e:firefox:flask
no_output_timeout: 5m
- store_artifacts:
path: test-artifacts
Expand Down Expand Up @@ -1306,15 +1272,15 @@ jobs:
- store_test_results:
path: test/test-results/e2e

test-e2e-mmi-playwright - OPTIONAL:
test-e2e-mmi-playwright:
executor: playwright
parallelism: 2
steps:
- run: *shallow-git-clone-and-enable-vnc
- run: corepack enable
- attach_workspace:
at: .
- run: *check-mmi-optional
- run: *check-mmi-trigger
- run:
name: Move test build to dist
command: mv ./dist-test-mmi-playwright ./dist
Expand Down Expand Up @@ -1393,7 +1359,7 @@ jobs:
command: mv ./builds-test-mv2 ./builds
- run:
name: test:e2e:firefox
command: ENABLE_MV3=false .circleci/scripts/test-run-e2e.sh yarn test:e2e:firefox
command: .circleci/scripts/test-run-e2e.sh yarn test:e2e:firefox
no_output_timeout: 5m
- store_artifacts:
path: test-artifacts
Expand Down Expand Up @@ -1743,3 +1709,18 @@ jobs:
- run:
name: All Tests Passed
command: echo 'whew - everything passed!'

check-mmi-trigger:
executor: node-browsers-medium
steps:
- checkout
- run:
name: Check for MMI Team Label or Reviewer
command: ./.circleci/scripts/check_mmi_trigger.sh
- store_artifacts:
path: mmi_trigger.env
destination: mmi_trigger.env
- persist_to_workspace:
root: .
paths:
- mmi_trigger.env
60 changes: 60 additions & 0 deletions .circleci/scripts/check_mmi_trigger.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash
set -eo pipefail

# Ensure required environment variables are set
if [ -z "$CIRCLE_PULL_REQUEST" ] || [ -z "$GITHUB_TOKEN" ]; then
echo "This appears to be a fork or required environment variables are not set."
echo "Skipping MMI tests."
echo "run_mmi_tests=false" > mmi_trigger.env
exit 0
fi

# Extract PR number from the pull request URL
PR_NUMBER=$(echo "$CIRCLE_PULL_REQUEST" | awk -F'/' '{print $NF}')

# Define repository details
REPO_OWNER="$CIRCLE_PROJECT_USERNAME"
REPO_NAME=$(basename "$CIRCLE_REPOSITORY_URL" .git)

# Fetch PR details using GitHub API
PR_DETAILS=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/pulls/$PR_NUMBER")

# Fetch submitted reviews
SUBMITTED_REVIEWS=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/pulls/$PR_NUMBER/reviews")

# Check for label 'team-mmi'
LABEL_EXISTS=$(jq -r '.labels[]? | select(.name == "team-mmi") | length > 0' <<< "$PR_DETAILS")

# Check for individual reviewer 'mmi'
REVIEWER_REQUESTED=$(jq -r '.requested_reviewers[]? | select(.login == "mmi") | length > 0' <<< "$PR_DETAILS")

# Check for team reviewer 'mmi'
TEAM_REQUESTED=$(jq -r '.requested_teams[]? | select(.slug == "mmi") | length > 0' <<< "$PR_DETAILS")

# Check if 'mmi' submitted a review
REVIEWER_SUBMITTED=$(jq -r '.[]? | select(.user.login == "mmi") | length > 0' <<< "$SUBMITTED_REVIEWS")

# Determine which condition was met and trigger tests if needed
if [[ "$LABEL_EXISTS" == "true" || "$REVIEWER_REQUESTED" == "true" || "$TEAM_REQUESTED" == "true" || "$REVIEWER_SUBMITTED" == "true" ]]; then
echo "run_mmi_tests=true" > mmi_trigger.env

# Log exactly which condition was met
echo "Conditions met:"
if [[ "$LABEL_EXISTS" == "true" ]]; then
echo "- Label 'team-mmi' found."
fi
if [[ "$REVIEWER_REQUESTED" == "true" ]]; then
echo "- Reviewer 'mmi' requested."
fi
if [[ "$TEAM_REQUESTED" == "true" ]]; then
echo "- Team 'mmi' requested."
fi
if [[ "$REVIEWER_SUBMITTED" == "true" ]]; then
echo "- Reviewer 'mmi' submitted a review."
fi
else
echo "run_mmi_tests=false" > mmi_trigger.env
echo "Skipping MMI tests: Neither the 'team-mmi' label was found nor a reviewer from the 'MetaMask/mmi' team was assigned."
fi
6 changes: 5 additions & 1 deletion .circleci/scripts/git-diff-develop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type PRInfo = {
ref: string;
};
body: string;
labels: { name: string }[];
};

/**
Expand Down Expand Up @@ -123,7 +124,7 @@ async function storeGitDiffOutputAndPrBody() {
fs.mkdirSync(CHANGED_FILES_DIR, { recursive: true });

console.log(
`Determining whether this run is for a PR targeting ${MAIN_BRANCH}`,
`Determining whether to run git diff...`,
);
if (!PR_NUMBER) {
console.log('Not a PR, skipping git diff');
Expand All @@ -140,6 +141,9 @@ async function storeGitDiffOutputAndPrBody() {
console.log(`This is for a PR targeting '${baseRef}', skipping git diff`);
writePrBodyToFile(prInfo.body);
return;
} else if (prInfo.labels.some(label => label.name === 'skip-e2e-quality-gate')) {
console.log('PR has the skip-e2e-quality-gate label, skipping git diff');
return;
}

console.log('Attempting to get git diff...');
Expand Down
42 changes: 0 additions & 42 deletions .circleci/scripts/install-dependencies.sh

This file was deleted.

4 changes: 2 additions & 2 deletions .circleci/scripts/test-run-e2e-timeout-minutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { filterE2eChangedFiles } from '../../test/e2e/changedFilesUtil';

const changedOrNewTests = filterE2eChangedFiles();

//15 minutes, plus 3 minutes for every changed file, up to a maximum of 30 minutes
const extraTime = Math.min(15 + changedOrNewTests.length * 3, 30);
// 20 minutes, plus 3 minutes for every changed file, up to a maximum of 30 minutes
const extraTime = Math.min(20 + changedOrNewTests.length * 3, 30);

console.log(extraTime);
3 changes: 3 additions & 0 deletions .depcheckrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ ignores:
- '@babel/plugin-transform-logical-assignment-operators'
# trezor
- 'ts-mixer'
- '@testing-library/dom'
- 'mini-css-extract-plugin'
- 'webpack-cli'

# files depcheck should not parse
ignorePatterns:
Expand Down
6 changes: 4 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,16 +307,18 @@ module.exports = {
{
files: [
'**/__snapshots__/*.snap',
'app/scripts/controllers/app-state.test.js',
'app/scripts/controllers/app-state-controller.test.ts',
'app/scripts/controllers/mmi-controller.test.ts',
'app/scripts/controllers/alert-controller.test.ts',
'app/scripts/metamask-controller.actions.test.js',
'app/scripts/detect-multiple-instances.test.js',
'app/scripts/controllers/bridge.test.ts',
'app/scripts/controllers/swaps/**/*.test.js',
'app/scripts/controllers/swaps/**/*.test.ts',
'app/scripts/controllers/metametrics.test.js',
'app/scripts/controllers/permissions/**/*.test.js',
'app/scripts/controllers/preferences.test.js',
'app/scripts/controllers/preferences-controller.test.ts',
'app/scripts/controllers/account-tracker-controller.test.ts',
'app/scripts/lib/**/*.test.js',
'app/scripts/metamask-controller.test.js',
'app/scripts/migrations/*.test.js',
Expand Down
7 changes: 6 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ privacy-snapshot.json @MetaMask/extension-privacy-reviewers
.devcontainer/ @MetaMask/library-admins @HowardBraham @plasmacorral

# Confirmations team to own code for confirmations on UI.
ui/pages/confirmations @MetaMask/confirmations
app/scripts/lib/ppom @MetaMask/confirmations
app/scripts/lib/signature @MetaMask/confirmations
app/scripts/lib/transaction/decode @MetaMask/confirmations
app/scripts/lib/transaction/metrics.* @MetaMask/confirmations
app/scripts/lib/transaction/util.* @MetaMask/confirmations
ui/pages/confirmations @MetaMask/confirmations

# MMI team is responsible for code related with Institutioanl version of MetaMask
ui/pages/institutional @MetaMask/mmi
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 }}
6 changes: 4 additions & 2 deletions .github/workflows/fitness-functions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ name: Fitness Functions CI

on:
pull_request:
types: [assigned, opened, synchronize, reopened]
types:
- opened
- reopened
- synchronize

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
Loading

0 comments on commit b49a9a4

Please sign in to comment.