Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

travis: Separate builds for setup, install script and tests #1036

Merged
merged 4 commits into from
Aug 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,42 +18,52 @@ matrix:
- name: "Python 2.7 Basic Setup"
python: 2.7
env: TEST=bench
script: python -m unittest -v bench.tests.test_init
script: python bench/tests/test_init.py TestBenchInit.basic

- name: "Python 3.6 Basic Setup"
python: 3.6
env: TEST=bench
script: python -m unittest -v bench.tests.test_init
script: python bench/tests/test_init.py TestBenchInit.basic

- name: "Python 3.7 Basic Setup"
python: 3.7
env: TEST=bench
script: python -m unittest -v bench.tests.test_init
script: python bench/tests/test_init.py TestBenchInit.basic

- name: "Python 3.8 Production Setup"
python: 3.8
env: TEST=bench
script: python -m unittest -v bench.tests.test_setup_production
script: python bench/tests/test_setup_production.py TestSetupProduction.production

- name: "Python 2.7 Production Setup"
python: 2.7
env: TEST=bench
script: python -m unittest -v bench.tests.test_setup_production
script: python bench/tests/test_setup_production.py TestSetupProduction.production

- name: "Python 3.6 Production Setup"
python: 3.6
env: TEST=bench
script: python -m unittest -v bench.tests.test_setup_production
script: python bench/tests/test_setup_production.py TestSetupProduction.production

- name: "Python 3.7 Production Setup"
python: 3.7
env: TEST=bench
script: python -m unittest -v bench.tests.test_setup_production
script: python bench/tests/test_setup_production.py TestSetupProduction.production

- name: "Python 3.8 Production Setup"
python: 3.8
env: TEST=bench
script: python -m unittest -v bench.tests.test_setup_production
script: python bench/tests/test_setup_production.py TestSetupProduction.production

- name: "Python 2.7 Tests"
python: 2.7
env: TEST=bench
script: python -m unittest -v bench.tests.test_init

- name: "Python 3.7 Tests"
python: 3.7
env: TEST=bench
script: python -m unittest -v bench.tests.test_init

- name: "Python 3.6 Easy Install"
python: 3.6
Expand Down
16 changes: 11 additions & 5 deletions bench/tests/test_base.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# imports - standard imports
import getpass
import json
import os
import shutil
import subprocess
import sys
import traceback
import unittest
import getpass

# imports - module imports
import bench
import bench.utils

# imports - third party imports
from six import PY2

# imports - module imports
import bench
import bench.utils

if PY2:
FRAPPE_BRANCH = "version-12"
Expand Down Expand Up @@ -102,3 +102,9 @@ def file_exists(self, path):
if os.environ.get("CI"):
return not subprocess.call(["sudo", "test", "-f", path])
return os.path.isfile(path)

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
11 changes: 9 additions & 2 deletions bench/tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import bench
import bench.utils
from bench.release import get_bumped_version
from bench.tests.test_base import TestBenchBase, FRAPPE_BRANCH
from bench.tests.test_base import FRAPPE_BRANCH, TestBenchBase


class TestBenchInit(TestBenchBase):
Expand All @@ -34,6 +34,13 @@ def test_init(self, bench_name="test-bench", **kwargs):
self.assert_config(bench_name)


def basic(self):
try:
self.test_init()
except Exception:
print(self.get_traceback())


def test_multiple_benches(self):
for bench_name in ("test-bench-1", "test-bench-2"):
self.init_bench(bench_name)
Expand Down Expand Up @@ -148,4 +155,4 @@ def test_switch_to_branch(self):


if __name__ == '__main__':
unittest.main()
unittest.main()
9 changes: 8 additions & 1 deletion bench/tests/test_setup_production.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ def test_setup_production(self):
bench.utils.exec_cmd("sudo bench disable-production", cwd=bench_path)


def production(self):
try:
self.test_setup_production()
except Exception:
print(self.get_traceback())


def assert_nginx_config(self, bench_name):
conf_src = os.path.join(os.path.abspath(self.benches_path), bench_name, 'config', 'nginx.conf')
conf_dest = "/etc/nginx/conf.d/{bench_name}.conf".format(bench_name=bench_name)
Expand Down Expand Up @@ -169,4 +176,4 @@ def assert_supervisor_process(self, bench_name, use_rq=True, disable_production=


if __name__ == '__main__':
unittest.main()
unittest.main()