Skip to content

Commit

Permalink
Merge branch 'develop' into weizman-patch-lavadome-try
Browse files Browse the repository at this point in the history
  • Loading branch information
weizman authored Sep 18, 2024
2 parents 6bdd808 + eadc707 commit 6338a91
Show file tree
Hide file tree
Showing 1,437 changed files with 58,233 additions and 37,657 deletions.
273 changes: 143 additions & 130 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
45 changes: 41 additions & 4 deletions .circleci/scripts/git-diff-develop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,26 @@ import { promisify } from 'util';

const exec = promisify(execCallback);

const MAIN_BRANCH = 'develop';

/**
* Get the target branch for the given pull request.
*
* @returns The name of the branch targeted by the PR.
*/
async function getBaseRef(): Promise<string | null> {
if (!process.env.CIRCLE_PULL_REQUEST) {
return null;
}

// We're referencing the CIRCLE_PULL_REQUEST environment variable within the script rather than
// passing it in because this makes it easier to use Bash parameter expansion to extract the
// PR number from the URL.
const result = await exec(`gh pr view --json baseRefName "\${CIRCLE_PULL_REQUEST##*/}" --jq '.baseRefName'`);
const baseRef = result.stdout.trim();
return baseRef;
}

/**
* Fetches the git repository with a specified depth.
*
Expand Down Expand Up @@ -76,14 +96,31 @@ async function gitDiff(): Promise<string> {
*/
async function storeGitDiffOutput() {
try {
console.log("Attempting to get git diff...");
const diffOutput = await gitDiff();
console.log(diffOutput);

// Create the directory
// This is done first because our CirleCI config requires that this directory is present,
// even if we want to skip this step.
const outputDir = 'changed-files';
fs.mkdirSync(outputDir, { recursive: true });

console.log(`Determining whether this run is for a PR targetting ${MAIN_BRANCH}`)
if (!process.env.CIRCLE_PULL_REQUEST) {
console.log("Not a PR, skipping git diff");
return;
}

const baseRef = await getBaseRef();
if (baseRef === null) {
console.log("Not a PR, skipping git diff");
return;
} else if (baseRef !== MAIN_BRANCH) {
console.log(`This is for a PR targeting '${baseRef}', skipping git diff`);
return;
}

console.log("Attempting to get git diff...");
const diffOutput = await gitDiff();
console.log(diffOutput);

// Store the output of git diff
const outputPath = path.resolve(outputDir, 'changed-files.txt');
fs.writeFileSync(outputPath, diffOutput.trim());
Expand Down
2 changes: 1 addition & 1 deletion .circleci/scripts/release-create-gh-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ then
install_github_cli

printf '%s\n' 'Creating GitHub Release'
release_body="$(awk -v version="${tag##v}" -f .circleci/scripts/show-changelog.awk CHANGELOG.md)"
release_body="$(awk -v version="[${tag##v}]" -f .circleci/scripts/show-changelog.awk CHANGELOG.md)"
hub release create \
--attach builds/metamask-chrome-*.zip \
--attach builds-mv2/metamask-firefox-*.zip \
Expand Down
21 changes: 21 additions & 0 deletions .circleci/scripts/test-run-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,25 @@ 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

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

# Error code 124 means the command timed out
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'
rm -rf test/test-results/e2e
exit 124
fi

exit 0
17 changes: 17 additions & 0 deletions .depcheckrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,23 @@ ignores:
- 'resolve-url-loader'
# jest environments
- 'jest-environment-jsdom'
# webpack
- '@pmmmwh/react-refresh-webpack-plugin' # dev tool
- 'webpack-dev-server' # dev tool
- 'html-bundler-webpack-plugin' # build tool
- 'postcss-loader' # build tool
- '@swc/helpers' # build tool
- browserslist # build tool
- 'buffer' # polyfill
- 'crypto-browserify' # polyfill
- 'process' # polyfill
- 'stream-http' # polyfill
- 'rimraf' # misc: install helper
- 'json-schema-to-ts' # misc: typescript helper
- 'https-browserify' # polyfill
- 'path-browserify' # polyfill
- 'nyc' # coverage
- 'core-js-pure' # polyfills
# babel
- '@babel/plugin-transform-logical-assignment-operators'
# trezor
Expand Down
5 changes: 2 additions & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
],
"settings": {
"editor.formatOnSave": true,
"git.autofetch": true,
"git.ignoreRebaseWarning": true,
"git.rebaseWhenSync": true,
"gitlens.showWelcomeOnInstall": false
Expand Down Expand Up @@ -48,13 +47,13 @@
}
},

"postAttachCommand": "/usr/local/share/desktop-init.sh && git pull --rebase; yarn download-builds",
"postAttachCommand": "/usr/local/share/desktop-init.sh && git pull; yarn download-builds",

// This is a working Infura key, but it's on the Free Plan and has very limited requests per second
// If you want to use your own INFURA_PROJECT_ID, follow the instructions in README.md
"postCreateCommand": "if [ -z \"$INFURA_PROJECT_ID\" ]; then echo 'INFURA_PROJECT_ID=3d110a0fce9e49b08d2ee584e19a05ba' > .metamaskrc; fi",

"runArgs": ["--shm-size=1g"],

"updateContentCommand": "sudo .devcontainer/install.sh && yarn --immutable && yarn tsx .devcontainer/setup-browsers.ts && echo 'export DISPLAY=:1' >> ~/.bashrc"
"updateContentCommand": "sudo .devcontainer/install.sh && corepack enable && COREPACK_ENABLE_DOWNLOAD_PROMPT=0 yarn --immutable && yarn tsx .devcontainer/setup-browsers.ts && echo 'export DISPLAY=:1' >> ~/.bashrc"
}
6 changes: 5 additions & 1 deletion .devcontainer/download-builds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ async function getBuilds(branch: string, jobNames: string[]) {

const artifacts = await response.json();

if (!artifacts || artifacts.length === 0) {
if (
!artifacts ||
artifacts.length === 0 ||
artifacts.message === 'Not Found'
) {
return [];
}

Expand Down
23 changes: 22 additions & 1 deletion .github/CODEOWNERS
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
89 changes: 0 additions & 89 deletions .github/scripts/add-team-label.ts

This file was deleted.

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
4 changes: 3 additions & 1 deletion .github/workflows/add-team-label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ on:

jobs:
add-team-label:
uses: metamask/github-tools/.github/workflows/add-team-label.yml@main
uses: metamask/github-tools/.github/workflows/add-team-label.yml@058012b49ff2fbd9649c566ba43b29497f93b21d
permissions:
pull-requests: write
secrets:
PERSONAL_ACCESS_TOKEN: ${{ secrets.RELEASE_LABEL_TOKEN }}
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: 20 additions & 0 deletions .github/workflows/run-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,26 @@ jobs:
name: coverage-${{matrix.shard}}
path: coverage/coverage-${{matrix.shard}}.json

test-webpack:
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/coverage-final.json coverage/coverage-webpack.json

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

report-coverage:
runs-on: ubuntu-latest
needs:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/update-attributions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
- name: Generate Attributions
run: yarn attributions:generate
- name: Cache attributions file
uses: actions/cache/save@v3
uses: actions/cache/save@v4
with:
path: attribution.txt
key: cache-build-${{ needs.prepare.outputs.COMMIT_SHA }}
Expand Down Expand Up @@ -113,7 +113,7 @@ jobs:
id: commit-sha
run: echo "COMMIT_SHA=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
- name: Restore attributions file
uses: actions/cache/restore@v3
uses: actions/cache/restore@v4
with:
path: attribution.txt
key: cache-build-${{ needs.prepare.outputs.COMMIT_SHA }}
Expand Down
Loading

0 comments on commit 6338a91

Please sign in to comment.