Install current pr branch

This commit is contained in:
GeorgianaElena
2020-02-18 16:32:45 +02:00
parent 15d849c275
commit 764806b999
2 changed files with 62 additions and 13 deletions

View File

@@ -37,19 +37,27 @@ commands:
upgrade: upgrade:
type: string type: string
default: "" default: ""
branch_path:
type: string
default: ""
steps: steps:
- run: - run:
name: Run basic tests name: Run basic tests
command: | command: |
.circleci/integration-test.py run-test basic-tests \ .circleci/integration-test.py run-test basic-tests \
test_hub.py test_install.py test_extensions.py \ test_hub.py test_install.py test_extensions.py \
<< parameters.upgrade >> << parameters.upgrade >> << parameters.branch_path >>
admin_tests: admin_tests:
parameters: parameters:
upgrade: upgrade:
type: string type: string
default: "" default: ""
branch_path:
type: string
default: ""
steps: steps:
- run: - run:
name: Run admin tests name: Run admin tests
@@ -57,13 +65,17 @@ commands:
.circleci/integration-test.py run-test \ .circleci/integration-test.py run-test \
--installer-args "--admin admin:admin" \ --installer-args "--admin admin:admin" \
basic-tests test_admin_installer.py \ basic-tests test_admin_installer.py \
<< parameters.upgrade >> << parameters.upgrade >> << parameters.branch_path >>
plugin_tests: plugin_tests:
parameters: parameters:
upgrade: upgrade:
type: string type: string
default: "" default: ""
branch_path:
type: string
default: ""
steps: steps:
- run: - run:
name: Run plugin tests name: Run plugin tests
@@ -80,6 +92,15 @@ commands:
command: | command: |
py.test integration-tests/test_bootstrap.py py.test integration-tests/test_bootstrap.py
get_pr_branch:
steps:
- run:
name: Get PR branch
command: |
CIRCLE_PR_BRANCH=`curl -s https://api.github.com/repos/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/pulls/${CIRCLE_PR_NUMBER} \
| grep '"ref":' | grep -v "master" | cut -d '"' -f4'
jobs: jobs:
unit-test: unit-test:
executor: ubuntu_docker executor: ubuntu_docker
@@ -127,19 +148,25 @@ jobs:
command: | command: |
apk add --no-cache python3 pytest apk add --no-cache python3 pytest
- get_pr_branch
- checkout - checkout
- setup_remote_docker - setup_remote_docker
- build_systemd_image - build_systemd_image
- basic-tests - basic-tests:
branch_path: "git+https://github.com/{CIRCLE_PROJECT_USERNAME}/the-littlest-jupyterhub.git@${CIRCLE_PR_BRANCH}"
- admin_tests - admin_tests:
branch_path: "git+https://github.com/{CIRCLE_PROJECT_USERNAME}/the-littlest-jupyterhub.git@${CIRCLE_PR_BRANCH}"
- plugin_tests - plugin_tests:
branch_path: "git+https://github.com/{CIRCLE_PROJECT_USERNAME}/the-littlest-jupyterhub.git@${CIRCLE_PR_BRANCH}"
- bootstrap_checks - bootstrap_checks:
branch_path: "git+https://github.com/{CIRCLE_PROJECT_USERNAME}/the-littlest-jupyterhub.git@${CIRCLE_PR_BRANCH}"
upgrade-test: upgrade-test:
@@ -152,6 +179,8 @@ jobs:
command: | command: |
apk add --no-cache python3 pytest apk add --no-cache python3 pytest
- get_pr_branch
- checkout - checkout
- setup_remote_docker - setup_remote_docker
@@ -160,12 +189,15 @@ jobs:
- basic-tests: - basic-tests:
upgrade: "--upgrade" upgrade: "--upgrade"
branch_path: "git+https://github.com/{CIRCLE_PROJECT_USERNAME}/the-littlest-jupyterhub.git@${CIRCLE_PR_BRANCH}"
- admin_tests: - admin_tests:
upgrade: "--upgrade" upgrade: "--upgrade"
branch_path: "git+https://github.com/{CIRCLE_PROJECT_USERNAME}/the-littlest-jupyterhub.git@${CIRCLE_PR_BRANCH}"
- plugin_tests: - plugin_tests:
upgrade: "--upgrade" upgrade: "--upgrade"
branch_path: "git+https://github.com/{CIRCLE_PROJECT_USERNAME}/the-littlest-jupyterhub.git@${CIRCLE_PR_BRANCH}"
documentation: documentation:

View File

@@ -15,7 +15,7 @@ def build_systemd_image(image_name, source_path):
]) ])
def run_systemd_image(image_name, container_name): def run_systemd_image(image_name, container_name, branch_path):
""" """
Run docker image with systemd Run docker image with systemd
@@ -23,7 +23,7 @@ def run_systemd_image(image_name, container_name):
Container named container_name will be started. Container named container_name will be started.
""" """
subprocess.check_call([ cmd = [
'docker', 'run', 'docker', 'run',
'--privileged', '--privileged',
'--mount', 'type=bind,source=/sys/fs/cgroup,target=/sys/fs/cgroup', '--mount', 'type=bind,source=/sys/fs/cgroup,target=/sys/fs/cgroup',
@@ -34,7 +34,12 @@ def run_systemd_image(image_name, container_name):
# If we change this, need to change all other references to this number. # If we change this, need to change all other references to this number.
'--memory', '1G', '--memory', '1G',
image_name image_name
]) ]
if branch_path:
cmd.append('-e', f'TLJH_BOOTSTRAP_PIP_SPEC="{branch_path}"')
subprocess.check_call(cmd)
def stop_container(container_name): def stop_container(container_name):
@@ -74,12 +79,12 @@ def copy_to_container(container_name, src_path, dest_path):
]) ])
def run_test(image_name, test_name, test_files, installer_args): def run_test(image_name, test_name, branch_path, test_files, upgrade, installer_args):
""" """
Wrapper that sets up tljh with installer_args & runs test_name Wrapper that sets up tljh with installer_args & runs test_name
""" """
stop_container(test_name) stop_container(test_name)
run_systemd_image(image_name, test_name) run_systemd_image(image_name, test_name, branch_path)
source_path = os.path.abspath( source_path = os.path.abspath(
os.path.join(os.path.dirname(__file__), os.pardir) os.path.join(os.path.dirname(__file__), os.pardir)
@@ -87,10 +92,20 @@ def run_test(image_name, test_name, test_files, installer_args):
copy_to_container(test_name, os.path.join(source_path, 'bootstrap/.'), '/srv/src') copy_to_container(test_name, os.path.join(source_path, 'bootstrap/.'), '/srv/src')
copy_to_container(test_name, os.path.join(source_path, 'integration-tests/'), '/srv/src') copy_to_container(test_name, os.path.join(source_path, 'integration-tests/'), '/srv/src')
# Install TLJH master first to test upgrades
if upgrade:
run_container_command(
test_name,
f'curl https://raw.githubusercontent.com/jupyterhub/the-littlest-jupyterhub/master/bootstrap/bootstrap.py | python3 -'
)
run_container_command( run_container_command(
test_name, test_name,
f'python3 /srv/src/bootstrap.py {installer_args}' f'python3 /srv/src/bootstrap.py {installer_args}'
) )
# Install pkgs from requirements in hub's pip, where # Install pkgs from requirements in hub's pip, where
# the bootstrap script installed the others # the bootstrap script installed the others
run_container_command( run_container_command(
@@ -140,7 +155,9 @@ def main():
run_test_parser = subparsers.add_parser('run-test') run_test_parser = subparsers.add_parser('run-test')
run_test_parser.add_argument('--installer-args', default='') run_test_parser.add_argument('--installer-args', default='')
run_test_parser.add_argument('--upgrade', action='store_true')
run_test_parser.add_argument('test_name') run_test_parser.add_argument('test_name')
run_test_parser.add_argument('branch_path')
run_test_parser.add_argument('test_files', nargs='+') run_test_parser.add_argument('test_files', nargs='+')
show_logs_parser = subparsers.add_parser('show-logs') show_logs_parser = subparsers.add_parser('show-logs')
@@ -151,7 +168,7 @@ def main():
image_name = 'tljh-systemd' image_name = 'tljh-systemd'
if args.action == 'run-test': if args.action == 'run-test':
run_test(image_name, args.test_name, args.test_files, args.installer_args) run_test(image_name, args.test_name, args.branch_path, args.test_files, args.upgrade, args.installer_args)
elif args.action == 'show-logs': elif args.action == 'show-logs':
show_logs(args.container_name) show_logs(args.container_name)
elif args.action == 'run': elif args.action == 'run':
@@ -159,7 +176,7 @@ def main():
elif args.action == 'copy': elif args.action == 'copy':
copy_to_container(args.container_name, args.src, args.dest) copy_to_container(args.container_name, args.src, args.dest)
elif args.action == 'start-container': elif args.action == 'start-container':
run_systemd_image(image_name, args.container_name) run_systemd_image(image_name, args.container_name, args.branch_path)
elif args.action == 'stop-container': elif args.action == 'stop-container':
stop_container(args.container_name) stop_container(args.container_name)
elif args.action == 'build-image': elif args.action == 'build-image':