Skip to content

Commit

Permalink
CI: embed last test scripts into .travis.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
consideRatio committed Nov 1, 2020
1 parent 36e8e7b commit 6a4f160
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 96 deletions.
45 changes: 36 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ before_install:
# available on travis.
- pip install "docker~=4.2.0"

# Fix to avoid rebuilding images already built
- remove_docker_mirror_on_travis

# Explicitly set a namespace to use
- export K8S_NAMESPACE=binderhub-test


install:
# Fix to avoid rebuilding images already built
- remove_docker_mirror_on_travis

# Setup our minikube based Kubernetes cluster
- setup_minikube
- setup_kubectl
Expand Down Expand Up @@ -80,23 +81,49 @@ jobs:
- stage: test
name: main
script:
- ./ci/test-main
- ./testing/local-binder-k8s-hub/install-jupyterhub-chart
- await_jupyterhub
- pytest -m "not auth_test" --log-cli-level=10 -vsx --cov binderhub

- stage: test
name: auth
script:
- ./ci/test-auth
- ./testing/local-binder-k8s-hub/install-jupyterhub-chart --auth
- await_jupyterhub
- pytest -m "auth_test" --log-cli-level=10 -vsx --cov binderhub

- stage: test
name: helm
script:
- ./ci/test-helm
# Prepare
- echo "Preparing local BinderHub Helm chart"
- helm dependency update ./helm-chart/binderhub
- (cd helm-chart && chartpress)
- git --no-pager diff

# Install
- echo "Installing local BinderHub Helm chart with JupyterHub as a dependency into k8s cluster"
- generate_binderhub_chart_config_remote
- |
helm upgrade --install --create-namespace --namespace $K8S_NAMESPACE \
binderhub-test helm-chart/binderhub \
--values testing/k8s-binder-k8s-hub/binderhub-chart-config.yaml \
--values testing/k8s-binder-k8s-hub/binderhub-chart-config-remote.yaml
- await_binderhub

# Test
- export BINDER_URL=http://$(minikube ip):30901
- echo "Running tests against $BINDER_URL"
- mark="remote${GITHUB_ACCESS_TOKEN:+ and not github_api}"
- pytest -vsx -m "$mark" --log-cli-level=10 --cov binderhub


- stage: publish
name: publish:helm-chart
install:
- remove_docker_mirror_on_travis
install: # overrides default
- setup_helm
- pip install chartpress
script:
script: # overrides default
- ./ci/publish
after_failure:
- echo "Required dummy override of default 'after_failure' in .travis.yml."
Expand Down
20 changes: 12 additions & 8 deletions ci/common
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
# Use https://www.shellcheck.net/ to reduce mistakes if you make changes to this file.

remove_docker_mirror_on_travis() {
Expand All @@ -13,21 +13,18 @@ remove_docker_mirror_on_travis() {
sudo systemctl restart docker
docker ps -a
}
export -f remove_docker_mirror_on_travis

setup_kubectl () {
echo "setup kubectl"
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v${KUBE_VERSION}/bin/linux/amd64/kubectl
chmod +x kubectl
sudo mv kubectl /usr/local/bin/
}
export -f setup_kubectl

setup_helm () {
echo "setup helm ${HELM_VERSION}"
curl -sf https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | DESIRED_VERSION=v${HELM_VERSION} bash
}
export -f setup_helm

setup_minikube () {
# install conntrack for minikube with k8s 1.18.2
Expand All @@ -44,7 +41,6 @@ setup_minikube () {
sudo CHANGE_MINIKUBE_NONE_USER=true minikube start --vm-driver=none --kubernetes-version=v${KUBE_VERSION}
minikube update-context
}
export -f setup_minikube

await_jupyterhub() {
kubectl rollout status --watch --timeout 300s deployment/proxy --namespace ${K8S_NAMESPACE:-binderhub-test} \
Expand All @@ -55,13 +51,22 @@ await_jupyterhub() {
fi
)
}
export -f await_jupyterhub

await_binderhub() {
await_jupyterhub
kubectl rollout status --watch --timeout 300s deployment/binder --namespace ${K8S_NAMESPACE:-binderhub-test}
}
export -f await_binderhub

generate_binderhub_chart_config_remote () {
file=testing/k8s-binder-k8s-hub/binderhub-chart-config-remote.yaml
echo "config:" > $file
echo " BinderHub:" >> $file
echo " hub_url: http://$(minikube ip):30902"
if [[ ! -z "$GITHUB_ACCESS_TOKEN" ]]; then
echo " GitHubRepoProvider:" >> $file
echo " access_token: $GITHUB_ACCESS_TOKEN" >> $file
fi
}

full_namespace_report () {
# list config (secret,configmap)
Expand Down Expand Up @@ -94,4 +99,3 @@ full_namespace_report () {
) | xargs --max-args 1 --no-run-if-empty --max-lines \
sh -c 'printf "\nPending user pod detected ($0)\n - Logs of deploy/user-scheduler:\n"; kubectl logs --all-containers deploy/user-scheduler --namespace ${K8S_NAMESPACE:-binderhub-test}'
}
export -f full_namespace_report
7 changes: 0 additions & 7 deletions ci/test-auth

This file was deleted.

64 changes: 0 additions & 64 deletions ci/test-helm

This file was deleted.

8 changes: 0 additions & 8 deletions ci/test-main

This file was deleted.

0 comments on commit 6a4f160

Please sign in to comment.