From 01ff89315bfa3a53237113fc1cb161ff9bf5f352 Mon Sep 17 00:00:00 2001 From: Ivanq Date: Mon, 19 Aug 2019 15:30:31 +0000 Subject: [PATCH] Add GitLab CI/CD support (#2163) * Use GitLab CI/CD * Force colored tests * Get rid of an error * Mark tests as slow * Disable codecov & coveralls * Python 3.5-3.8 * Add Python 3.4 * Support both OpenSSL 1.1.0 and 1.1.1+ * Test both OpenSSL 1.1.0 and 1.1.1+ * Fix OpenSSL 1.1.1 * Fix Python 3.4 build --- .gitignore | 1 + .gitlab-ci.yml | 48 +++++++++++++++++++ plugins/disabled-Bootstrapper/Test/pytest.ini | 1 + src/Crypt/CryptBitcoin.py | 9 +++- src/Test/conftest.py | 15 +++--- src/Test/pytest.ini | 1 + 6 files changed, 67 insertions(+), 8 deletions(-) create mode 100644 .gitlab-ci.yml diff --git a/.gitignore b/.gitignore index b3795821..c6cbd0a0 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ __pycache__/ .* !/.gitignore !/.travis.yml +!/.gitlab-ci.yml # Temporary files *.bak diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 00000000..b62c7b0c --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,48 @@ +stages: + - test + +.test_template: &test_template + stage: test + before_script: + - pip install --upgrade pip wheel + # Selenium and requests can't be installed without a requests hint on Python 3.4 + - pip install --upgrade requests>=2.22.0 + - pip install --upgrade codecov coveralls flake8 mock pytest==4.6.3 pytest-cov selenium + - pip install --upgrade -r requirements.txt + script: + - pip list + - openssl version -a + - python -m pytest -x plugins/CryptMessage/Test --color=yes + - python -m pytest -x plugins/Bigfile/Test --color=yes + - python -m pytest -x plugins/AnnounceLocal/Test --color=yes + - python -m pytest -x plugins/OptionalManager/Test --color=yes + - python -m pytest src/Test --cov=src --cov-config src/Test/coverage.ini --color=yes + - mv plugins/disabled-Multiuser plugins/Multiuser + - python -m pytest -x plugins/Multiuser/Test --color=yes + - mv plugins/disabled-Bootstrapper plugins/Bootstrapper + - python -m pytest -x plugins/Bootstrapper/Test --color=yes + - flake8 . --count --select=E9,F63,F72,F82 --show-source --statistics --exclude=src/lib/pybitcointools/ + +test:py3.4: + image: python:3.4.3 + <<: *test_template + +test:py3.5: + image: python:3.5.7 + <<: *test_template + +test:py3.6: + image: python:3.6.9 + <<: *test_template + +test:py3.7-openssl1.1.0: + image: python:3.7.0b5 + <<: *test_template + +test:py3.7-openssl1.1.1: + image: python:3.7.4 + <<: *test_template + +test:py3.8: + image: python:3.8.0b3 + <<: *test_template \ No newline at end of file diff --git a/plugins/disabled-Bootstrapper/Test/pytest.ini b/plugins/disabled-Bootstrapper/Test/pytest.ini index d09210d1..8ee21268 100644 --- a/plugins/disabled-Bootstrapper/Test/pytest.ini +++ b/plugins/disabled-Bootstrapper/Test/pytest.ini @@ -2,4 +2,5 @@ python_files = Test*.py addopts = -rsxX -v --durations=6 markers = + slow: mark a tests as slow. webtest: mark a test as a webtest. \ No newline at end of file diff --git a/src/Crypt/CryptBitcoin.py b/src/Crypt/CryptBitcoin.py index be0c1ba2..0d902726 100644 --- a/src/Crypt/CryptBitcoin.py +++ b/src/Crypt/CryptBitcoin.py @@ -26,9 +26,16 @@ def loadLib(lib_name): import bitcoin.core.key import bitcoin.wallet + try: + # OpenSSL 1.1.0 + ssl_version = bitcoin.core.key._ssl.SSLeay() + except AttributeError: + # OpenSSL 1.1.1+ + ssl_version = bitcoin.core.key._ssl.OpenSSL_version_num() + logging.info( "OpenSSL loaded: %s, version: %.9X in %.3fs" % - (bitcoin.core.key._ssl, bitcoin.core.key._ssl.SSLeay(), time.time() - s) + (bitcoin.core.key._ssl, ssl_version, time.time() - s) ) diff --git a/src/Test/conftest.py b/src/Test/conftest.py index 99fdae13..144256dd 100644 --- a/src/Test/conftest.py +++ b/src/Test/conftest.py @@ -109,13 +109,14 @@ from Debug import Debug def cleanup(): Db.dbCloseAll() for dir_path in [config.data_dir, config.data_dir + "-temp"]: - for file_name in os.listdir(dir_path): - ext = file_name.rsplit(".", 1)[-1] - if ext not in ["csr", "pem", "srl", "db", "json", "tmp"]: - continue - file_path = dir_path + "/" + file_name - if os.path.isfile(file_path): - os.unlink(file_path) + if os.path.isdir(dir_path): + for file_name in os.listdir(dir_path): + ext = file_name.rsplit(".", 1)[-1] + if ext not in ["csr", "pem", "srl", "db", "json", "tmp"]: + continue + file_path = dir_path + "/" + file_name + if os.path.isfile(file_path): + os.unlink(file_path) atexit.register(cleanup) diff --git a/src/Test/pytest.ini b/src/Test/pytest.ini index d09210d1..8ee21268 100644 --- a/src/Test/pytest.ini +++ b/src/Test/pytest.ini @@ -2,4 +2,5 @@ python_files = Test*.py addopts = -rsxX -v --durations=6 markers = + slow: mark a tests as slow. webtest: mark a test as a webtest. \ No newline at end of file