mirror of
https://github.com/basicswap/basicswap.git
synced 2025-11-05 18:38:09 +01:00
tests: Run selenium test in CI
This commit is contained in:
41
.github/workflows/ci.yml
vendored
41
.github/workflows/ci.yml
vendored
@@ -9,6 +9,9 @@ concurrency:
|
|||||||
env:
|
env:
|
||||||
BIN_DIR: /tmp/cached_bin
|
BIN_DIR: /tmp/cached_bin
|
||||||
TEST_RELOAD_PATH: /tmp/test_basicswap
|
TEST_RELOAD_PATH: /tmp/test_basicswap
|
||||||
|
BSX_SELENIUM_DRIVER: firefox-ci
|
||||||
|
XMR_RPC_USER: xmr_user
|
||||||
|
XMR_RPC_PWD: xmr_pwd
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ci:
|
ci:
|
||||||
@@ -24,8 +27,18 @@ jobs:
|
|||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
|
if [ $(dpkg-query -W -f='${Status}' firefox 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
|
||||||
|
install -d -m 0755 /etc/apt/keyrings
|
||||||
|
wget -q https://packages.mozilla.org/apt/repo-signing-key.gpg -O- | sudo tee /etc/apt/keyrings/packages.mozilla.org.asc > /dev/null
|
||||||
|
echo "deb [signed-by=/etc/apt/keyrings/packages.mozilla.org.asc] https://packages.mozilla.org/apt mozilla main" | sudo tee -a /etc/apt/sources.list.d/mozilla.list > /dev/null
|
||||||
|
echo "Package: *" | sudo tee /etc/apt/preferences.d/mozilla
|
||||||
|
echo "Pin: origin packages.mozilla.org" | sudo tee -a /etc/apt/preferences.d/mozilla
|
||||||
|
echo "Pin-Priority: 1000" | sudo tee -a /etc/apt/preferences.d/mozilla
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y firefox
|
||||||
|
fi
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install flake8 codespell pytest
|
pip install flake8 codespell pytest selenium
|
||||||
pip install -r requirements.txt --require-hashes
|
pip install -r requirements.txt --require-hashes
|
||||||
- name: Install
|
- name: Install
|
||||||
run: |
|
run: |
|
||||||
@@ -33,13 +46,13 @@ jobs:
|
|||||||
# Print the core versions to a file for caching
|
# Print the core versions to a file for caching
|
||||||
basicswap-prepare --version --withcoins=bitcoin | tail -n +2 > core_versions.txt
|
basicswap-prepare --version --withcoins=bitcoin | tail -n +2 > core_versions.txt
|
||||||
cat core_versions.txt
|
cat core_versions.txt
|
||||||
- name: Running flake8
|
- name: Run flake8
|
||||||
run: |
|
run: |
|
||||||
flake8 --ignore=E203,E501,W503 --exclude=basicswap/contrib,basicswap/interface/contrib,.eggs,.tox,bin/install_certifi.py
|
flake8 --ignore=E203,E501,W503 --exclude=basicswap/contrib,basicswap/interface/contrib,.eggs,.tox,bin/install_certifi.py
|
||||||
- name: Running codespell
|
- name: Run codespell
|
||||||
run: |
|
run: |
|
||||||
codespell --check-filenames --disable-colors --quiet-level=7 --ignore-words=tests/lint/spelling.ignore-words.txt -S .git,.eggs,.tox,pgp,*.pyc,*basicswap/contrib,*basicswap/interface/contrib,*mnemonics.py,bin/install_certifi.py,*basicswap/static
|
codespell --check-filenames --disable-colors --quiet-level=7 --ignore-words=tests/lint/spelling.ignore-words.txt -S .git,.eggs,.tox,pgp,*.pyc,*basicswap/contrib,*basicswap/interface/contrib,*mnemonics.py,bin/install_certifi.py,*basicswap/static
|
||||||
- name: Running test_other
|
- name: Run test_other
|
||||||
run: |
|
run: |
|
||||||
pytest tests/basicswap/test_other.py
|
pytest tests/basicswap/test_other.py
|
||||||
- name: Cache coin cores
|
- name: Cache coin cores
|
||||||
@@ -55,17 +68,33 @@ jobs:
|
|||||||
name: Running basicswap-prepare
|
name: Running basicswap-prepare
|
||||||
run: |
|
run: |
|
||||||
basicswap-prepare --bindir="$BIN_DIR" --preparebinonly --withcoins=particl,bitcoin,monero
|
basicswap-prepare --bindir="$BIN_DIR" --preparebinonly --withcoins=particl,bitcoin,monero
|
||||||
- name: Running test_xmr
|
- name: Run test_xmr
|
||||||
run: |
|
run: |
|
||||||
export PYTHONPATH=$(pwd)
|
export PYTHONPATH=$(pwd)
|
||||||
export PARTICL_BINDIR="$BIN_DIR/particl"
|
export PARTICL_BINDIR="$BIN_DIR/particl"
|
||||||
export BITCOIN_BINDIR="$BIN_DIR/bitcoin"
|
export BITCOIN_BINDIR="$BIN_DIR/bitcoin"
|
||||||
export XMR_BINDIR="$BIN_DIR/monero"
|
export XMR_BINDIR="$BIN_DIR/monero"
|
||||||
pytest tests/basicswap/test_btc_xmr.py::TestBTC -k "test_003_api or test_02_a_leader_recover_a_lock_tx"
|
pytest tests/basicswap/test_btc_xmr.py::TestBTC -k "test_003_api or test_02_a_leader_recover_a_lock_tx"
|
||||||
- name: Running test_encrypted_xmr_reload
|
- name: Run test_encrypted_xmr_reload
|
||||||
run: |
|
run: |
|
||||||
export PYTHONPATH=$(pwd)
|
export PYTHONPATH=$(pwd)
|
||||||
export TEST_PATH=${TEST_RELOAD_PATH}
|
export TEST_PATH=${TEST_RELOAD_PATH}
|
||||||
mkdir -p ${TEST_PATH}/bin
|
mkdir -p ${TEST_PATH}/bin
|
||||||
cp -r $BIN_DIR/* ${TEST_PATH}/bin/
|
cp -r $BIN_DIR/* ${TEST_PATH}/bin/
|
||||||
pytest tests/basicswap/extended/test_encrypted_xmr_reload.py
|
pytest tests/basicswap/extended/test_encrypted_xmr_reload.py
|
||||||
|
- name: Run selenium tests
|
||||||
|
run: |
|
||||||
|
export TEST_PATH=/tmp/test_persistent
|
||||||
|
mkdir -p ${TEST_PATH}/bin
|
||||||
|
cp -r $BIN_DIR/* ${TEST_PATH}/bin/
|
||||||
|
export PYTHONPATH=$(pwd)
|
||||||
|
python tests/basicswap/extended/test_xmr_persistent.py > /tmp/log.txt 2>&1 & PID=$!
|
||||||
|
echo "Starting test_xmr_persistent, PID $PID"
|
||||||
|
until curl -s -f -o /dev/null "http://localhost:12701/json/coins"
|
||||||
|
do
|
||||||
|
tail -n 1 /tmp/log.txt
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
echo "Running test_settings.py"
|
||||||
|
python tests/basicswap/selenium/test_settings.py
|
||||||
|
kill -9 $PID
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
export RESET_TEST=true
|
|
||||||
export TEST_PATH=/tmp/test_persistent
|
export TEST_PATH=/tmp/test_persistent
|
||||||
mkdir -p ${TEST_PATH}/bin
|
mkdir -p ${TEST_PATH}/bin
|
||||||
cp -r ~/tmp/basicswap_bin/* ${TEST_PATH}/bin
|
cp -r ~/tmp/basicswap_bin/* ${TEST_PATH}/bin
|
||||||
@@ -20,6 +19,10 @@ python tests/basicswap/extended/test_xmr_persistent.py
|
|||||||
# Copy coin releases to permanent storage for faster subsequent startups
|
# Copy coin releases to permanent storage for faster subsequent startups
|
||||||
cp -r ${TEST_PATH}/bin/ ~/tmp/basicswap_bin/
|
cp -r ${TEST_PATH}/bin/ ~/tmp/basicswap_bin/
|
||||||
|
|
||||||
|
|
||||||
|
# Continue existing chains with
|
||||||
|
export RESET_TEST=false
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
@@ -62,7 +65,7 @@ from basicswap.interface.dcr.rpc import callrpc as callrpc_dcr
|
|||||||
import basicswap.bin.run as runSystem
|
import basicswap.bin.run as runSystem
|
||||||
|
|
||||||
test_path = os.path.expanduser(os.getenv("TEST_PATH", "/tmp/test_persistent"))
|
test_path = os.path.expanduser(os.getenv("TEST_PATH", "/tmp/test_persistent"))
|
||||||
RESET_TEST = make_boolean(os.getenv("RESET_TEST", "false"))
|
RESET_TEST = make_boolean(os.getenv("RESET_TEST", "true"))
|
||||||
|
|
||||||
PORT_OFS = int(os.getenv("PORT_OFS", 1))
|
PORT_OFS = int(os.getenv("PORT_OFS", 1))
|
||||||
UI_PORT = 12700 + PORT_OFS
|
UI_PORT = 12700 + PORT_OFS
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright (c) 2023 tecnovert
|
# Copyright (c) 2023 tecnovert
|
||||||
# Copyright (c) 2024 The Basicswap developers
|
# Copyright (c) 2024-2025 The Basicswap developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
@@ -20,19 +20,24 @@ BSX_SELENIUM_DRIVER = os.getenv("BSX_SELENIUM_DRIVER", "firefox")
|
|||||||
def get_driver():
|
def get_driver():
|
||||||
if BSX_SELENIUM_DRIVER == "firefox":
|
if BSX_SELENIUM_DRIVER == "firefox":
|
||||||
from selenium.webdriver import Firefox, FirefoxOptions
|
from selenium.webdriver import Firefox, FirefoxOptions
|
||||||
|
options = FirefoxOptions()
|
||||||
driver = Firefox(options=FirefoxOptions())
|
driver = Firefox(options=options)
|
||||||
|
elif BSX_SELENIUM_DRIVER == "firefox-ci":
|
||||||
|
from selenium.webdriver import Firefox, FirefoxOptions
|
||||||
|
options = FirefoxOptions()
|
||||||
|
options.headless = True
|
||||||
|
options.add_argument("start-maximized")
|
||||||
|
options.add_argument("--headless")
|
||||||
|
options.add_argument("--no-sandbox")
|
||||||
|
driver = Firefox(options=options)
|
||||||
elif BSX_SELENIUM_DRIVER == "chrome":
|
elif BSX_SELENIUM_DRIVER == "chrome":
|
||||||
from selenium.webdriver import Chrome, ChromeOptions
|
from selenium.webdriver import Chrome, ChromeOptions
|
||||||
|
|
||||||
driver = Chrome(options=ChromeOptions())
|
driver = Chrome(options=ChromeOptions())
|
||||||
elif BSX_SELENIUM_DRIVER == "safari":
|
elif BSX_SELENIUM_DRIVER == "safari":
|
||||||
from selenium.webdriver import Safari, SafariOptions
|
from selenium.webdriver import Safari, SafariOptions
|
||||||
|
|
||||||
driver = Safari(options=SafariOptions())
|
driver = Safari(options=SafariOptions())
|
||||||
else:
|
else:
|
||||||
raise ValueError("Unknown driver " + BSX_SELENIUM_DRIVER)
|
raise ValueError("Unknown driver " + BSX_SELENIUM_DRIVER)
|
||||||
|
|
||||||
return driver
|
return driver
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user