From 93e4d1372ae17df08aa9708099874767906a8697 Mon Sep 17 00:00:00 2001 From: brdy <41711440+BrodyHughes@users.noreply.github.com> Date: Mon, 8 Apr 2024 12:37:39 -0400 Subject: [PATCH] retry test (#1456) --- .github/workflows/build.yml | 128 ++++++-------- e2e/parallel/shortcuts-walletSwitcher.test.ts | 3 + lavamoat/build-webpack/policy.json | 156 +++++++++--------- package.json | 2 +- scripts/e2e-op-serial-tests.sh | 60 ++++--- scripts/e2e-parallel-tests.sh | 25 +++ scripts/e2e-serial-tests.sh | 60 ++++--- 7 files changed, 231 insertions(+), 203 deletions(-) create mode 100755 scripts/e2e-parallel-tests.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8ef128e49a..604d4794e8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -90,7 +90,7 @@ jobs: export OS=linux export FIREFOX_BIN="$(pwd)/firefox/firefox" yarn firefox:manifest && yarn firefox:zip - yarn vitest:parallel --retry=5 + yarn vitest:parallel - name: Upload deps artifacts if: steps.FFE2eParallel.outcome == 'failure' uses: actions/upload-artifact@v3 @@ -115,16 +115,12 @@ jobs: # - name: Run e2e Swap (Firefox) # id: FFE2eSwap # continue-on-error: true - # uses: nick-fields/retry@v2 - # with: - # timeout_minutes: 25 - # max_attempts: 2 - # command: | - # export BROWSER=firefox - # export OS=linux - # export FIREFOX_BIN="$(pwd)/firefox/firefox" - # yarn firefox:manifest && yarn firefox:zip - # yarn vitest:swap --retry=5 + # run: | + # export BROWSER=firefox + # export OS=linux + # export FIREFOX_BIN="$(pwd)/firefox/firefox" + # yarn firefox:manifest && yarn firefox:zip + # yarn vitest:swap # - name: Upload deps artifacts # if: steps.FFE2eSwap.outcome == 'failure' # uses: actions/upload-artifact@v3 @@ -149,16 +145,12 @@ jobs: - name: Run e2e Send (Firefox) id: FFE2eSend continue-on-error: true - uses: nick-fields/retry@v2 - with: - timeout_minutes: 25 - max_attempts: 2 - command: | - export BROWSER=firefox - export OS=linux - export FIREFOX_BIN="$(pwd)/firefox/firefox" - yarn firefox:manifest && yarn firefox:zip - yarn vitest:send --retry=5 + run: | + export BROWSER=firefox + export OS=linux + export FIREFOX_BIN="$(pwd)/firefox/firefox" + yarn firefox:manifest && yarn firefox:zip + yarn vitest:send - name: Upload deps artifacts if: steps.FFE2eSend.outcome == 'failure' uses: actions/upload-artifact@v3 @@ -183,16 +175,12 @@ jobs: - name: Run e2e Dapp Interactions (Firefox) id: FFE2eDappInteractions continue-on-error: true - uses: nick-fields/retry@v2 - with: - timeout_minutes: 25 - max_attempts: 2 - command: | - export BROWSER=firefox - export OS=linux - export FIREFOX_BIN="$(pwd)/firefox/firefox" - yarn firefox:manifest && yarn firefox:zip - yarn vitest:dappInteractions --retry=5 + run: | + export BROWSER=firefox + export OS=linux + export FIREFOX_BIN="$(pwd)/firefox/firefox" + yarn firefox:manifest && yarn firefox:zip + yarn vitest:dappInteractions - name: Upload deps artifacts if: steps.FFE2eDappInteractions.outcome == 'failure' uses: actions/upload-artifact@v3 @@ -222,7 +210,7 @@ jobs: export BROWSER=chrome export OS=linux export CHROMIUM_BIN=$(find chrome -type f -name 'chrome') - yarn vitest:parallel --retry=5 + yarn vitest:parallel - name: Upload deps artifacts if: steps.ChromeE2EParallel.outcome == 'failure' uses: actions/upload-artifact@v3 @@ -247,15 +235,11 @@ jobs: - name: Run e2e swap (Chrome) id: ChromeE2ESwaps continue-on-error: true - uses: nick-fields/retry@v2 - with: - timeout_minutes: 25 - max_attempts: 2 - command: | - export BROWSER=chrome - export OS=linux - export CHROMIUM_BIN=$(find chrome -type f -name 'chrome') - yarn vitest:swap + run: | + export BROWSER=chrome + export OS=linux + export CHROMIUM_BIN=$(find chrome -type f -name 'chrome') + yarn vitest:swap - name: Upload deps artifacts if: steps.ChromeE2ESwaps.outcome == 'failure' uses: actions/upload-artifact@v3 @@ -280,15 +264,11 @@ jobs: - name: Run e2e send (Chrome) id: ChromeE2ESend continue-on-error: true - uses: nick-fields/retry@v2 - with: - timeout_minutes: 25 - max_attempts: 2 - command: | - export BROWSER=chrome - export OS=linux - export CHROMIUM_BIN=$(find chrome -type f -name 'chrome') - yarn vitest:send --retry=5 + run: | + export BROWSER=chrome + export OS=linux + export CHROMIUM_BIN=$(find chrome -type f -name 'chrome') + yarn vitest:send - name: Upload deps artifacts if: steps.ChromeE2ESend.outcome == 'failure' uses: actions/upload-artifact@v3 @@ -313,15 +293,11 @@ jobs: - name: Run Optimism e2e send (Chrome) id: ChromeOpE2ESend continue-on-error: true - uses: nick-fields/retry@v2 - with: - timeout_minutes: 25 - max_attempts: 2 - command: | - export BROWSER=chrome - export OS=linux - export CHROMIUM_BIN=$(find chrome -type f -name 'chrome') - yarn vitest:send:optimism --retry=5 + run: | + export BROWSER=chrome + export OS=linux + export CHROMIUM_BIN=$(find chrome -type f -name 'chrome') + yarn vitest:send:optimism - name: Upload deps artifacts if: steps.ChromeOpE2ESend.outcome == 'failure' uses: actions/upload-artifact@v3 @@ -346,15 +322,11 @@ jobs: - name: Run e2e dappInteractions (Chrome) id: ChromeE2EDappInteractions continue-on-error: true - uses: nick-fields/retry@v2 - with: - timeout_minutes: 25 - max_attempts: 2 - command: | - export BROWSER=chrome - export OS=linux - export CHROMIUM_BIN=$(find chrome -type f -name 'chrome') - yarn vitest:dappInteractions --retry=5 + run: | + export BROWSER=chrome + export OS=linux + export CHROMIUM_BIN=$(find chrome -type f -name 'chrome') + yarn vitest:dappInteractions - name: Upload deps artifacts if: steps.ChromeE2EDappInteractions.outcome == 'failure' uses: actions/upload-artifact@v3 @@ -412,15 +384,11 @@ jobs: # - name: Copy dotenv # run: cat tmp/dotenv >> .env && rm -rf tmp # - name: Run e2e (Brave) - # uses: nick-fields/retry@v2 - # with: - # timeout_minutes: 18 - # max_attempts: 3 - # command: | - # export BROWSER=brave - # export OS=linux - # export BRAVE_BIN='/usr/bin/brave-browser-stable' - # yarn vitest:parallel && yarn vitest:serial + # run: | + # export BROWSER=brave + # export OS=linux + # export BRAVE_BIN='/usr/bin/brave-browser-stable' + # yarn vitest:parallel && yarn vitest:serial # UNIT TESTS unit-tests: runs-on: ubuntu-latest @@ -457,11 +425,7 @@ jobs: - name: Copy dotenv run: cat tmp/dotenv >> .env && rm -rf tmp - name: Run unit tests - uses: nick-fields/retry@v2 - with: - timeout_minutes: 5 - max_attempts: 3 - command: yarn test + run: yarn test # LINT, TYPECHECK, AUDIT ci-checks: diff --git a/e2e/parallel/shortcuts-walletSwitcher.test.ts b/e2e/parallel/shortcuts-walletSwitcher.test.ts index 51380d97dc..cc7196b15f 100644 --- a/e2e/parallel/shortcuts-walletSwitcher.test.ts +++ b/e2e/parallel/shortcuts-walletSwitcher.test.ts @@ -10,6 +10,7 @@ import { findElementById, findElementByTestId, findElementByText, + findElementByTextAndClick, getExtensionIdByName, getRootUrl, importWalletFlowUsingKeyboardNavigation, @@ -82,6 +83,8 @@ describe.runIf(browser !== 'firefox')( await executePerformShortcut({ driver, key: 'TAB', timesToPress: 2 }); await executePerformShortcut({ driver, key: 'ENTER' }); await checkExtensionURL(driver, 'wallet-switcher'); + // need this to unfocus search field on slow running tests + await findElementByTextAndClick(driver, 'wallets'); await executePerformShortcut({ driver, key: 'ESCAPE' }); }); diff --git a/lavamoat/build-webpack/policy.json b/lavamoat/build-webpack/policy.json index 8d15a9aa99..2dfb40a900 100644 --- a/lavamoat/build-webpack/policy.json +++ b/lavamoat/build-webpack/policy.json @@ -1099,13 +1099,13 @@ "eslint>debug": true, "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame": true, "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/generator": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-environment-visitor": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-hoist-variables": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-split-export-declaration": true, "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/parser": true, "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/types": true, - "jest>@jest/core>jest-snapshot>@babel/traverse>globals": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-environment-visitor": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-hoist-variables": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-split-export-declaration": true + "jest>@jest/core>jest-snapshot>@babel/traverse>globals": true } }, "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame": { @@ -1172,141 +1172,141 @@ "define": true } }, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/types": { - "globals": { - "console.warn": true, - "process.env.BABEL_TYPES_8_BREAKING": true - }, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name": { "packages": { - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/types>@babel/helper-string-parser": true, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/types>@babel/helper-validator-identifier": true, - "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/types": true } }, - "jest>@jest/core>jest-snapshot>@babel/types": { - "globals": { - "console.trace": true, - "process.env.BABEL_TYPES_8_BREAKING": true - }, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template": { "packages": { - "jest>@jest/core>jest-snapshot>@babel/types>@babel/helper-string-parser": true, - "jest>@jest/core>jest-snapshot>@babel/types>@babel/helper-validator-identifier": true, - "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/parser": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/types": true } }, - "lavamoat>@babel/highlight": { + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame": { + "globals": { + "console.warn": true, + "process.emitWarning": true + }, "packages": { - "lavamoat>@babel/highlight>@babel/helper-validator-identifier": true, - "lavamoat>@babel/highlight>chalk": true, - "react>loose-envify>js-tokens": true + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk": true, + "lavamoat>@babel/highlight": true } }, - "lavamoat>@babel/highlight>chalk": { + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk": { "globals": { "process.env.TERM": true, "process.platform": true }, "packages": { - "lavamoat>@babel/highlight>chalk>ansi-styles": true, - "lavamoat>@babel/highlight>chalk>escape-string-regexp": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>escape-string-regexp": true, "supports-color": true } }, - "lavamoat>@babel/highlight>chalk>ansi-styles": { + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles": { "packages": { - "lavamoat>@babel/highlight>chalk>ansi-styles>color-convert": true + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles>color-convert": true } }, - "lavamoat>@babel/highlight>chalk>ansi-styles>color-convert": { + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles>color-convert": { "packages": { - "lavamoat>@babel/highlight>chalk>ansi-styles>color-convert>color-name": true + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles>color-convert>color-name": true } }, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name": { + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/types": { + "globals": { + "console.warn": true, + "process.env.BABEL_TYPES_8_BREAKING": true + }, "packages": { - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/types": true + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/types>@babel/helper-string-parser": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/types>@babel/helper-validator-identifier": true, + "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true } }, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template": { + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-hoist-variables": { "packages": { - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/parser": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/types": true + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-hoist-variables>@babel/types": true } }, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame": { + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-hoist-variables>@babel/types": { "globals": { "console.warn": true, - "process.emitWarning": true + "process.env.BABEL_TYPES_8_BREAKING": true }, "packages": { - "lavamoat>@babel/highlight": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk": true + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-hoist-variables>@babel/types>@babel/helper-string-parser": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-hoist-variables>@babel/types>@babel/helper-validator-identifier": true, + "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true } }, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk": { - "globals": { - "process.env.TERM": true, - "process.platform": true - }, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-split-export-declaration": { "packages": { - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>escape-string-regexp": true, - "supports-color": true + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-split-export-declaration>@babel/types": true } }, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles": { + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-split-export-declaration>@babel/types": { + "globals": { + "console.warn": true, + "process.env.BABEL_TYPES_8_BREAKING": true + }, "packages": { - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles>color-convert": true + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-split-export-declaration>@babel/types>@babel/helper-string-parser": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-split-export-declaration>@babel/types>@babel/helper-validator-identifier": true, + "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true } }, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles>color-convert": { + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/types": { + "globals": { + "console.warn": true, + "process.env.BABEL_TYPES_8_BREAKING": true + }, "packages": { - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles>color-convert>color-name": true + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/types>@babel/helper-string-parser": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/types>@babel/helper-validator-identifier": true, + "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true } }, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/types": { + "jest>@jest/core>jest-snapshot>@babel/types": { "globals": { - "console.warn": true, + "console.trace": true, "process.env.BABEL_TYPES_8_BREAKING": true }, "packages": { - "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/types>@babel/helper-string-parser": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/types>@babel/helper-validator-identifier": true + "jest>@jest/core>jest-snapshot>@babel/types>@babel/helper-string-parser": true, + "jest>@jest/core>jest-snapshot>@babel/types>@babel/helper-validator-identifier": true, + "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true } }, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-hoist-variables": { + "lavamoat>@babel/highlight": { "packages": { - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-hoist-variables>@babel/types": true + "lavamoat>@babel/highlight>@babel/helper-validator-identifier": true, + "lavamoat>@babel/highlight>chalk": true, + "react>loose-envify>js-tokens": true } }, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-hoist-variables>@babel/types": { + "lavamoat>@babel/highlight>chalk": { "globals": { - "console.warn": true, - "process.env.BABEL_TYPES_8_BREAKING": true + "process.env.TERM": true, + "process.platform": true }, "packages": { - "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-hoist-variables>@babel/types>@babel/helper-string-parser": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-hoist-variables>@babel/types>@babel/helper-validator-identifier": true + "lavamoat>@babel/highlight>chalk>ansi-styles": true, + "lavamoat>@babel/highlight>chalk>escape-string-regexp": true, + "supports-color": true } }, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-split-export-declaration": { + "lavamoat>@babel/highlight>chalk>ansi-styles": { "packages": { - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-split-export-declaration>@babel/types": true + "lavamoat>@babel/highlight>chalk>ansi-styles>color-convert": true } }, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-split-export-declaration>@babel/types": { - "globals": { - "console.warn": true, - "process.env.BABEL_TYPES_8_BREAKING": true - }, + "lavamoat>@babel/highlight>chalk>ansi-styles>color-convert": { "packages": { - "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-split-export-declaration>@babel/types>@babel/helper-string-parser": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-split-export-declaration>@babel/types>@babel/helper-validator-identifier": true + "lavamoat>@babel/highlight>chalk>ansi-styles>color-convert>color-name": true } }, "lint-staged>execa>merge-stream": { diff --git a/package.json b/package.json index 13f9b53e20..002315d378 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "test": "./scripts/unit-tests.sh", "test:watch": "yarn anvil & vitest --watch", "// Runs e2e": "", - "vitest:parallel": "yarn vitest e2e/parallel --config ./e2e/parallel/vitest.config.ts --bail 1", + "vitest:parallel": "./scripts/e2e-parallel-tests.sh", "vitest:serial": "./scripts/e2e-serial-tests.sh", "vitest:swap": "./scripts/e2e-serial-tests.sh 'swap'", "vitest:send": "./scripts/e2e-serial-tests.sh 'send'", diff --git a/scripts/e2e-op-serial-tests.sh b/scripts/e2e-op-serial-tests.sh index 933ae26cba..7ea06ebe05 100755 --- a/scripts/e2e-op-serial-tests.sh +++ b/scripts/e2e-op-serial-tests.sh @@ -1,29 +1,47 @@ #!/bin/bash ANVIL_PORT=8545 +MAX_RETRIES=5 +RETRY_COUNT=0 -# Launch anvil in the bg -yarn anvil:kill -yarn anvil:optimism --chain-id 1338 & -echo "Launching Anvil..." +# Function to launch and verify Anvil +launch_anvil() { + # Launch anvil in the bg + yarn anvil:kill + yarn anvil:optimism --chain-id 1338 & + echo "Launching Anvil..." -# Give it some time to boot -interval=5 -until nc -z localhost $ANVIL_PORT; do - sleep $interval - interval=$((interval * 2)) -done -echo "Anvil Launched..." + # Give it some time to boot + interval=5 + until nc -z localhost $ANVIL_PORT; do + sleep $interval + interval=$((interval * 2)) + done + echo "Anvil Launched..." +} -# Run the tests and store the result -echo "Running Tests..." -yarn vitest e2e/serial/$1 --config ./e2e/serial/vitest.config.ts --reporter=verbose --bail 1 +# Function to run tests +run_tests() { + echo "Running Tests..." + yarn vitest e2e/serial/$1 --config ./e2e/serial/vitest.config.ts --reporter=verbose --bail 1 +} -# Store exit code -TEST_RESULT=$? +# Main loop for retry logic +TEST_RESULT=1 +while [ $RETRY_COUNT -lt $MAX_RETRIES ] && [ $TEST_RESULT -ne 0 ]; do + if [ $RETRY_COUNT -gt 0 ]; then + echo "Test failed, attempting retry $RETRY_COUNT..." + fi + + launch_anvil + run_tests $1 + TEST_RESULT=$? + + # kill anvil + echo "Cleaning Up..." + yarn anvil:kill -# kill anvil -echo "Cleaning Up..." -yarn anvil:kill + RETRY_COUNT=$((RETRY_COUNT+1)) +done -# return the result of the tests -exit "$TEST_RESULT" +# Return the result of the tests +exit $TEST_RESULT diff --git a/scripts/e2e-parallel-tests.sh b/scripts/e2e-parallel-tests.sh new file mode 100755 index 0000000000..60272027d3 --- /dev/null +++ b/scripts/e2e-parallel-tests.sh @@ -0,0 +1,25 @@ +#!/bin/bash +MAX_RETRIES=5 +RETRY_COUNT=0 + +# Function to run tests +run_tests() { + echo "Running Tests..." + yarn vitest e2e/parallel/$1 --config ./e2e/parallel/vitest.config.ts --reporter=verbose --bail 1 +} + +# Main loop for retry logic +TEST_RESULT=1 +while [ $RETRY_COUNT -lt $MAX_RETRIES ] && [ $TEST_RESULT -ne 0 ]; do + if [ $RETRY_COUNT -gt 0 ]; then + echo "Test failed, attempting retry $RETRY_COUNT..." + fi + + run_tests $1 + TEST_RESULT=$? + + RETRY_COUNT=$((RETRY_COUNT+1)) +done + +# Return the result of the tests +exit $TEST_RESULT diff --git a/scripts/e2e-serial-tests.sh b/scripts/e2e-serial-tests.sh index 7e50e82dc3..8aa57a1f27 100755 --- a/scripts/e2e-serial-tests.sh +++ b/scripts/e2e-serial-tests.sh @@ -1,29 +1,47 @@ #!/bin/bash ANVIL_PORT=8545 +MAX_RETRIES=5 +RETRY_COUNT=0 -# Launch anvil in the bg -yarn anvil:kill -yarn anvil --chain-id 1337 & -echo "Launching Anvil..." +# Function to launch and verify Anvil +launch_anvil() { + # Launch anvil in the bg + yarn anvil:kill + yarn anvil --chain-id 1337 & + echo "Launching Anvil..." -# Give it some time to boot -interval=5 -until nc -z localhost $ANVIL_PORT; do - sleep $interval - interval=$((interval * 2)) -done -echo "Anvil Launched..." + # Give it some time to boot + interval=5 + until nc -z localhost $ANVIL_PORT; do + sleep $interval + interval=$((interval * 2)) + done + echo "Anvil Launched..." +} -# Run the tests and store the result -echo "Running Tests..." -yarn vitest e2e/serial/$1 --config ./e2e/serial/vitest.config.ts --reporter=verbose --bail 1 +# Function to run tests +run_tests() { + echo "Running Tests..." + yarn vitest e2e/serial/$1 --config ./e2e/serial/vitest.config.ts --reporter=verbose --bail 1 +} -# Store exit code -TEST_RESULT=$? +# Main loop for retry logic +TEST_RESULT=1 +while [ $RETRY_COUNT -lt $MAX_RETRIES ] && [ $TEST_RESULT -ne 0 ]; do + if [ $RETRY_COUNT -gt 0 ]; then + echo "Test failed, attempting retry $RETRY_COUNT..." + fi + + launch_anvil + run_tests $1 + TEST_RESULT=$? + + # kill anvil + echo "Cleaning Up..." + yarn anvil:kill -# kill anvil -echo "Cleaning Up..." -yarn anvil:kill + RETRY_COUNT=$((RETRY_COUNT+1)) +done -# return the result of the tests -exit "$TEST_RESULT" +# Return the result of the tests +exit $TEST_RESULT