Fix 'yarn setup' on M1 Macs (#11887)

There are a few issues encountered when running `yarn setup` on new
Apple Silicon (aka M1, aka arm64) Macs:

* The script halts when attempting to run the install step for
  the `chromedriver` package with the message "Only Mac 64 bits
  supported". This is somewhat misleading as it seems to indicate that
  chromedriver can only be installed on a 64-bit Mac. However, what I
  think is happening is that the installation script for `chromedriver`
  is not able to detect that an arm64 CPU *is* a 64-bit CPU. After
  looking through the `chromedriver` repo, it appears that 87.0.1 is the
  first version that adds a proper check ([1]).

  Note that upgrading chromedriver caused the Chrome-specific tests to
  fail intermittently on CI. I was not able to 100% work out the reason
  for this, but ensuring that X (which provides a way for Chrome to run
  in a GUI setting from the command line) is available seems to fix
  these issues.

* The script also halts when attempting to run the install step for
  the `electron` package. This happens because for the version of
  `electron` we are using (9.4.2), there is no available binary for
  arm64. It appears that Electron 11.x was the first version to support
  arm64 Macs ([2]). This is a bit trickier to resolve because we don't
  explicitly rely on `electron` — that's brought in by `react-devtools`.
  The first version of `react-devtools` that relies on `electron` 11.x
  is 4.11.0 ([3]).

[1]: 469dd0a6ee
[2]: https://www.electronjs.org/blog/apple-silicon
[3]: https://github.com/facebook/react/blob/main/packages/react-devtools/CHANGELOG.md#4110-april-9-2021
feature/default_network_editable
Elliot Winkler 3 years ago committed by GitHub
parent a4c0133bc5
commit 8ffebb294b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      .circleci/scripts/chrome-install.sh
  2. 31
      development/lib/retry.js
  3. 4
      package.json
  4. 2
      test/e2e/benchmark.js
  5. 4
      test/e2e/helpers.js
  6. 4
      test/e2e/metamask-ui.spec.js
  7. 2
      test/e2e/run-e2e-test.js
  8. 17
      test/e2e/x-server.js
  9. 116
      yarn.lock

@ -4,11 +4,11 @@ set -e
set -u
set -o pipefail
CHROME_VERSION='79.0.3945.117-1'
CHROME_VERSION='87.0.4280.88-1'
CHROME_BINARY="google-chrome-stable_${CHROME_VERSION}_amd64.deb"
CHROME_BINARY_URL="http://mirror.cs.uchicago.edu/google-chrome/pool/main/g/google-chrome-stable/${CHROME_BINARY}"
CHROME_BINARY_URL="https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/${CHROME_BINARY}"
CHROME_BINARY_SHA512SUM='2d4f76202219a40e560477d79023fa4a847187a086278924a9d916dcd5fbefafdcf7dfd8879fae907b8276b244e71a3b8a1b00a88dee87b18738ce31134a6713'
CHROME_BINARY_SHA512SUM='19eea1d1be171cab60ce5135572da9388b4b72e313118478b53f65c0bf2293733809282736b98ef828a208b7426e5191258f8c666cba7510b8bf5c92d0010a47'
wget -O "${CHROME_BINARY}" -t 5 "${CHROME_BINARY_URL}"
@ -24,6 +24,4 @@ fi
rm -rf "${CHROME_BINARY}"
sudo sed -i 's|HERE/chrome"|HERE/chrome" --disable-setuid-sandbox --no-sandbox|g' "/opt/google/chrome/google-chrome"
printf '%s\n' "CHROME ${CHROME_VERSION} configured"

@ -1,13 +1,31 @@
/**
* Run the given function, retrying it upon failure until reaching the
* specified number of retries.
* Re-runs the given function until it returns a resolved promise or the number
* of retries is exceeded, whichever comes first (with an optional delay in
* between retries).
*
* @param {number} retries - The number of retries upon failure to attempt.
* @param {function} functionToRetry - The function that will be retried upon failure.
* @param {Object} args - A set of arguments and options.
* @param {number} args.retries - The maximum number of times to re-run the
* function on failure.
* @param {number} args.delay - The amount of time (in milliseconds) to wait in
* between retries. (Default: 0)
* @param {string} args.rejectionMessage - The message for the rejected promise
* this function will return in the event of failure. (Default: "Retry limit
* reached")
* @param {function} functionToRetry - The function that is run and tested for
* failure.
* @returns {Promise<null | Error>} a promise that either resolves to null if
* the function is successful or is rejected with rejectionMessage otherwise.
*/
async function retry(retries, functionToRetry) {
async function retry(
{ retries, delay = 0, rejectionMessage = 'Retry limit reached' },
functionToRetry,
) {
let attempts = 0;
while (attempts <= retries) {
if (attempts > 0 && delay > 0) {
await new Promise((resolve) => setTimeout(resolve, delay));
}
try {
await functionToRetry();
return;
@ -17,7 +35,8 @@ async function retry(retries, functionToRetry) {
attempts += 1;
}
}
throw new Error('Retry limit reached');
throw new Error(rejectionMessage);
}
module.exports = { retry };

@ -249,7 +249,7 @@
"brfs": "^2.0.2",
"browserify": "^16.5.1",
"chalk": "^3.0.0",
"chromedriver": "^79.0.0",
"chromedriver": "^87.0.1",
"concurrently": "^5.2.0",
"copy-webpack-plugin": "^6.0.3",
"cross-spawn": "^7.0.3",
@ -305,7 +305,7 @@
"pumpify": "^2.0.1",
"randomcolor": "^0.5.4",
"rc": "^1.2.8",
"react-devtools": "^4.10.1",
"react-devtools": "^4.11.0",
"read-installed": "^4.0.3",
"redux-mock-store": "^1.5.4",
"remote-redux-devtools": "^0.5.16",

@ -63,7 +63,7 @@ async function profilePageLoad(pages, numSamples, retries) {
const runResults = [];
for (let i = 0; i < numSamples; i += 1) {
let result;
await retry(retries, async () => {
await retry({ retries }, async () => {
result = await measurePage(pageName);
});
runResults.push(result);

@ -7,6 +7,7 @@ const {
const Ganache = require('./ganache');
const FixtureServer = require('./fixture-server');
const { buildWebDriver } = require('./webdriver');
const { ensureXServerIsRunning } = require('./x-server');
const tinyDelayMs = 200;
const regularDelayMs = tinyDelayMs * 2;
@ -83,6 +84,9 @@ async function withFixtures(options, testSuite) {
});
await segmentServer.start(9090);
}
if (process.env.SELENIUM_BROWSER === 'chrome') {
await ensureXServerIsRunning();
}
const { driver } = await buildWebDriver(driverOptions);
webDriver = driver;

@ -6,6 +6,7 @@ const createStaticServer = require('../../development/create-static-server');
const { tinyDelayMs, regularDelayMs, largeDelayMs } = require('./helpers');
const { buildWebDriver } = require('./webdriver');
const Ganache = require('./ganache');
const { ensureXServerIsRunning } = require('./x-server');
const ganacheServer = new Ganache();
const dappPort = 8080;
@ -39,6 +40,9 @@ describe('MetaMask', function () {
dappServer.on('listening', resolve);
dappServer.on('error', reject);
});
if (process.env.SELENIUM_BROWSER === 'chrome') {
await ensureXServerIsRunning();
}
const result = await buildWebDriver();
driver = result.driver;
await driver.navigate();

@ -73,7 +73,7 @@ async function main() {
process.env.E2E_LEAVE_RUNNING = 'true';
}
await retry(retries, async () => {
await retry({ retries }, async () => {
await runInShell('yarn', ['mocha', '--no-timeouts', e2eTestPath]);
});
}

@ -0,0 +1,17 @@
const { runCommand } = require('../../development/lib/run-command');
const { retry } = require('../../development/lib/retry');
function ensureXServerIsRunning() {
return retry(
{
retries: 3,
delay: 2000,
rejectionMessage: 'X server does not seem to be running?!',
},
() => {
return runCommand('xset', ['q']);
},
);
}
module.exports = { ensureXServerIsRunning };

@ -3765,6 +3765,11 @@
dependencies:
defer-to-connect "^1.0.1"
"@testim/chrome-version@^1.0.7":
version "1.0.7"
resolved "https://registry.yarnpkg.com/@testim/chrome-version/-/chrome-version-1.0.7.tgz#0cd915785ec4190f08a3a6acc9b61fc38fb5f1a9"
integrity sha512-8UT/J+xqCYfn3fKtOznAibsHpiuDshCb0fwgWxRazTT19Igp9ovoXMPhXyLD6m3CKQGTMHgqoxaFfMWaL40Rnw==
"@testing-library/dom@^7.17.1":
version "7.22.2"
resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-7.22.2.tgz#6deaa828500993cc94bdd62875c251b5b5b70d69"
@ -4313,6 +4318,13 @@
dependencies:
"@types/yargs-parser" "*"
"@types/yauzl@^2.9.1":
version "2.9.2"
resolved "https://registry.yarnpkg.com/@types/yauzl/-/yauzl-2.9.2.tgz#c48e5d56aff1444409e39fa164b0b4d4552a7b7a"
integrity sha512-8uALY5LTvSuHgloDVUvWP3pIauILm+8/0pDMokuDYIoNsOkSwd5AiHBTSEJjKTDcZr5z8UpgOWZkxBF4iJftoA==
dependencies:
"@types/node" "*"
"@typescript-eslint/experimental-utils@^4.0.1":
version "4.21.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.21.0.tgz#0b0bb7c15d379140a660c003bdbafa71ae9134b6"
@ -7956,15 +7968,18 @@ chrome-trace-event@^1.0.2:
dependencies:
tslib "^1.9.0"
chromedriver@^79.0.0:
version "79.0.0"
resolved "https://registry.yarnpkg.com/chromedriver/-/chromedriver-79.0.0.tgz#1660ac29924dfcd847911025593d6b6746aeea35"
integrity sha512-DO29C7ntJfzu6q1vuoWwCON8E9x5xzopt7Q41A7Dr7hBKcdNpGw1l9DTt9b+l1qviOWiJLGsD+jHw21ptEHubA==
chromedriver@^87.0.1:
version "87.0.7"
resolved "https://registry.yarnpkg.com/chromedriver/-/chromedriver-87.0.7.tgz#74041e02ff7f633e91b98eb707e2476f713dc4ca"
integrity sha512-7J7iN2rJuSDsKb9BUUMewJt07PuTlZYd809D10dUCT1rjMD3i2jUw7dum9RxdC1xO3aFwMd8TwZ5NR82T+S+Dg==
dependencies:
del "^4.1.1"
extract-zip "^1.6.7"
mkdirp "^0.5.1"
request "^2.88.0"
"@testim/chrome-version" "^1.0.7"
axios "^0.21.1"
del "^6.0.0"
extract-zip "^2.0.1"
https-proxy-agent "^5.0.0"
mkdirp "^1.0.4"
proxy-from-env "^1.1.0"
tcp-port-used "^1.0.1"
ci-info@^1.5.0:
@ -9471,18 +9486,19 @@ del@^3.0.0:
pify "^3.0.0"
rimraf "^2.2.8"
del@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/del/-/del-4.1.1.tgz#9e8f117222ea44a31ff3a156c049b99052a9f0b4"
integrity sha512-QwGuEUouP2kVwQenAsOof5Fv8K9t3D8Ca8NxcXKrIpEHjTXK5J2nXLdP+ALI1cgv8wj7KuwBhTwBkOZSJKM5XQ==
del@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/del/-/del-6.0.0.tgz#0b40d0332cea743f1614f818be4feb717714c952"
integrity sha512-1shh9DQ23L16oXSZKB2JxpL7iMy2E0S9d517ptA1P8iw0alkPtQcrKH7ru31rYtKwF499HkTu+DRzq3TCKDFRQ==
dependencies:
"@types/glob" "^7.1.1"
globby "^6.1.0"
is-path-cwd "^2.0.0"
is-path-in-cwd "^2.0.0"
p-map "^2.0.0"
pify "^4.0.1"
rimraf "^2.6.3"
globby "^11.0.1"
graceful-fs "^4.2.4"
is-glob "^4.0.1"
is-path-cwd "^2.2.0"
is-path-inside "^3.0.2"
p-map "^4.0.0"
rimraf "^3.0.2"
slash "^3.0.0"
delayed-stream@~1.0.0:
version "1.0.0"
@ -10047,10 +10063,10 @@ electron-to-chromium@^1.3.378, electron-to-chromium@^1.3.47, electron-to-chromiu
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.610.tgz#1254eb394acd220a836ea1f203f8cded4e487052"
integrity sha512-eFDC+yVQpEhtlapk4CYDPfV9ajF9cEof5TBcO49L1ETO+aYogrKWDmYpZyxBScMNe8Bo/gJamH4amQ4yyvXg4g==
electron@^9.1.0:
version "9.4.2"
resolved "https://registry.yarnpkg.com/electron/-/electron-9.4.2.tgz#0c76dfc3d317108adac66844b868a9e2e57d48f5"
integrity sha512-WpnJLDFHtj5eIewAi4hMHxGdbwkzjzmxsMu/BtDFCic3wpruchkskL7EV28Sg/IYTAqo6yN5ISfnFaQcLsIdng==
electron@^11.1.0:
version "11.4.12"
resolved "https://registry.yarnpkg.com/electron/-/electron-11.4.12.tgz#3315ce63a37cea5033125f7abcfdcc2f76864a57"
integrity sha512-Kaf4uNaKcGWlBuZwFJ4OZcIN1cfVe9jlGgjm6pUIAJucUsUU7hCFOtaVdZ1sMJR2zbshIbwbiczq8+S61jLfUA==
dependencies:
"@electron/get" "^1.0.1"
"@types/node" "^12.0.12"
@ -12050,7 +12066,7 @@ extglob@^2.0.4:
snapdragon "^0.8.1"
to-regex "^3.0.1"
extract-zip@^1.0.3, extract-zip@^1.6.7:
extract-zip@^1.0.3:
version "1.7.0"
resolved "https://registry.yarnpkg.com/extract-zip/-/extract-zip-1.7.0.tgz#556cc3ae9df7f452c493a0cfb51cc30277940927"
integrity sha512-xoh5G1W/PB0/27lXgMQyIhP5DSY/LhoCsOyZgb+6iMmRtCwVBo55uKaMoEYrDCKQhWvqEip5ZPKAc6eFNyf/MA==
@ -12060,6 +12076,17 @@ extract-zip@^1.0.3, extract-zip@^1.6.7:
mkdirp "^0.5.4"
yauzl "^2.10.0"
extract-zip@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/extract-zip/-/extract-zip-2.0.1.tgz#663dca56fe46df890d5f131ef4a06d22bb8ba13a"
integrity sha512-GDhU9ntwuKyGXdZBUgTIe+vXnWj0fppUEtMDL0+idd5Sta8TGpHssn/eusA9mrPr9qNDym6SxAYZjNvCn/9RBg==
dependencies:
debug "^4.1.1"
get-stream "^5.1.0"
yauzl "^2.10.0"
optionalDependencies:
"@types/yauzl" "^2.9.1"
extsprintf@1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05"
@ -15650,7 +15677,7 @@ is-path-cwd@^1.0.0:
resolved "https://registry.yarnpkg.com/is-path-cwd/-/is-path-cwd-1.0.0.tgz#d225ec23132e89edd38fda767472e62e65f1106d"
integrity sha1-0iXsIxMuie3Tj9p2dHLmLmXxEG0=
is-path-cwd@^2.0.0:
is-path-cwd@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/is-path-cwd/-/is-path-cwd-2.2.0.tgz#67d43b82664a7b5191fd9119127eb300048a9fdb"
integrity sha512-w942bTcih8fdJPJmQHFzkS76NEP8Kzzvmw92cXsazb8intwLqPibPPdXf4ANdKV3rYMuuQYGIWtvz9JilB3NFQ==
@ -15662,13 +15689,6 @@ is-path-in-cwd@^1.0.0:
dependencies:
is-path-inside "^1.0.0"
is-path-in-cwd@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/is-path-in-cwd/-/is-path-in-cwd-2.1.0.tgz#bfe2dca26c69f397265a4009963602935a053acb"
integrity sha512-rNocXHgipO+rvnP6dk3zI20RpOtrAM/kzbB258Uw5BWr3TpXi861yzjo16Dn4hUox07iw5AyeMLHWsujkjzvRQ==
dependencies:
is-path-inside "^2.1.0"
is-path-inside@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-1.0.1.tgz#8ef5b7de50437a3fdca6b4e865ef7aa55cb48036"
@ -15676,12 +15696,10 @@ is-path-inside@^1.0.0:
dependencies:
path-is-inside "^1.0.1"
is-path-inside@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-2.1.0.tgz#7c9810587d659a40d27bcdb4d5616eab059494b2"
integrity sha512-wiyhTzfDWsvwAW53OBWF5zuvaOGlZ6PwYxAbPVDhpm+gM09xKQGjBq/8uYN12aDvMxnAnq3dxTyoSoRNmg5YFg==
dependencies:
path-is-inside "^1.0.2"
is-path-inside@^3.0.2:
version "3.0.3"
resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-3.0.3.tgz#d231362e53a07ff2b0e0ea7fed049161ffd16283"
integrity sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==
is-plain-obj@^1.0.0, is-plain-obj@^1.1, is-plain-obj@^1.1.0:
version "1.1.0"
@ -22549,24 +22567,24 @@ react-dev-utils@^10.0.0:
strip-ansi "6.0.0"
text-table "0.2.0"
react-devtools-core@4.10.1:
version "4.10.1"
resolved "https://registry.yarnpkg.com/react-devtools-core/-/react-devtools-core-4.10.1.tgz#6d57db291aeac9cc45ef9fb4636dd2ab97490daf"
integrity sha512-sXbBjGAWcf9HAblTP/zMtFhGHqxAfIR+GPxONZsSGN9FHnF4635dx1s2LdQWG9rJ+Ehr3nWg+BUAB6P78my5PA==
react-devtools-core@4.16.0:
version "4.16.0"
resolved "https://registry.yarnpkg.com/react-devtools-core/-/react-devtools-core-4.16.0.tgz#c640ab15b98d077bc47f10f84fc8ed3633f537bd"
integrity sha512-fqyVbp+wVVey6O4uVBk5s3J/vTiPludp7lulr6a8asTBm7DIA0vLBbjmAOLCnOlkWcgdy4mjsqOgNCbu8uICWw==
dependencies:
shell-quote "^1.6.1"
ws "^7"
react-devtools@^4.10.1:
version "4.10.1"
resolved "https://registry.yarnpkg.com/react-devtools/-/react-devtools-4.10.1.tgz#579c14fe0b181e222e262a75fc55c2e2e17abc7a"
integrity sha512-gGOu0tcpCdm2+LZNrFgyimImtkYDoi6z5aKMRxxfuRM0VrJpmZakxAwaLs0BMRA9+UUF22Emzku366+m5eBtIQ==
react-devtools@^4.11.0:
version "4.16.0"
resolved "https://registry.yarnpkg.com/react-devtools/-/react-devtools-4.16.0.tgz#89440dfb27b5f57ca8c098e91c9039308ace6395"
integrity sha512-K+EUWY0kWIwhBJSQotn9BnbXsGXM6S55bhZV7MMWQBop8dc/jVBWKklr6vM4jOTg3kxpXiVj7KJDv45hceiSZw==
dependencies:
cross-spawn "^5.0.1"
electron "^9.1.0"
electron "^11.1.0"
ip "^1.1.4"
minimist "^1.2.3"
react-devtools-core "4.10.1"
react-devtools-core "4.16.0"
update-notifier "^2.1.0"
react-dnd-html5-backend@^7.4.4:
@ -23579,7 +23597,7 @@ request-promise-native@^1.0.9:
stealthy-require "^1.1.1"
tough-cookie "^2.3.3"
request@^2.79.0, request@^2.83.0, request@^2.85.0, request@^2.88.0, request@^2.88.2, request@~2.88.0:
request@^2.79.0, request@^2.83.0, request@^2.85.0, request@^2.88.2, request@~2.88.0:
version "2.88.2"
resolved "https://registry.yarnpkg.com/request/-/request-2.88.2.tgz#d73c918731cb5a87da047e207234146f664d12b3"
integrity sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==

Loading…
Cancel
Save