diff --git a/.circleci/config.yml b/.circleci/config.yml index 0b303f13604..cca2e84a42f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,36 +3,47 @@ parameters: run_flaky_tests: type: boolean default: false + nightly: + type: boolean + default: false + filter: + type: string + default: 'run,search,url,deploy,ballot' orbs: browser-tools: circleci/browser-tools@1.5.2 win: circleci/windows@5.0 node: circleci/node@7.0.0 + nx: nrwl/nx@1.7.0 jobs: build: docker: - - image: cimg/node:20.0.0-browsers - + - image: cimg/node:20.0.0 resource_class: xlarge working_directory: ~/remix-project + environment: + NX_PARALLEL: 6 steps: + - run: nproc - run: sudo apt update && sudo apt install zstd - checkout - restore_cache: keys: - v1-deps-{{ checksum "yarn.lock" }} - - run: yarn + - run: yarn install --frozen-lockfile - save_cache: key: v1-deps-{{ checksum "yarn.lock" }} paths: - node_modules + - nx/set-shas: + main-branch-name: master - run: name: Build command: | if [ "${CIRCLE_BRANCH}" == "master" ]; then - NX_BIN_URL=http://127.0.0.1:8080/assets/js/soljson NX_WASM_URL=http://127.0.0.1:8080/assets/js/soljson NX_NPM_URL=http://127.0.0.1:9090/ yarn build:production + NX_PARALLEL=6 NX_BIN_URL=http://127.0.0.1:8080/assets/js/soljson NX_WASM_URL=http://127.0.0.1:8080/assets/js/soljson NX_NPM_URL=http://127.0.0.1:9090/ yarn build:production else - NX_BIN_URL=http://127.0.0.1:8080/assets/js/soljson NX_WASM_URL=http://127.0.0.1:8080/assets/js/soljson NX_NPM_URL=http://127.0.0.1:9090/ yarn build + NX_PARALLEL=6 NX_BIN_URL=http://127.0.0.1:8080/assets/js/soljson NX_WASM_URL=http://127.0.0.1:8080/assets/js/soljson NX_NPM_URL=http://127.0.0.1:9090/ yarn build fi - run: yarn run build:e2e @@ -669,6 +680,23 @@ jobs: - run: mkdir node_modules/hardhat && wget https://unpkg.com/hardhat/console.sol -O node_modules/hardhat/console.sol - run: ls -la ./dist/apps/remix-ide/assets/js + - when: + condition: + equal: [ "brave", << parameters.browser >> ] + steps: + - run: yarn install_webdriver + - run: + name: Install Brave Browser + command: | + sudo apt update + sudo apt install -y curl gnupg + sudo mkdir -p /etc/apt/keyrings + curl -fsSL https://brave-browser-apt-release.s3.brave.com/brave-browser-archive-keyring.gpg | sudo tee /etc/apt/keyrings/brave-browser-archive-keyring.gpg >/dev/null + echo "deb [signed-by=/etc/apt/keyrings/brave-browser-archive-keyring.gpg] https://brave-browser-apt-release.s3.brave.com/ stable main" | sudo tee /etc/apt/sources.list.d/brave-browser-release.list + sudo apt update && sudo apt install -y brave-browser + - run: + name: Check Brave Version + command: brave-browser --version - when: condition: equal: [ "chrome", << parameters.browser >> ] @@ -691,7 +719,7 @@ jobs: install-chromedriver: false - run: yarn install_webdriver - run: firefox --version - - run: ./apps/remix-ide/ci/<< parameters.script >> << parameters.browser >> << parameters.jobsize >> << parameters.job >> + - run: ./apps/remix-ide/ci/<< parameters.script >> << parameters.browser >> << parameters.jobsize >> << parameters.job >> << pipeline.parameters.filter >> - store_test_results: path: ./reports/tests - store_artifacts: @@ -799,8 +827,62 @@ workflows: job: ["nogroup"] jobsize: ["1"] parallelism: [5] + nightly-tests: + when: << pipeline.parameters.nightly >> # ✅ Conditional workflow execution + jobs: + - build + # - remix-ide-browser: + # requires: + # - build + # matrix: + # alias: nightly-brave-tests + # parameters: + # browser: ["brave"] # ✅ Brave only runs if nightly=true + # script: ["browser_test.sh"] + # job: ["0","1","2","3","4","5","6","7","8","9"] + # jobsize: ["10"] + # parallelism: [15] + - remix-ide-browser: + requires: + - build + matrix: + alias: nightly-tests + parameters: + browser: ["chrome"] + script: ["nightly.sh"] + job: ["0"] + jobsize: ["1"] + parallelism: [15] + # - remix-ide-browser: + # requires: + # - build + # matrix: + # alias: metamask + # parameters: + # browser: ["chrome", "brave"] + # script: ["metamask.sh"] + # job: ["0"] + # jobsize: ["10"] + # parallelism: [1] + filtered-tests: + when: << pipeline.parameters.filter >> # ✅ Conditional workflow execution + jobs: + - build + - remix-ide-browser: + requires: + - build + matrix: + parameters: + browser: ["chrome"] + script: ["browser_test.sh"] + job: ["0"] + jobsize: ["1"] + parallelism: [15] build_all: - unless: << pipeline.parameters.run_flaky_tests >> + when: + and: + - not: << pipeline.parameters.run_flaky_tests >> + - not: << pipeline.parameters.filter >> jobs: - build - build-desktop @@ -887,6 +969,7 @@ workflows: job: ["0","1","2","3","4","5","6","7","8","9"] jobsize: ["10"] parallelism: [15] + - remix-ide-browser: requires: - build @@ -953,4 +1036,15 @@ workflows: branches: only: remix_beta + +trigger: + - &detect_fork + name: "Detect if PR is a fork" + command: | + if [[ -z "$CIRCLE_PR_REPONAME" ]]; then + echo "export IS_FORK=false" >> $BASH_ENV + else + echo "export IS_FORK=true" >> $BASH_ENV + fi + # VS Code Extension Version: 1.5.1 diff --git a/.nx/workspace-data/d/daemon.log b/.nx/workspace-data/d/daemon.log new file mode 100644 index 00000000000..32491c4d573 --- /dev/null +++ b/.nx/workspace-data/d/daemon.log @@ -0,0 +1,48 @@ +[NX v20.6.1 Daemon Server] - 2025-03-19T06:48:33.746Z - Started listening on: /var/folders/qv/xmjp70m950b67kdf04fcx00h0000gn/T/26481ed23dae92d5c286/d.sock +[NX v20.6.1 Daemon Server] - 2025-03-19T06:48:33.748Z - [WATCHER]: Subscribed to changes within: /Users/filipmertens/Documents/code/remix-project (native) +[NX v20.6.1 Daemon Server] - 2025-03-19T06:48:33.757Z - Established a connection. Number of open connections: 1 +[NX v20.6.1 Daemon Server] - 2025-03-19T06:48:33.758Z - Established a connection. Number of open connections: 2 +[NX v20.6.1 Daemon Server] - 2025-03-19T06:48:33.758Z - Closed a connection. Number of open connections: 1 +[NX v20.6.1 Daemon Server] - 2025-03-19T06:48:33.759Z - [REQUEST]: Responding to the client. Shutdown initiated +[NX v20.6.1 Daemon Server] - 2025-03-19T06:48:33.759Z - Done responding to the client Shutdown initiated +[NX v20.6.1 Daemon Server] - 2025-03-19T06:48:33.759Z - Handled FORCE_SHUTDOWN. Handling time: 0. Response time: 0. +[NX v20.6.1 Daemon Server] - 2025-03-19T06:48:33.760Z - Closed a connection. Number of open connections: 0 +[NX v20.6.1 Daemon Server] - 2025-03-19T06:48:33.760Z - [WATCHER]: Stopping the watcher for /Users/filipmertens/Documents/code/remix-project (sources) +[NX v20.6.1 Daemon Server] - 2025-03-19T06:48:33.760Z - [WATCHER]: Stopping the watcher for /Users/filipmertens/Documents/code/remix-project (outputs) +[NX v20.6.1 Daemon Server] - 2025-03-19T06:48:33.760Z - Server stopped because: "Request to shutdown" +[NX v20.6.1 Daemon Server] - 2025-03-19T06:48:54.527Z - Started listening on: /var/folders/qv/xmjp70m950b67kdf04fcx00h0000gn/T/26481ed23dae92d5c286/d.sock +[NX v20.6.1 Daemon Server] - 2025-03-19T06:48:54.532Z - [WATCHER]: Subscribed to changes within: /Users/filipmertens/Documents/code/remix-project (native) +[NX v20.6.1 Daemon Server] - 2025-03-19T06:48:54.533Z - Established a connection. Number of open connections: 1 +[NX v20.6.1 Daemon Server] - 2025-03-19T06:48:54.533Z - Established a connection. Number of open connections: 2 +[NX v20.6.1 Daemon Server] - 2025-03-19T06:48:54.534Z - Closed a connection. Number of open connections: 1 +[NX v20.6.1 Daemon Server] - 2025-03-19T06:48:54.534Z - [REQUEST]: Responding to the client. Shutdown initiated +[NX v20.6.1 Daemon Server] - 2025-03-19T06:48:54.535Z - Done responding to the client Shutdown initiated +[NX v20.6.1 Daemon Server] - 2025-03-19T06:48:54.535Z - Handled FORCE_SHUTDOWN. Handling time: 0. Response time: 1. +[NX v20.6.1 Daemon Server] - 2025-03-19T06:48:54.536Z - [WATCHER]: Stopping the watcher for /Users/filipmertens/Documents/code/remix-project (sources) +[NX v20.6.1 Daemon Server] - 2025-03-19T06:48:54.536Z - Closed a connection. Number of open connections: 0 +[NX v20.6.1 Daemon Server] - 2025-03-19T06:48:54.536Z - [WATCHER]: Stopping the watcher for /Users/filipmertens/Documents/code/remix-project (outputs) +[NX v20.6.1 Daemon Server] - 2025-03-19T06:48:54.537Z - Server stopped because: "Request to shutdown" +[NX v20.6.1 Daemon Server] - 2025-03-19T06:49:27.139Z - Started listening on: /var/folders/qv/xmjp70m950b67kdf04fcx00h0000gn/T/26481ed23dae92d5c286/d.sock +[NX v20.6.1 Daemon Server] - 2025-03-19T06:49:27.142Z - [WATCHER]: Subscribed to changes within: /Users/filipmertens/Documents/code/remix-project (native) +[NX v20.6.1 Daemon Server] - 2025-03-19T06:49:27.144Z - Established a connection. Number of open connections: 1 +[NX v20.6.1 Daemon Server] - 2025-03-19T06:49:27.145Z - Established a connection. Number of open connections: 2 +[NX v20.6.1 Daemon Server] - 2025-03-19T06:49:27.147Z - Closed a connection. Number of open connections: 1 +[NX v20.6.1 Daemon Server] - 2025-03-19T06:49:27.148Z - [REQUEST]: Responding to the client. Shutdown initiated +[NX v20.6.1 Daemon Server] - 2025-03-19T06:49:27.148Z - Done responding to the client Shutdown initiated +[NX v20.6.1 Daemon Server] - 2025-03-19T06:49:27.148Z - Handled FORCE_SHUTDOWN. Handling time: 0. Response time: 0. +[NX v20.6.1 Daemon Server] - 2025-03-19T06:49:27.150Z - [WATCHER]: Stopping the watcher for /Users/filipmertens/Documents/code/remix-project (sources) +[NX v20.6.1 Daemon Server] - 2025-03-19T06:49:27.150Z - Closed a connection. Number of open connections: 0 +[NX v20.6.1 Daemon Server] - 2025-03-19T06:49:27.150Z - [WATCHER]: Stopping the watcher for /Users/filipmertens/Documents/code/remix-project (outputs) +[NX v20.6.1 Daemon Server] - 2025-03-19T06:49:27.150Z - Server stopped because: "Request to shutdown" +[NX v20.6.1 Daemon Server] - 2025-03-19T06:50:46.973Z - Started listening on: /var/folders/qv/xmjp70m950b67kdf04fcx00h0000gn/T/26481ed23dae92d5c286/d.sock +[NX v20.6.1 Daemon Server] - 2025-03-19T06:50:46.976Z - [WATCHER]: Subscribed to changes within: /Users/filipmertens/Documents/code/remix-project (native) +[NX v20.6.1 Daemon Server] - 2025-03-19T06:50:46.982Z - Established a connection. Number of open connections: 1 +[NX v20.6.1 Daemon Server] - 2025-03-19T06:50:46.982Z - Established a connection. Number of open connections: 2 +[NX v20.6.1 Daemon Server] - 2025-03-19T06:50:46.983Z - Closed a connection. Number of open connections: 1 +[NX v20.6.1 Daemon Server] - 2025-03-19T06:50:46.984Z - [REQUEST]: Responding to the client. Shutdown initiated +[NX v20.6.1 Daemon Server] - 2025-03-19T06:50:46.984Z - Done responding to the client Shutdown initiated +[NX v20.6.1 Daemon Server] - 2025-03-19T06:50:46.984Z - Handled FORCE_SHUTDOWN. Handling time: 0. Response time: 1. +[NX v20.6.1 Daemon Server] - 2025-03-19T06:50:46.985Z - [WATCHER]: Stopping the watcher for /Users/filipmertens/Documents/code/remix-project (sources) +[NX v20.6.1 Daemon Server] - 2025-03-19T06:50:46.985Z - Closed a connection. Number of open connections: 0 +[NX v20.6.1 Daemon Server] - 2025-03-19T06:50:46.985Z - [WATCHER]: Stopping the watcher for /Users/filipmertens/Documents/code/remix-project (outputs) +[NX v20.6.1 Daemon Server] - 2025-03-19T06:50:46.986Z - Server stopped because: "Request to shutdown" diff --git a/apps/remix-ide-e2e/nightwatch-brave.ts b/apps/remix-ide-e2e/nightwatch-brave.ts new file mode 100644 index 00000000000..0c72e78270d --- /dev/null +++ b/apps/remix-ide-e2e/nightwatch-brave.ts @@ -0,0 +1,112 @@ +import * as fs from 'fs'; +import * as os from 'os'; +import * as path from 'path'; + +const crxFile = fs.readFileSync('apps/remix-ide-e2e/src/extensions/chrome/11.13.1_0.crx'); +const metamaskExtension = crxFile.toString('base64'); + +// Function to find the Brave binary path based on the OS +const getBravePath = () => { + const platform = os.platform(); + if (platform === 'darwin') { + return '/Applications/Brave Browser.app/Contents/MacOS/Brave Browser'; + } else if (platform === 'win32') { + const possiblePaths = [ + 'C:\\Program Files\\BraveSoftware\\Brave-Browser\\Application\\brave.exe', + 'C:\\Program Files (x86)\\BraveSoftware\\Brave-Browser\\Application\\brave.exe', + ]; + return possiblePaths.find(fs.existsSync) || 'brave.exe'; // Default to PATH lookup + } else { + return '/usr/bin/brave-browser'; // Linux default + } +}; + +const braveBinary = getBravePath(); + +module.exports = { + src_folders: ['dist/apps/remix-ide-e2e/src/tests'], + output_folder: './reports/tests', + custom_commands_path: ['dist/apps/remix-ide-e2e/src/commands'], + custom_assertions_path: '', + page_objects_path: '', + globals_path: '', + + webdriver: { + start_process: true, + port: 9515, + server_path: './tmp/webdrivers/node_modules/chromedriver/bin/chromedriver', + }, + + test_settings: { + 'default': { + globals: { + waitForConditionTimeout: 10000, + asyncHookTimeout: 10000000 + }, + screenshots: { + enabled: true, + path: './reports/screenshots', + on_failure: true, + on_error: true + }, + exclude: ['dist/apps/remix-ide-e2e/src/tests/runAndDeploy.test.js', 'dist/apps/remix-ide-e2e/src/tests/pluginManager.test.ts'] + }, + + 'brave': { + desiredCapabilities: { + 'browserName': 'chrome', + 'javascriptEnabled': true, + 'acceptSslCerts': true, + 'goog:chromeOptions': { + binary: braveBinary, // Dynamic Brave binary path + args: [ + 'window-size=2560,1440', + '--no-sandbox', + '--headless=new', // Enable headless mode for CI + '--verbose', + '--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36' + ], + extensions: [metamaskExtension] + } + } + }, + + 'braveDesktop': { + desiredCapabilities: { + 'browserName': 'chrome', + 'javascriptEnabled': true, + 'acceptSslCerts': true, + 'goog:chromeOptions': { + binary: braveBinary, + args: ['window-size=2560,1440', 'start-fullscreen', '--no-sandbox', '--verbose'] + } + } + }, + + 'braveDesktopMetamask': { + desiredCapabilities: { + 'browserName': 'chrome', + 'javascriptEnabled': true, + 'acceptSslCerts': true, + 'goog:chromeOptions': { + binary: braveBinary, + args: ['window-size=2560,1440', '--no-sandbox', '--verbose'], + extensions: [metamaskExtension] + } + } + }, + + 'brave-runAndDeploy': { + desiredCapabilities: { + 'browserName': 'chrome', + 'javascriptEnabled': true, + 'acceptSslCerts': true, + 'goog:chromeOptions': { + binary: braveBinary, + args: ['window-size=2560,1440', 'start-fullscreen', '--no-sandbox', '--headless', '--verbose'], + extensions: [metamaskExtension] + } + } + } + } +}; \ No newline at end of file diff --git a/apps/remix-ide-e2e/src/buildGroupTests.js b/apps/remix-ide-e2e/src/buildGroupTests.js index 71274621258..bbaa5a349cb 100644 --- a/apps/remix-ide-e2e/src/buildGroupTests.js +++ b/apps/remix-ide-e2e/src/buildGroupTests.js @@ -1,4 +1,5 @@ const testFolder = './apps/remix-ide-e2e/src/tests/' +const e = require('express') const fs = require('fs') // build group tests @@ -15,12 +16,14 @@ fs.readdirSync(testFolder).forEach(file => { if (!file.includes('group')) { const content = fs.readFileSync(testFolder + file, 'utf8') const matches = content.match(/group\d+/g) + createFlakyTestFiles(file, content) - createFiles(file, matches) + createNonNightlyTestFiles(file, matches, content) + createNightlyTestFiles(file, content) } }) -function createFiles(file, matches, flaky = false) { +function createFiles(file, matches, flaky = false, nightly = false) { if (matches) { const unique = matches.filter(onlyUnique) unique.map((group) => { @@ -28,10 +31,12 @@ function createFiles(file, matches, flaky = false) { const extension = file.split('.') extension.shift() let filename - if (!flaky) { + if (!flaky && !nightly) { filename = `${testFolder}${file.split('.').shift()}_${group}.${extension.join('.')}` - } else { + } else if (flaky) { filename = `${testFolder}${file.split('.').shift()}_${group}.flaky.ts` + } else if (nightly) { + filename = `${testFolder}${file.split('.').shift()}_${group}.nightly.ts` } fs.writeFileSync(filename, rewrite) }) @@ -53,3 +58,27 @@ function createFlakyTestFiles(file, text) { } }) } + +function createNightlyTestFiles(file, text) { + const lines = text.split('\n') + lines.forEach((line, index) => { + // if line contains #nightly + if (line.includes('#nightly')) { + const matches = line.match(/group\d+/g) + const unique = matches.filter(onlyUnique) + createFiles(file, matches, false, true) + } + }) +} + +function createNonNightlyTestFiles(file, matches, text) { + if (matches) { + const lines = text.split('\n') + lines.forEach((line, index) => { + // if line contains #nightly + if (!line.includes('#nightly')) { + createFiles(file, matches, false, false) + } + }) + } +} diff --git a/apps/remix-ide-e2e/src/select_tests.sh b/apps/remix-ide-e2e/src/select_tests.sh index 3c6440def70..3d05f02c9f4 100644 --- a/apps/remix-ide-e2e/src/select_tests.sh +++ b/apps/remix-ide-e2e/src/select_tests.sh @@ -3,7 +3,7 @@ # Bash Menu Script Example PS3='Select a browser: ' -BROWSERS=( "chrome" "chrome with metamask" "firefox" "exit" ) +BROWSERS=( "chrome" "chrome with metamask" "firefox" "brave" "brave with metamask" "exit" ) select opt in "${BROWSERS[@]}" do case $opt in @@ -22,6 +22,16 @@ do BROWSER="firefoxDesktop" break ;; + "brave") + echo "Brave selected" + BROWSER="braveDesktop" + break + ;; + "brave with metamask") + echo "Brave metamask selected" + BROWSER="braveDesktopMetamask" + break + ;; "exit") echo "Exiting" exit 0 @@ -55,6 +65,13 @@ do yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch-chrome.js $opt --env=$BROWSER elif [ "$BROWSER" = "chromeDesktopMetamask" ]; then yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch-chrome.js $opt --env=$BROWSER + elif [ "$BROWSER" = "braveDesktop" ]; then + yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch-brave.js $opt --env=$BROWSER + elif [ "$BROWSER" = "braveDesktopMetamask" ]; then + yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch-brave.js $opt --env=$BROWSER + else + echo "Invalid browser" + exit 1 fi fi diff --git a/apps/remix-ide-e2e/src/tests/debugger.test.ts b/apps/remix-ide-e2e/src/tests/debugger.test.ts index 60447b9d032..9de5a54abe1 100644 --- a/apps/remix-ide-e2e/src/tests/debugger.test.ts +++ b/apps/remix-ide-e2e/src/tests/debugger.test.ts @@ -12,7 +12,7 @@ module.exports = { return sources }, - 'Should launch debugger #group1': function (browser: NightwatchBrowser) { + 'Should launch debugger #nightly #group1': function (browser: NightwatchBrowser) { browser.addFile('blah.sol', sources[0]['blah.sol']) .pause(4000) // on autocompile sometimes the compiler returns invalid source, so we need to recompile to make sure the source is valid @@ -111,7 +111,7 @@ module.exports = { }) }, - 'Should display correct source highlighting while debugging a contract which has ABIEncoderV2 #group2': function (browser: NightwatchBrowser) { + 'Should display correct source highlighting while debugging a contract which has ABIEncoderV2 #nightly #group2': function (browser: NightwatchBrowser) { /* localVariable_step266_ABIEncoder and localVariable_step717_ABIEncoder still contains unwanted values (related to decoding calldata types) diff --git a/apps/remix-ide-e2e/src/tests/metamask.test.ts b/apps/remix-ide-e2e/src/tests/metamask.test.ts index 54954976ce9..d219c4620cd 100644 --- a/apps/remix-ide-e2e/src/tests/metamask.test.ts +++ b/apps/remix-ide-e2e/src/tests/metamask.test.ts @@ -362,14 +362,11 @@ const tests = { } } -const branch = process.env.CIRCLE_BRANCH -const runTestsConditions = branch && (branch === 'master' || branch === 'remix_live' || branch.includes('remix_beta') || branch.includes('metamask')) - if (!checkBrowserIsChrome(browser)) { module.exports = {} } else { module.exports = { - ...(branch ? (runTestsConditions ? tests : {}) : tests) + ...tests }; } diff --git a/apps/remix-ide-e2e/src/tests/workspace_git.test.ts b/apps/remix-ide-e2e/src/tests/workspace_git.test.ts index 437d54dbb9f..569aa43877c 100644 --- a/apps/remix-ide-e2e/src/tests/workspace_git.test.ts +++ b/apps/remix-ide-e2e/src/tests/workspace_git.test.ts @@ -8,7 +8,7 @@ module.exports = { before: function (browser: NightwatchBrowser, done: VoidFunction) { init(browser, done) }, - 'Should not be able to create GIT without credentials #group1': function (browser: NightwatchBrowser) { + 'Should not be able to create GIT without credentials #nightly #group1': function (browser: NightwatchBrowser) { browser .clickLaunchIcon('filePanel') .click('*[data-id="workspacesMenuDropdown"]') diff --git a/apps/remix-ide/ci/browser_test.sh b/apps/remix-ide/ci/browser_test.sh index ed1e968109e..52b72c8b176 100755 --- a/apps/remix-ide/ci/browser_test.sh +++ b/apps/remix-ide/ci/browser_test.sh @@ -12,10 +12,50 @@ npx http-server -p 9090 --cors='*' ./node_modules & yarn run serve:production & sleep 5 -# grep -IRiL "@disabled" "dist/apps/remix-ide-e2e/src/tests" | grep "\.spec\|\.test" | xargs -I {} basename {} .test.js | grep -E "\b[${2}]" -# TESTFILES=$(grep -IRiL "@disabled" "dist/apps/remix-ide-e2e/src/tests" | grep "\.spec\|\.test" | xargs -I {} basename {} .test.js | grep -E "\b[$2]" | circleci tests split --split-by=timings ) +set -x # Enable debug mode + +echo "Raw test files before filtering:" node apps/remix-ide/ci/splice_tests.js $2 $3 -TESTFILES=$(node apps/remix-ide/ci/splice_tests.js $2 $3 | grep -v 'metamask' | circleci tests split --split-by=timings) + +# Get initial test files +TESTFILES=$(node apps/remix-ide/ci/splice_tests.js $2 $3 | grep -v 'metamask' || true) + +echo "Filtered test files (without metamask):" +echo "$TESTFILES" + +# If $4 is provided, filter by it +if [ -n "$4" ]; then + FILTER_PATTERN=$(echo "$4" | sed -E 's/[,[:space:]]+/|/g') + echo "Filtering by pattern: $FILTER_PATTERN" + + if [ -n "$TESTFILES" ]; then + TESTFILES=$(echo "$TESTFILES" | grep -E "$FILTER_PATTERN" || true) + fi +fi + +# Log final test files +echo "Running the following test files:" +echo "$TESTFILES" + +set +x # Disable debug mode + +# Check if TESTFILES has content +if [ -z "$TESTFILES" ]; then + echo "No test files found after filtering. Exiting." + exit 0 # ✅ Exit gracefully (change to exit 1 if failure is preferred) +fi + +# Split tests only if there are valid test files +TESTFILES=$(echo "$TESTFILES" | circleci tests split --split-by=timings) + +if [ -z "$TESTFILES" ]; then + echo "No test files found after splitting. Exiting." + exit 0 # ✅ Exit gracefully (change to exit 1 if failure is preferred) +fi + +echo "Running the following test files after splitting:" +echo "$TESTFILES" + for TESTFILE in $TESTFILES; do npx nightwatch --config dist/apps/remix-ide-e2e/nightwatch-${1}.js dist/apps/remix-ide-e2e/src/tests/${TESTFILE}.js --env=$1 || npx nightwatch --config dist/apps/remix-ide-e2e/nightwatch-${1}.js dist/apps/remix-ide-e2e/src/tests/${TESTFILE}.js --env=$1 || TEST_EXITCODE=1 done diff --git a/apps/remix-ide/ci/nightly.sh b/apps/remix-ide/ci/nightly.sh new file mode 100755 index 00000000000..d8ab8e6e6f2 --- /dev/null +++ b/apps/remix-ide/ci/nightly.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +set -e + +TESTFILES=$(grep -IRiL "\'@disabled\': \?true" "dist/apps/remix-ide-e2e/src/tests" | grep "\.nightly" | sort ) + +# count test files +fileCount=$(grep -IRiL "\'@disabled\': \?true" "dist/apps/remix-ide-e2e/src/tests" | grep "\.nightly" | wc -l ) +# if fileCount is 0 +if [ $fileCount -eq 0 ] +then + echo "No nightly tests found" + exit 0 +fi + +# Split tests only if there are valid test files +TESTFILES=$(echo "$TESTFILES" | circleci tests split --split-by=timings) + +BUILD_ID=${CIRCLE_BUILD_NUM:-${TRAVIS_JOB_NUMBER}} +echo "$BUILD_ID" +TEST_EXITCODE=0 + +npx ganache & +npx http-server -p 9090 --cors='*' ./node_modules & +yarn run serve:production & +sleep 5 + +for TESTFILE in $TESTFILES; do + npx nightwatch --config dist/apps/remix-ide-e2e/nightwatch-${1}.js $TESTFILE --env=$1 || TEST_EXITCODE=1 +done + +echo "$TEST_EXITCODE" +if [ "$TEST_EXITCODE" -eq 1 ] +then + exit 1 +fi diff --git a/nxbuid.js b/nxbuid.js new file mode 100755 index 00000000000..820c990ab33 --- /dev/null +++ b/nxbuid.js @@ -0,0 +1,52 @@ +const fs = require("fs"); +const path = require("path"); +const { execSync } = require("child_process"); + +// Detect configuration argument (default to "development" if none is provided) +const configArg = process.argv[2] || "development"; + +// Path to nx.json +const nxConfigPath = path.join(__dirname, "nx.json"); + +if (!fs.existsSync(nxConfigPath)) { + console.error("Error: nx.json file not found."); + process.exit(1); +} + +// Read nx.json +const nxConfig = JSON.parse(fs.readFileSync(nxConfigPath, "utf8")); + +// Get default project +const defaultProject = nxConfig.defaultProject; + +if (!defaultProject) { + console.error("Error: No default project found in nx.json."); + process.exit(1); +} + +// Path to project.json of the default project +const projectConfigPath = path.join(__dirname, "apps", defaultProject, "project.json"); + +if (!fs.existsSync(projectConfigPath)) { + console.error(`Error: project.json not found for default project (${defaultProject}).`); + process.exit(1); +} + +// Read project.json +const projectConfig = JSON.parse(fs.readFileSync(projectConfigPath, "utf8")); + +// Get implicit dependencies +const implicitDependencies = projectConfig.implicitDependencies || []; + +// Construct the `nx run-many` command +const projects = [defaultProject, ...implicitDependencies].join(","); +const command = `yarn nx affected --target=build --projects=${projects} --base=master --configuration=${configArg} --parallel --skip-nx-cache --max-parallel=8`; + +console.log("Generated command:", command); + +// Optionally, execute the command +try { + execSync(command, { stdio: "inherit" }); +} catch (error) { + console.error("Error executing command:", error.message); +} \ No newline at end of file diff --git a/package.json b/package.json index 13c1226015f..659a8642d6f 100644 --- a/package.json +++ b/package.json @@ -29,11 +29,11 @@ "scripts": { "nx": "nx", "start": "nx start", - "serve": "nx serve remix-ide --configuration=development", + "serve": "yarn build && nx serve remix-ide --configuration=development", "serve:hot": "nx serve remix-ide --configuration=hot", "serve:plugin": "nx serve ${npm_config_plugin} --configuration=development", "build:plugin": "NODE_ENV=production nx build ${npm_config_plugin} --configuration=production --skip-nx-cache", - "build": "nx build", + "build": "node ./nxbuid.js", "test": "nx test", "lint": "nx lint", "affected:apps": "nx affected:apps",