From 1badfa8da4c9088b564cf2f42d595bdde5364d06 Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Wed, 27 Jul 2022 16:16:54 +0530 Subject: [PATCH] ci: Update conditions for FRAPPE_BRANCH --- .travis.yml | 15 ++++----------- bench/tests/test_base.py | 9 ++++----- bench/tests/test_init.py | 4 ++-- bench/tests/test_setup_production.py | 5 ++--- requirements.txt | 2 +- 5 files changed, 13 insertions(+), 22 deletions(-) diff --git a/.travis.yml b/.travis.yml index f1d8b83f..a3d88ab3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,11 +5,6 @@ sudo: true git: depth: 1 -cache: - - pip - - npm - - yarn - addons: mariadb: '10.3' @@ -61,20 +56,18 @@ matrix: script: python -m unittest -v bench.tests.test_utils && python -m unittest -v bench.tests.test_init install: - - pip3 install urllib3 pyOpenSSL ndg-httpsclient pyasn1 + - python -m pip install urllib3 pyOpenSSL ndg-httpsclient pyasn1 - if [ $TEST == "bench" ];then - wget -q -O /tmp/wkhtmltox.tar.xz https://github.com/frappe/wkhtmltopdf/raw/master/wkhtmltox-0.12.3_linux-generic-amd64.tar.xz; - tar -xf /tmp/wkhtmltox.tar.xz -C /tmp; - sudo mv /tmp/wkhtmltox/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf; - sudo chmod o+x /usr/local/bin/wkhtmltopdf; + wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb; + sudo apt install ./wkhtmltox_0.12.6-1.focal_amd64.deb; nvm install 14; nvm use 14; mkdir -p ~/.bench; cp -r $TRAVIS_BUILD_DIR/* ~/.bench; - pip3 install -q -U -e ~/.bench; + python -m pip install -U -e ~/.bench; mysql -u root -e "SET GLOBAL character_set_server = 'utf8mb4'"; mysql -u root -e "SET GLOBAL collation_server = 'utf8mb4_unicode_ci'"; diff --git a/bench/tests/test_base.py b/bench/tests/test_base.py index cc910f94..9ca23de4 100644 --- a/bench/tests/test_base.py +++ b/bench/tests/test_base.py @@ -17,10 +17,10 @@ PYTHON_VER = sys.version_info FRAPPE_BRANCH = "version-12" if PYTHON_VER.major == 3: - if PYTHON_VER.minor in [6, 7]: - FRAPPE_BRANCH = "version-13" - else: + if PYTHON_VER.minor >= 10: FRAPPE_BRANCH = "develop" + if 7 >= PYTHON_VER.minor >= 9: + FRAPPE_BRANCH = "version-13" class TestBenchBase(unittest.TestCase): @@ -134,5 +134,4 @@ class TestBenchBase(unittest.TestCase): def get_traceback(self): exc_type, exc_value, exc_tb = sys.exc_info() trace_list = traceback.format_exception(exc_type, exc_value, exc_tb) - body = "".join(str(t) for t in trace_list) - return body + return "".join(str(t) for t in trace_list) diff --git a/bench/tests/test_init.py b/bench/tests/test_init.py index 685dcf40..61150c83 100755 --- a/bench/tests/test_init.py +++ b/bench/tests/test_init.py @@ -184,15 +184,15 @@ class TestBenchInit(TestBenchBase): successful_switch = not exec_cmd( f"bench switch-to-branch {prevoius_branch} frappe --upgrade", cwd=bench_path ) - app_branch_after_switch = str(git.Repo(path=app_path).active_branch) if successful_switch: + app_branch_after_switch = str(git.Repo(path=app_path).active_branch) self.assertEqual(prevoius_branch, app_branch_after_switch) successful_switch = not exec_cmd( f"bench switch-to-branch {FRAPPE_BRANCH} frappe --upgrade", cwd=bench_path ) - app_branch_after_second_switch = str(git.Repo(path=app_path).active_branch) if successful_switch: + app_branch_after_second_switch = str(git.Repo(path=app_path).active_branch) self.assertEqual(FRAPPE_BRANCH, app_branch_after_second_switch) diff --git a/bench/tests/test_setup_production.py b/bench/tests/test_setup_production.py index 8c7a9100..4dae93c0 100644 --- a/bench/tests/test_setup_production.py +++ b/bench/tests/test_setup_production.py @@ -1,6 +1,7 @@ # imports - standard imports import getpass import os +import pathlib import re import subprocess import time @@ -76,9 +77,7 @@ class TestSetupProduction(TestBenchBase): if os.environ.get("CI"): sudoers = subprocess.check_output(["sudo", "cat", sudoers_file]).decode("utf-8") else: - with open(sudoers_file) as f: - sudoers = f.read() - + sudoers = pathlib.Path(sudoers_file).read_text() self.assertTrue(f"{user} ALL = (root) NOPASSWD: {service} nginx *" in sudoers) self.assertTrue(f"{user} ALL = (root) NOPASSWD: {nginx}" in sudoers) diff --git a/requirements.txt b/requirements.txt index 664c9639..d5b26797 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,5 +5,5 @@ Jinja2~=3.0.3 python-crontab~=2.4.0 requests semantic-version~=2.8.2 -setuptools +setuptools>60.0.0 tomli;python_version<"3.11" \ No newline at end of file