Skip to content

Commit

Permalink
Merge pull request #27411 from MetaMask/Version-v12.5.0
Browse files Browse the repository at this point in the history
Version v12.5.0
  • Loading branch information
danjm authored Oct 21, 2024
2 parents 626289d + ab0250e commit 22bf4ad
Show file tree
Hide file tree
Showing 1,097 changed files with 45,154 additions and 27,459 deletions.
126 changes: 66 additions & 60 deletions .circleci/config.yml

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions .circleci/scripts/enable-vnc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

# This script is based on the documentation from CircleCI, which does not work as written
# https://circleci.com/docs/browser-testing/#interacting-with-the-browser-over-vnc

set -e
set -u
set -o pipefail
set -x

cd "${HOME}/project"

# Install a VNC server
readonly LOCK_FILE="installed.lock"
if [ ! -f "${LOCK_FILE}" ]; then
sudo apt update
sudo apt install -y x11vnc

touch "${LOCK_FILE}"
fi

# Start VNC server
if ! pgrep x11vnc > /dev/null; then
x11vnc -display "$DISPLAY" -bg -forever -nopw -quiet -listen localhost -xkb -rfbport 5901 -passwd password
fi
8 changes: 8 additions & 0 deletions .circleci/scripts/test-run-e2e-timeout-minutes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
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);

console.log(extraTime);
16 changes: 14 additions & 2 deletions .circleci/scripts/test-run-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,23 @@ then
exit 1
fi

# Skip running e2e tests if we're doing "Rerun job with SSH" and we're not on the first node
if netstat -tnlp | grep -q 'circleci-agent' && [ "$CIRCLE_NODE_INDEX" -ne 0 ]
then
printf '"Rerun job with SSH" and not on the first node, shutting down\n'
circleci-agent step halt
exit 1
fi

TIMEOUT_MINUTES=$(yarn tsx .circleci/scripts/test-run-e2e-timeout-minutes.ts)
echo "TIMEOUT_MINUTES: $TIMEOUT_MINUTES"

# Run the actual test command from the parameters
timeout 20m "$@" --retries 1
timeout "${TIMEOUT_MINUTES}"m "$@" --retries 1

# Error code 124 means the command timed out
if [ $? -eq 124 ]; then
if [ $? -eq 124 ]
then
# Once deleted, if someone tries to "Rerun failed tests" the result will be
# "Error: can not rerun failed tests: no failed tests could be found"
echo 'Timeout error, deleting the test results'
Expand Down
4 changes: 2 additions & 2 deletions .circleci/scripts/validate-locales-only.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ const { readChangedFiles } = require('../../test/e2e/changedFilesUtil.js');
* Fails the build if any changed files are outside of the /_locales/ directory.
* Fails if no changed files are detected.
*/
async function validateLocalesOnlyChangedFiles() {
const changedFiles = await readChangedFiles();
function validateLocalesOnlyChangedFiles() {
const changedFiles = readChangedFiles();
if (!changedFiles || changedFiles.length === 0) {
console.error('Failure: No changed files detected.');
process.exit(1);
Expand Down
1 change: 1 addition & 0 deletions .depcheckrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ ignores:
- '@sentry/cli' # invoked as `sentry-cli`
- 'chromedriver'
- 'depcheck' # ooo meta
- 'ethers' # ethers @5.7.0 expected by @account-abstraction/contracts, but conflicts with transitive [email protected]
- 'ganache-cli'
- 'geckodriver'
- 'jest'
Expand Down
30 changes: 30 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,36 @@ module.exports = {
plugins: ['@metamask/design-tokens'],
rules: {
'@metamask/design-tokens/color-no-hex': 'warn',
'import/no-restricted-paths': [
'error',
{
basePath: './',
zones: [
{
target: './app',
from: './ui',
message:
'Should not import from UI in background, use shared directory instead',
},
{
target: './ui',
from: './app',
message:
'Should not import from background in UI, use shared directory instead',
},
{
target: './shared',
from: './app',
message: 'Should not import from background in shared',
},
{
target: './shared',
from: './ui',
message: 'Should not import from UI in shared',
},
],
},
],
},
overrides: [
/**
Expand Down
23 changes: 22 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

* @MetaMask/extension-devs
development/ @MetaMask/extension-devs @kumavis
lavamoat/ @MetaMask/extension-devs @MetaMask/supply-chain @MetaMask/snaps-devs
lavamoat/ @MetaMask/extension-devs @MetaMask/supply-chain

# The offscreen.ts script file that is included in the offscreen document html
# file is responsible, at present, for loading the snaps execution environment
Expand Down Expand Up @@ -93,3 +93,24 @@ app/scripts/controllers/swaps @MetaMask/swaps-engineers
shared/constants/permissions.ts @MetaMask/snaps-devs
ui/helpers/utils/permission.js @MetaMask/snaps-devs
ui/hooks/useTransactionInsights.js @MetaMask/snaps-devs

# Wallet UX
ui/components/multichain @MetaMask/wallet-ux
ui/components/app/whats-new-popup @MetaMask/wallet-ux
ui/css @MetaMask/wallet-ux
ui/pages/home @MetaMask/wallet-ux
ui/pages/onboarding-flow @MetaMask/wallet-ux

# Assets
ui/components/app/add-network @MetaMask/metamask-assets
ui/components/app/auto-detect-nft @MetaMask/metamask-assets
ui/components/app/auto-detect-token @MetaMask/metamask-assets
ui/components/app/import-token @MetaMask/metamask-assets
ui/components/app/nft-default-image @MetaMask/metamask-assets
ui/components/app/nft-details @MetaMask/metamask-assets
ui/components/app/nft-options @MetaMask/metamask-assets
ui/components/app/nfts-detection-notice-import-nfts @MetaMask/metamask-assets
ui/components/app/nfts-items @MetaMask/metamask-assets
ui/components/app/nfts-tab @MetaMask/metamask-assets
ui/components/ui/deprecated-networks @MetaMask/metamask-assets
ui/components/ui/nft-collection-image @MetaMask/metamask-assets
4 changes: 2 additions & 2 deletions .github/scripts/check-template-and-add-labels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ enum RegressionStage {
Production
}

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

main().catch((error: Error): void => {
console.error(error);
Expand Down Expand Up @@ -82,7 +82,7 @@ async function main(): Promise<void> {
}

// If author is not part of the MetaMask organisation
if (!(await userBelongsToMetaMaskOrg(octokit, labelable?.author))) {
if (!knownBots.includes(labelable?.author) && !(await userBelongsToMetaMaskOrg(octokit, labelable?.author))) {
// Add external contributor label to the issue
await addLabelToLabelable(octokit, labelable, externalContributorLabel);
}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/create-bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
payload=$(cat <<EOF
{
"title": "v${{ env.version }} Bug Report",
"body": "This bug report was automatically created by a GitHub action upon the creation of release branch \`Version-v${{ env.version }}\` (release cut).\n\n**Expected actions for release engineers:**\n\n1. Convert this issue into a Zenhub epic and link all bugs identified during the release regression testing phase to this epic.\n\n2. After completing the first regression run, move this epic to \"Regression Completed\" on the [Extension Release Regression board](https://app.zenhub.com/workspaces/extension-release-regression-6478c62d937eaa15e95c33c5/board?filterLogic=any&labels=release-${{ env.version }},release-task).\n\nNote that once the release is prepared for store submission, meaning the \`Version-v${{ env.version }}\` branch merges into \`master\`, another GitHub action will automatically close this epic.",
"body": "**What is this bug report issue for?**\n\n1. This issue is used to track release dates on this [Github Project board](https://github.com/orgs/MetaMask/projects/86/views/1), which content then gets pulled into our metrics system.\n\n2. This issue is also used by our Zapier automations, to determine if automated notifications shall be sent on Slack for release \`${{ env.version }}\`. Notifications will only be sent as long as this issue is open.\n\n**Who created and/or closed this issue?**\n\n- This issue was automatically created by a GitHub action upon the creation of the release branch \`Version-v${{ env.version }}\`, indicating the release was cut.\n\n- This issue gets automatically closed by another GitHub action, once the \`Version-v${{ env.version }}\` branch merges into \`master\`, indicating the release is prepared for store submission.",
"labels": ["type-bug", "team-extension-platform", "regression-RC-${{ env.version }}"]
}
EOF
Expand Down
20 changes: 0 additions & 20 deletions .github/workflows/run-integration-tests.yml

This file was deleted.

142 changes: 142 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
name: Run tests

on:
push:
branches:
- develop
- master
pull_request:
types:
- opened
- reopened
- synchronize

jobs:
test-unit:
name: Unit tests
runs-on: ubuntu-latest
strategy:
matrix:
shard: [1, 2, 3, 4, 5, 6]
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup environment
uses: metamask/github-tools/.github/actions/setup-environment@main

- name: test:unit:coverage
run: yarn test:unit:coverage --shard=${{ matrix.shard }}/${{ strategy.job-total }}

- name: Rename coverage
run: mv coverage/unit/coverage-final.json coverage/unit/coverage-unit-${{matrix.shard}}.json

- uses: actions/upload-artifact@v4
with:
name: coverage-unit-${{matrix.shard}}
path: coverage/unit/coverage-unit-${{matrix.shard}}.json

test-webpack:
name: Webpack tests
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup environment
uses: metamask/github-tools/.github/actions/setup-environment@main

- name: test:unit:webpack:coverage
run: yarn test:unit:webpack:coverage

- name: Rename coverage
run: mv coverage/webpack/coverage-final.json coverage/webpack/coverage-webpack.json

- uses: actions/upload-artifact@v4
with:
name: coverage-webpack
path: coverage/webpack/coverage-webpack.json

test-integration:
name: Integration tests
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup environment
uses: metamask/github-tools/.github/actions/setup-environment@main

- name: test:integration:coverage
run: yarn test:integration:coverage

- name: Rename coverage
run: mv coverage/integration/coverage-final.json coverage/integration/coverage-integration.json

- uses: actions/upload-artifact@v4
with:
name: coverage-integration
path: coverage/integration/coverage-integration.json

sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
needs:
- test-unit
- test-webpack
- test-integration
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for better relevancy of analysis

- name: Setup environment
uses: metamask/github-tools/.github/actions/setup-environment@main

- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: coverage
merge-multiple: true

- name: Merge coverage reports
run: yarn nyc merge coverage .nyc_output/coverage-final.json && yarn nyc report --reporter lcov

- uses: actions/upload-artifact@v4
with:
name: lcov.info
path: coverage/lcov.info

- name: Get Sonar coverage
id: get-sonar-coverage
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
projectKey=$(grep 'sonar.projectKey=' sonar-project.properties | cut -d'=' -f2)
sonar_coverage=$(curl --silent --header "Authorization: Bearer $SONAR_TOKEN" "https://sonarcloud.io/api/measures/component?component=$projectKey&metricKeys=coverage" | jq -r '.component.measures[0].value // 0')
echo "The Sonar coverage of $projectKey is $sonar_coverage%."
echo 'SONAR_COVERAGE='"$sonar_coverage" >> "$GITHUB_OUTPUT"
- name: Validate test coverage
env:
SONAR_COVERAGE: ${{ steps.get-sonar-coverage.outputs.SONAR_COVERAGE }}
run: |
coverage=$(yarn nyc report --reporter=text-summary | grep 'Lines' | awk '{gsub(/%/, ""); print $3}')
if [ -z "$coverage" ]; then
echo "::error::Could not retrieve test coverage."
exit 1
fi
if (( $(echo "$coverage < $SONAR_COVERAGE" | bc -l) )); then
echo "::error::Quality gate failed for test coverage. Current test coverage is $coverage%, please increase coverage to at least $SONAR_COVERAGE%."
exit 1
else
echo "Test coverage is $coverage%. Quality gate passed."
fi
- name: SonarCloud Scan
# This is SonarSource/[email protected]
uses: SonarSource/sonarcloud-github-action@4b4d7634dab97dcee0b75763a54a6dc92a9e6bc1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Loading

0 comments on commit 22bf4ad

Please sign in to comment.