From 68564849e61a0037cc83f2f5c6a5bfc3e7a8c6aa Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 28 Jun 2016 12:11:06 +0530 Subject: [PATCH] [fix] installer and travis --- .travis.yml | 13 ++++++++----- playbooks/develop/ubuntu.yml | 6 +++++- playbooks/install.py | 32 ++++++++++++++++++-------------- playbooks/production/install.yml | 1 + 4 files changed, 32 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index 42dbbf53..89dbafb2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,15 +8,18 @@ python: install: - sudo apt-get purge -y mysql-common mysql-server mysql-client - sudo apt-get install --only-upgrade -y git - # - sudo python $TRAVIS_BUILD_DIR/installer/install.py --user travis --skip-bench-setup - - sudo bash $TRAVIS_BUILD_DIR/install_scripts/setup_frappe.sh --skip-install-bench --mysql-root-password travis - - mkdir -p ~/bench-repo - - cp -r $TRAVIS_BUILD_DIR/* ~/bench-repo/ + - mkdir -p ~/.bench + - mkdir -p /tmp/.bench + - cp -r $TRAVIS_BUILD_DIR/* ~/.bench + - cp -r $TRAVIS_BUILD_DIR/* /tmp/.bench + + - sudo python $TRAVIS_BUILD_DIR/playbooks/install.py --user travis --run-travis --production + # - sudo bash $TRAVIS_BUILD_DIR/install_scripts/setup_frappe.sh --skip-install-bench --mysql-root-password travis # - cd ~ && sudo python bench-repo/installer/install.py --only-dependencies script: - cd ~ - sudo pip install --upgrade pip - - sudo pip install -e bench-repo + - sudo pip install -e ~/.bench # - sudo python -m unittest bench.tests.test_setup_production.TestSetupProduction.test_setup_production_v6 - sudo python -m unittest -v bench.tests.test_setup_production diff --git a/playbooks/develop/ubuntu.yml b/playbooks/develop/ubuntu.yml index 20106c2e..c930062f 100644 --- a/playbooks/develop/ubuntu.yml +++ b/playbooks/develop/ubuntu.yml @@ -68,9 +68,13 @@ # setup MariaDB - include: includes/setup_mariadb.yml + - debug: + var: run_travis + # setup frappe-bench - include: includes/setup_bench.yml + when: not run_travis # setup development environment - include: includes/setup_dev_env.yml - when: not production + when: not production and not run_travis diff --git a/playbooks/install.py b/playbooks/install.py index f79489b1..30f6ad5e 100644 --- a/playbooks/install.py +++ b/playbooks/install.py @@ -29,21 +29,23 @@ def install_bench(args): return # secure pip installation - if not os.path.exists("get-pip.py"): + if find_executable('pip'): run_os_command({ - 'apt-get': 'wget https://bootstrap.pypa.io/get-pip.py', - 'yum': 'wget https://bootstrap.pypa.io/get-pip.py' + 'yum': 'sudo pip install --upgrade setuptools pip', + 'apt-get': 'sudo pip install --upgrade setuptools pip', + 'brew': "sudo pip install --upgrade setuptools pip --user" }) - success = run_os_command({ - 'apt-get': 'sudo python get-pip.py', - 'yum': 'sudo python get-pip.py', - }) + else: + if not os.path.exists("get-pip.py"): + run_os_command({ + 'apt-get': 'wget https://bootstrap.pypa.io/get-pip.py', + 'yum': 'wget https://bootstrap.pypa.io/get-pip.py' + }) - - if success: - run_os_command({ - 'pip': "sudo pip install --upgrade setuptools --user python" + success = run_os_command({ + 'apt-get': 'sudo python get-pip.py', + 'yum': 'sudo python get-pip.py', }) # Restricting ansible version due to following bug in ansible 2.1 @@ -56,7 +58,8 @@ def install_bench(args): could_not_install('Ansible') # clone bench repo - clone_bench_repo(args) + if not args.run_travis: + clone_bench_repo(args) if is_sudo_user() and not args.user and not args.production: raise Exception('Please run this script as a non-root user with sudo privileges, but without using sudo or pass --user=USER') @@ -77,7 +80,8 @@ def install_bench(args): elif args.production: run_playbook('production/install.yml', sudo=True, extra_vars=extra_vars) - shutil.rmtree(tmp_bench_repo) + if os.path.exists(tmp_bench_repo): + shutil.rmtree(tmp_bench_repo) def install_python27(): version = (sys.version_info[0], sys.version_info[1]) @@ -180,7 +184,7 @@ def get_extra_vars_json(extra_args, run_travis=False): extra_vars.update(get_passwords(run_travis)) extra_vars.update(max_worker_connections=multiprocessing.cpu_count() * 1024) - branch = 'master' if extra_args.get('setup_production') else 'develop' + branch = 'master' if extra_args.get('production') else 'develop' extra_vars.update(branch=branch) user = args.user or getpass.getuser() diff --git a/playbooks/production/install.yml b/playbooks/production/install.yml index 039c07dc..0a2fd77d 100644 --- a/playbooks/production/install.yml +++ b/playbooks/production/install.yml @@ -9,6 +9,7 @@ # Setup Bench for production environment - include: includes/setup_bench_production.yml + when: not run_travis # Setup SELinux Policy, Optional can be done later # - include: includes/setup_selinux_policy.yml