Skip to content

Brave #5880

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from
Draft

Brave #5880

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 51 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ parameters:
run_flaky_tests:
type: boolean
default: false
nightly:
type: boolean
default: false
filter:
type: string
default: ''
orbs:
browser-tools: circleci/browser-tools@1.5.2
win: circleci/windows@5.0
Expand Down Expand Up @@ -669,6 +675,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 >> ]
Expand All @@ -691,7 +714,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:
Expand Down Expand Up @@ -799,6 +822,32 @@ 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-browser-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: metamask
parameters:
browser: ["chrome", "brave"]
script: ["metamask.sh"]
job: ["0"]
jobsize: ["10"]
parallelism: [1]
build_all:
unless: << pipeline.parameters.run_flaky_tests >>
jobs:
Expand Down Expand Up @@ -887,6 +936,7 @@ workflows:
job: ["0","1","2","3","4","5","6","7","8","9"]
jobsize: ["10"]
parallelism: [15]

- remix-ide-browser:
requires:
- build
Expand Down
112 changes: 112 additions & 0 deletions apps/remix-ide-e2e/nightwatch-brave.ts
Original file line number Diff line number Diff line change
@@ -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]
}
}
}
}
};
19 changes: 18 additions & 1 deletion apps/remix-ide-e2e/src/select_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions apps/remix-ide-e2e/src/tests/metamask.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
}

Expand Down
20 changes: 16 additions & 4 deletions apps/remix-ide/ci/browser_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,22 @@ 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 )
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)
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
# Get initial test files (without 'metamask' tests)
TESTFILES=$(node apps/remix-ide/ci/splice_tests.js $2 $3 | grep -v 'metamask')

# If $4 is provided, filter by it
if [ -n "$4" ]; then
TESTFILES=$(echo "$TESTFILES" | grep "$4")
fi

# 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)

echo "$TEST_EXITCODE"
if [ "$TEST_EXITCODE" -eq 1 ]
Expand Down