mirror of
https://github.com/jupyterhub/the-littlest-jupyterhub.git
synced 2025-12-18 21:54:05 +08:00
Some refactoring
This commit is contained in:
@@ -33,6 +33,7 @@ commands:
|
||||
command: |
|
||||
apk add --no-cache python3 pytest
|
||||
- run:
|
||||
# Need this to indentify the circle pr branch
|
||||
name: install curl and jq
|
||||
command: |
|
||||
apk add curl curl-dev
|
||||
@@ -48,6 +49,7 @@ commands:
|
||||
|
||||
basic_tests:
|
||||
parameters:
|
||||
# Whether or not we should run update tests
|
||||
upgrade:
|
||||
type: string
|
||||
default: ""
|
||||
@@ -55,14 +57,15 @@ commands:
|
||||
- run:
|
||||
name: Run basic tests
|
||||
command: |
|
||||
PR_BRANCH=`(curl -s https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pulls/$CIRCLE_PR_NUMBER | jq -r ".head.ref")`
|
||||
PR_INFO_URL=https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pulls/$CIRCLE_PR_NUMBER
|
||||
PR_BRANCH=`(curl -s $PR_INFO_URL | jq -r ".head.ref")`
|
||||
if [ "$PR_BRANCH" == "null" ];then
|
||||
PR_BRANCH=$CIRCLE_BRANCH
|
||||
fi
|
||||
BRANCH=git+https://github.com/$CIRCLE_PROJECT_USERNAME/the-littlest-jupyterhub.git@$PR_BRANCH
|
||||
BOOTSTRAP_PIP_SPEC=git+https://github.com/$CIRCLE_PROJECT_USERNAME/the-littlest-jupyterhub.git@$PR_BRANCH
|
||||
|
||||
.circleci/integration-test.py run-test basic-tests \
|
||||
"$BRANCH" test_hub.py test_install.py test_extensions.py \
|
||||
"$BOOTSTRAP_PIP_SPEC" test_hub.py test_install.py test_extensions.py \
|
||||
<< parameters.upgrade >>
|
||||
admin_tests:
|
||||
parameters:
|
||||
@@ -73,15 +76,16 @@ commands:
|
||||
- run:
|
||||
name: Run admin tests
|
||||
command: |
|
||||
PR_BRANCH=`(curl -s https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pulls/$CIRCLE_PR_NUMBER | jq -r ".head.ref")`
|
||||
PR_INFO_URL=https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pulls/$CIRCLE_PR_NUMBER
|
||||
PR_BRANCH=`(curl -s $PR_INFO_URL | jq -r ".head.ref")`
|
||||
if [ "$PR_BRANCH" == "null" ];then
|
||||
PR_BRANCH=$CIRCLE_BRANCH
|
||||
fi
|
||||
BRANCH=git+https://github.com/$CIRCLE_PROJECT_USERNAME/the-littlest-jupyterhub.git@$PR_BRANCH
|
||||
BOOTSTRAP_PIP_SPEC=git+https://github.com/$CIRCLE_PROJECT_USERNAME/the-littlest-jupyterhub.git@$PR_BRANCH
|
||||
|
||||
.circleci/integration-test.py run-test \
|
||||
--installer-args "--admin admin:admin" \
|
||||
basic-tests $BRANCH test_admin_installer.py \
|
||||
basic-tests $BOOTSTRAP_PIP_SPEC test_admin_installer.py \
|
||||
<< parameters.upgrade >>
|
||||
|
||||
plugin_tests:
|
||||
@@ -93,15 +97,16 @@ commands:
|
||||
- run:
|
||||
name: Run plugin tests
|
||||
command: |
|
||||
PR_BRANCH=`(curl -s https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pulls/$CIRCLE_PR_NUMBER | jq -r ".head.ref")`
|
||||
PR_INFO_URL=https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pulls/$CIRCLE_PR_NUMBER
|
||||
PR_BRANCH=`(curl -s $PR_INFO_URL | jq -r ".head.ref")`
|
||||
if [ "$PR_BRANCH" == "null" ];then
|
||||
PR_BRANCH=$CIRCLE_BRANCH
|
||||
fi
|
||||
BRANCH=git+https://github.com/$CIRCLE_PROJECT_USERNAME/the-littlest-jupyterhub.git@$PR_BRANCH
|
||||
BOOTSTRAP_PIP_SPEC=git+https://github.com/$CIRCLE_PROJECT_USERNAME/the-littlest-jupyterhub.git@$PR_BRANCH
|
||||
|
||||
.circleci/integration-test.py run-test \
|
||||
--installer-args "--plugin /srv/src/integration-tests/plugins/simplest" \
|
||||
plugins $BRANCH test_simplest_plugin.py \
|
||||
plugins $BOOTSTRAP_PIP_SPEC test_simplest_plugin.py \
|
||||
<< parameters.upgrade >>
|
||||
|
||||
bootstrap_checks:
|
||||
|
||||
@@ -15,7 +15,7 @@ def build_systemd_image(image_name, source_path):
|
||||
])
|
||||
|
||||
|
||||
def run_systemd_image(image_name, container_name, branch_path):
|
||||
def run_systemd_image(image_name, container_name, bootstrap_pip_spec):
|
||||
"""
|
||||
Run docker image with systemd
|
||||
|
||||
@@ -35,9 +35,9 @@ def run_systemd_image(image_name, container_name, branch_path):
|
||||
'--memory', '1G',
|
||||
]
|
||||
|
||||
if branch_path:
|
||||
if bootstrap_pip_spec:
|
||||
cmd.append('-e')
|
||||
cmd.append(f'TLJH_BOOTSTRAP_PIP_SPEC={branch_path}')
|
||||
cmd.append(f'TLJH_BOOTSTRAP_PIP_SPEC={bootstrap_pip_spec}')
|
||||
|
||||
cmd.append(image_name)
|
||||
|
||||
@@ -81,12 +81,12 @@ def copy_to_container(container_name, src_path, dest_path):
|
||||
])
|
||||
|
||||
|
||||
def run_test(image_name, test_name, branch_path, test_files, upgrade, installer_args):
|
||||
def run_test(image_name, test_name, bootstrap_pip_spec, test_files, upgrade, installer_args):
|
||||
"""
|
||||
Wrapper that sets up tljh with installer_args & runs test_name
|
||||
"""
|
||||
stop_container(test_name)
|
||||
run_systemd_image(image_name, test_name, branch_path)
|
||||
run_systemd_image(image_name, test_name, bootstrap_pip_spec)
|
||||
|
||||
source_path = os.path.abspath(
|
||||
os.path.join(os.path.dirname(__file__), os.pardir)
|
||||
@@ -159,7 +159,7 @@ def main():
|
||||
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('branch_path')
|
||||
run_test_parser.add_argument('bootstrap_pip_spec')
|
||||
run_test_parser.add_argument('test_files', nargs='+')
|
||||
|
||||
show_logs_parser = subparsers.add_parser('show-logs')
|
||||
@@ -170,7 +170,7 @@ def main():
|
||||
image_name = 'tljh-systemd'
|
||||
|
||||
if args.action == 'run-test':
|
||||
run_test(image_name, args.test_name, args.branch_path, args.test_files, args.upgrade, args.installer_args)
|
||||
run_test(image_name, args.test_name, args.bootstrap_pip_spec, args.test_files, args.upgrade, args.installer_args)
|
||||
elif args.action == 'show-logs':
|
||||
show_logs(args.container_name)
|
||||
elif args.action == 'run':
|
||||
@@ -178,7 +178,7 @@ def main():
|
||||
elif args.action == 'copy':
|
||||
copy_to_container(args.container_name, args.src, args.dest)
|
||||
elif args.action == 'start-container':
|
||||
run_systemd_image(image_name, args.container_name, args.branch_path)
|
||||
run_systemd_image(image_name, args.container_name, args.bootstrap_pip_spec)
|
||||
elif args.action == 'stop-container':
|
||||
stop_container(args.container_name)
|
||||
elif args.action == 'build-image':
|
||||
|
||||
Reference in New Issue
Block a user