Skip to content

Commit

Permalink
fix: fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
sahar-fehri committed Sep 20, 2024
2 parents 6ff9669 + 27d8a54 commit e5e85e4
Show file tree
Hide file tree
Showing 506 changed files with 15,014 additions and 14,511 deletions.
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);
5 changes: 4 additions & 1 deletion .circleci/scripts/test-run-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ then
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 ]
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
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 }}
72 changes: 0 additions & 72 deletions .github/workflows/run-unit-tests.yml

This file was deleted.

22 changes: 0 additions & 22 deletions .github/workflows/sonar.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ licenseInfos.json
html-report/

/app/images/branding

/changed-files
2 changes: 1 addition & 1 deletion .storybook/metamask-storybook-theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
export const metamaskStorybookTheme = {
brandTitle: 'MetaMask Storybook',
// Typography
fontBase: 'Euclid Circular B, Roboto, Helvetica, Arial, sans-serif',
fontBase: 'Euclid Circular B, Helvetica, Arial, sans-serif',
};
20 changes: 18 additions & 2 deletions .storybook/test-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import { draftTransactionInitialState } from '../ui/ducks/send';
import { KeyringType } from '../shared/constants/keyring';
import { NetworkStatus } from '@metamask/network-controller';
import { EthAccountType } from '@metamask/keyring-api';
import { CHAIN_IDS } from '../shared/constants/network';
import {
CHAIN_IDS,
LINEA_MAINNET_DISPLAY_NAME,
} from '../shared/constants/network';
import { copyable, divider, heading, panel, text } from '@metamask/snaps-sdk';
import { getJsxElementFromComponent } from '@metamask/snaps-utils';
import { FirstTimeFlowType } from '../shared/constants/onboarding';
Expand Down Expand Up @@ -1224,6 +1227,7 @@ const state = {
rpcUrl: 'https://testrpc.com',
chainId: '0x1',
nickname: 'mainnet',
name: 'mainnet',
blockExplorerUrl: 'https://etherscan.io',
metadata: {
EIPS: { 1559: true },
Expand All @@ -1232,11 +1236,22 @@ const state = {
},
{
id: 'test-networkConfigurationId-2',
rpcUrl: 'https://testrpc2.com',
chainId: '0xe708',
nickname: LINEA_MAINNET_DISPLAY_NAME,
name: LINEA_MAINNET_DISPLAY_NAME,
blockExplorerUrl: 'https://lineascan.build',
metadata: { EIPS: { 1559: true }, status: NetworkStatus.Available },
},
{
id: 'test-networkConfigurationId-3',
rpcUrl: 'http://localhost:8545',
chainId: '0x539',
name: 'test network',
ticker: 'ETH',
nickname: 'Localhost 8545',
}),
},
),
accountTokens: {
'0x64a845a5b02460acf8a3d84503b0d68d028b4bb4': {
'0x1': [
Expand Down Expand Up @@ -1280,6 +1295,7 @@ const state = {
ipfsGateway: 'dweb.link',
migratedPrivacyMode: false,
selectedAddress: '0x9d0ba4ddac06032527b140912ec808ab9451b788',
selectedNetworkClientId: 'test-networkConfigurationId-1',
metaMetricsId:
'0xc2377d11fec1c3b7dd88c4854240ee5e3ed0d9f63b00456d98d80320337b827f',
currentCurrency: 'usd',
Expand Down

This file was deleted.

Loading

0 comments on commit e5e85e4

Please sign in to comment.