From 6583a986a26b1c7b6d5390cf2db684abfb985019 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Wed, 3 Sep 2025 14:49:34 +0000 Subject: [PATCH 1/2] ci: tests: move away from tox, just use pytest directly - it was originally added in https://github.com/spesmilo/electrum/pull/1334, with the goal of simplifying running the tests on local dev machines. However this usage is not documented anywhere, and AFAIK regular contributors don't use it either. - tox just adds another layer of abstraction that is not that useful IMO - I want more control over which electrum-deps are installed, which tox is (in this case) unhelpfully abstracting away --- .cirrus.yml | 49 +++++++++++++----------- contrib/requirements/requirements-ci.txt | 3 +- tox.ini | 17 -------- 3 files changed, 29 insertions(+), 40 deletions(-) delete mode 100644 tox.ini diff --git a/.cirrus.yml b/.cirrus.yml index 800a5b946..a70cada60 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -4,10 +4,9 @@ task: cpu: 1 memory: 2G matrix: - - name: "unittests: Tox Python $ELECTRUM_PYTHON_VERSION" + - name: "unittests: python $ELECTRUM_PYTHON_VERSION" env: ELECTRUM_IMAGE: python:$ELECTRUM_PYTHON_VERSION - TOXENV: py3 ELECTRUM_PYTHON_NAME: python3 matrix: - env: @@ -18,7 +17,7 @@ task: ELECTRUM_PYTHON_VERSION: 3.12 - env: ELECTRUM_PYTHON_VERSION: 3.13 - - name: "unittests: Tox Python 3 debug mode" + - name: "unittests: python 3 debug mode" env: ELECTRUM_PYTHON_VERSION: 3.13 # enable additional checks: @@ -27,28 +26,34 @@ task: pip_cache: folder: ~/.cache/pip fingerprint_script: echo $ELECTRUM_IMAGE && cat $ELECTRUM_REQUIREMENTS_CI && cat $ELECTRUM_REQUIREMENTS - version_script: - - $ELECTRUM_PYTHON_NAME --version tag_script: - git tag + libsecp_build_cache: + folder: contrib/_saved_secp256k1_build + fingerprint_script: sha256sum ./contrib/make_libsecp256k1.sh + populate_script: + - apt-get update + - apt-get -y install automake libtool + - ./contrib/make_libsecp256k1.sh + - mkdir contrib/_saved_secp256k1_build + - cp electrum/libsecp256k1.so.* contrib/_saved_secp256k1_build/ install_script: - apt-get update # qml test reqs: - apt-get -y install libgl1 libegl1 libxkbcommon0 libdbus-1-3 - pip install -r $ELECTRUM_REQUIREMENTS_CI - libsecp_build_cache: - folder: contrib/_saved_secp256k1_build - fingerprint_script: sha256sum ./contrib/make_libsecp256k1.sh - populate_script: - - apt-get -y install automake libtool - - ./contrib/make_libsecp256k1.sh - - mkdir contrib/_saved_secp256k1_build - - cp electrum/libsecp256k1.so.* contrib/_saved_secp256k1_build/ - tox_script: - - export PYTHONASYNCIODEBUG - - export PYTHONDEVMODE + # electrum itself: - export ELECTRUM_ECC_DONT_COMPILE=1 - - tox + - pip install ".[tests,qml_gui]" + version_script: + - $ELECTRUM_PYTHON_NAME --version + - pip freeze --all + pytest_script: + - > + coverage run --source=electrum \ + "--omit=electrum/gui/*,electrum/plugins/*,electrum/scripts/*" \ + -m pytest tests -v + - coverage report coveralls_script: - if [ ! -z "$COVERALLS_REPO_TOKEN" ] ; then coveralls ; fi env: @@ -89,7 +94,7 @@ task: ELECTRUM_REQUIREMENTS_CI: contrib/requirements/requirements-ci.txt # in addition, crowdin_api_key is set as an "override" in https://cirrus-ci.com/settings/... depends_on: - - "unittests: Tox Python 3.10" + - "unittests: python 3.10" only_if: $CIRRUS_BRANCH == 'master' task: @@ -222,7 +227,7 @@ task: CIRRUS_WORKING_DIR: /opt/wine64/drive_c/electrum CIRRUS_DOCKER_CONTEXT: contrib/build-wine depends_on: - - "unittests: Tox Python 3.10" + - "unittests: python 3.10" task: name: "build: Android (QML $APK_ARCH)" @@ -256,7 +261,7 @@ task: binaries_artifacts: path: "dist/*" depends_on: - - "unittests: Tox Python 3.10" + - "unittests: python 3.10" ## mac build disabled, as Cirrus CI no longer supports Intel-based mac builds #task: @@ -319,7 +324,7 @@ task: env: CIRRUS_DOCKER_CONTEXT: contrib/build-linux/appimage depends_on: - - "unittests: Tox Python 3.10" + - "unittests: python 3.10" task: container: @@ -342,7 +347,7 @@ task: env: OMIT_UNCLEAN_FILES: 1 depends_on: - - "unittests: Tox Python 3.10" + - "unittests: python 3.10" task: name: "check submodules" diff --git a/contrib/requirements/requirements-ci.txt b/contrib/requirements/requirements-ci.txt index 47cd6ac17..d9644b580 100644 --- a/contrib/requirements/requirements-ci.txt +++ b/contrib/requirements/requirements-ci.txt @@ -1,2 +1,3 @@ -tox +pytest +coverage coveralls diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 0007b6b45..000000000 --- a/tox.ini +++ /dev/null @@ -1,17 +0,0 @@ -[tox] - -[testenv] -deps= - pytest - coverage -passenv= - PYTHONASYNCIODEBUG - PYTHONDEVMODE -commands= - coverage run --source=electrum \ - '--omit=electrum/gui/*,electrum/plugins/*,electrum/scripts/*' \ - -m pytest tests -v - coverage report -extras= - tests - qml_gui From b60d2e9610367dc24f7d29a2782fe34c7b488baf Mon Sep 17 00:00:00 2001 From: SomberNight Date: Wed, 3 Sep 2025 16:03:14 +0000 Subject: [PATCH 2/2] ci: add task to run unittests with frozen deps I think it makes sense to run the tests with both the "latest" dependencies, and with the pinned dependencies that we package for releases. Testing with latest can reveal changes/issues with new dep versions, while testing with pinned is testing what users will actually run. Previously we were only testing with "latest". --- .cirrus.yml | 61 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 52 insertions(+), 9 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index a70cada60..c1a3529ff 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -1,13 +1,13 @@ +# unittests using the 'latest' runtime python-dependencies task: container: image: $ELECTRUM_IMAGE cpu: 1 memory: 2G matrix: - - name: "unittests: python $ELECTRUM_PYTHON_VERSION" + - name: "unittests: py$ELECTRUM_PYTHON_VERSION" env: ELECTRUM_IMAGE: python:$ELECTRUM_PYTHON_VERSION - ELECTRUM_PYTHON_NAME: python3 matrix: - env: ELECTRUM_PYTHON_VERSION: 3.10 @@ -17,7 +17,7 @@ task: ELECTRUM_PYTHON_VERSION: 3.12 - env: ELECTRUM_PYTHON_VERSION: 3.13 - - name: "unittests: python 3 debug mode" + - name: "unittests: py3.13, debug-mode" env: ELECTRUM_PYTHON_VERSION: 3.13 # enable additional checks: @@ -46,7 +46,7 @@ task: - export ELECTRUM_ECC_DONT_COMPILE=1 - pip install ".[tests,qml_gui]" version_script: - - $ELECTRUM_PYTHON_NAME --version + - python3 --version - pip freeze --all pytest_script: - > @@ -71,6 +71,49 @@ task: depends_on: - "linter: Flake8 Mandatory" +# unittests using the ~same frozen dependencies that are used in the released binaries +# note: not using pinned pyqt here, due to "qml_gui" extra +task: + container: + image: $ELECTRUM_IMAGE + cpu: 1 + memory: 2G + name: "unittests: py3.10, frozen-deps" + pip_cache: + folder: ~/.cache/pip + fingerprint_script: echo $ELECTRUM_IMAGE && cat contrib/requirements/requirements*.txt && cat contrib/deterministic-build/requirements*.txt + tag_script: + - git tag + libsecp_build_cache: + folder: contrib/_saved_secp256k1_build + fingerprint_script: sha256sum ./contrib/make_libsecp256k1.sh + populate_script: + - apt-get update + - apt-get -y install automake libtool + - ./contrib/make_libsecp256k1.sh + - mkdir contrib/_saved_secp256k1_build + - cp electrum/libsecp256k1.so.* contrib/_saved_secp256k1_build/ + install_script: + - apt-get update + # qml test reqs: + - apt-get -y install libgl1 libegl1 libxkbcommon0 libdbus-1-3 + - pip install -r contrib/deterministic-build/requirements-build-base.txt + - pip install -r contrib/requirements/requirements-ci.txt + # electrum itself: + - export ELECTRUM_ECC_DONT_COMPILE=1 + - pip install -r contrib/deterministic-build/requirements.txt -r contrib/deterministic-build/requirements-binaries.txt + - pip install ".[tests,qml_gui]" + version_script: + - python3 --version + - pip freeze --all + pytest_script: + - pytest tests -v + env: + ELECTRUM_IMAGE: python:3.10 + LD_LIBRARY_PATH: contrib/_saved_secp256k1_build/ + depends_on: + - "linter: Flake8 Mandatory" + task: name: "locale: upload to crowdin" container: @@ -94,7 +137,7 @@ task: ELECTRUM_REQUIREMENTS_CI: contrib/requirements/requirements-ci.txt # in addition, crowdin_api_key is set as an "override" in https://cirrus-ci.com/settings/... depends_on: - - "unittests: python 3.10" + - "unittests: py3.10" only_if: $CIRRUS_BRANCH == 'master' task: @@ -227,7 +270,7 @@ task: CIRRUS_WORKING_DIR: /opt/wine64/drive_c/electrum CIRRUS_DOCKER_CONTEXT: contrib/build-wine depends_on: - - "unittests: python 3.10" + - "unittests: py3.10" task: name: "build: Android (QML $APK_ARCH)" @@ -261,7 +304,7 @@ task: binaries_artifacts: path: "dist/*" depends_on: - - "unittests: python 3.10" + - "unittests: py3.10" ## mac build disabled, as Cirrus CI no longer supports Intel-based mac builds #task: @@ -324,7 +367,7 @@ task: env: CIRRUS_DOCKER_CONTEXT: contrib/build-linux/appimage depends_on: - - "unittests: python 3.10" + - "unittests: py3.10" task: container: @@ -347,7 +390,7 @@ task: env: OMIT_UNCLEAN_FILES: 1 depends_on: - - "unittests: python 3.10" + - "unittests: py3.10" task: name: "check submodules"