|
| 1 | +name: Tests |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: [master, main] |
| 7 | + |
| 8 | +defaults: |
| 9 | + run: |
| 10 | + shell: bash |
| 11 | + |
| 12 | +jobs: |
| 13 | + # Most of the "main", "auth" and "helm" jobs are the same and only differ |
| 14 | + # in small things. Unfortunately there is no easy way to share steps between |
| 15 | + # jobs or have "template" jobs, so we use `if` conditions on steps |
| 16 | + tests: |
| 17 | + runs-on: ubuntu-20.04 |
| 18 | + strategy: |
| 19 | + # keep running so we can see if tests with other k3s/k8s/helm versions pass |
| 20 | + fail-fast: false |
| 21 | + matrix: |
| 22 | + include: |
| 23 | + # This version of k3s uses kubernetes v1.18 |
| 24 | + - k3s-version: v1.18.10+k3s2 |
| 25 | + helm_version: v3.4.0 |
| 26 | + test: main |
| 27 | + - k3s-version: v1.18.10+k3s2 |
| 28 | + helm_version: v3.4.0 |
| 29 | + test: auth |
| 30 | + - k3s-version: v1.18.10+k3s2 |
| 31 | + helm_version: v3.4.0 |
| 32 | + test: helm |
| 33 | + steps: |
| 34 | + - uses: actions/checkout@v2 |
| 35 | + with: |
| 36 | + # chartpress requires the full history |
| 37 | + fetch-depth: 0 |
| 38 | + |
| 39 | + with: |
| 40 | + k3s-version: ${{ matrix.k3s-version }} |
| 41 | + helm-version: ${{ matrix.helm-version }} |
| 42 | + metrics-enabled: false |
| 43 | + traefik-enabled: false |
| 44 | + docker-enabled: true |
| 45 | + - uses: actions/setup-python@v2 |
| 46 | + with: |
| 47 | + python-version: '3.8' |
| 48 | + - name: Display kubernetes related details |
| 49 | + run: | |
| 50 | + echo "kubeconfig: $KUBECONFIG" |
| 51 | + echo |
| 52 | + echo "List of running pods:" |
| 53 | + kubectl get pods --all-namespaces |
| 54 | + echo |
| 55 | + echo "List of cluster nodes:" |
| 56 | + kubectl get nodes |
| 57 | + echo |
| 58 | + echo "Helm list output:" |
| 59 | + helm list |
| 60 | + - name: Setup helm chart repositories |
| 61 | + run: | |
| 62 | + helm repo add jupyterhub https://jupyterhub.github.io/helm-chart/ |
| 63 | + helm repo update |
| 64 | + - name: Setup OS level dependencies |
| 65 | + run: | |
| 66 | + sudo apt-get update |
| 67 | + sudo apt-get install --yes \ |
| 68 | + build-essential \ |
| 69 | + curl \ |
| 70 | + libcurl4-openssl-dev \ |
| 71 | + libssl-dev |
| 72 | + - uses: actions/setup-node@v2-beta |
| 73 | + with: |
| 74 | + node-version: '14' |
| 75 | + - name: Run webpack to build static assets |
| 76 | + run: | |
| 77 | + npm install |
| 78 | + npm run webpack |
| 79 | + - name: Setup Python package dependencies |
| 80 | + run: | |
| 81 | + # Install development requirements, package requirements, and frozen image |
| 82 | + # requirements, with an increasing priority. |
| 83 | + pip install -r dev-requirements.txt |
| 84 | + pip install . |
| 85 | + pip install -r helm-chart/images/binderhub/requirements.txt |
| 86 | + - name: Install JupyterHub chart for main tests |
| 87 | + if: matrix.test == 'main' |
| 88 | + run: ./testing/local-binder-k8s-hub/install-jupyterhub-chart |
| 89 | + - name: Install JupyterHub chart for auth tests |
| 90 | + if: matrix.test == 'auth' |
| 91 | + run: ./testing/local-binder-k8s-hub/install-jupyterhub-chart --auth |
| 92 | + - name: Use chartpress to create the helm chart |
| 93 | + if: matrix.test == 'helm' |
| 94 | + run: | |
| 95 | + # Use chartpress to create the helm chart and build its images |
| 96 | + helm dependency update ./helm-chart/binderhub |
| 97 | + (cd helm-chart && chartpress) |
| 98 | + git --no-pager diff |
| 99 | + - name: Validate the chart against the k8s API |
| 100 | + if: matrix.test == 'helm' |
| 101 | + run: | |
| 102 | + helm template --validate binderhub-test helm-chart/binderhub \ |
| 103 | + --values testing/k8s-binder-k8s-hub/binderhub-chart-config.yaml \ |
| 104 | + --set config.BinderHub.hub_url=http://localhost:30902 \ |
| 105 | + --set config.BinderHub.access_token=$GITHUB_ACCESS_TOKEN |
| 106 | + - name: Install the chart |
| 107 | + if: matrix.test == 'helm' |
| 108 | + run: | |
| 109 | + helm upgrade --install binderhub-test helm-chart/binderhub \ |
| 110 | + --values testing/k8s-binder-k8s-hub/binderhub-chart-config.yaml \ |
| 111 | + --set config.BinderHub.hub_url=http://localhost:30902 \ |
| 112 | + --set config.BinderHub.hub_url_local=http://proxy-public \ |
| 113 | + --set config.BinderHub.access_token=$GITHUB_ACCESS_TOKEN |
| 114 | + - name: Wait for JupyterHub to be ready |
| 115 | + run: | |
| 116 | + # Wait for JupyterHub to be ready |
| 117 | + set -e |
| 118 | + . ci/common |
| 119 | + await_jupyterhub |
| 120 | + # Next few commands are here for sanity checking/debugging of CI |
| 121 | + # related issues |
| 122 | + echo "Proxy service details" |
| 123 | + kubectl get svc proxy-public -o json |
| 124 | + echo |
| 125 | + echo "kubectl describe svc proxy-public" |
| 126 | + kubectl describe svc proxy-public |
| 127 | + echo |
| 128 | + echo "kubectl get svc" |
| 129 | + kubectl get svc |
| 130 | + echo |
| 131 | + echo "curl http://localhost:30902/hub/api/" should print the JupyterHub version |
| 132 | + curl http://localhost:30902/hub/api/ |
| 133 | + - name: Wait for binderhub to be ready |
| 134 | + if: matrix.test == 'helm' |
| 135 | + run: | |
| 136 | + # Wait for BinderHub to be ready |
| 137 | + set -e |
| 138 | + . ci/common |
| 139 | + await_binderhub |
| 140 | + echo "curl http://localhost:30901/health" to check BinderHub\'s health |
| 141 | + curl http://localhost:30901/health |
| 142 | + echo |
| 143 | + - name: Run main tests |
| 144 | + if: matrix.test == 'main' |
| 145 | + # running the "main" tests means "all tests that aren't auth" |
| 146 | + run: pytest -m "not auth" -vx --cov binderhub |
| 147 | + - name: Run auth tests |
| 148 | + if: matrix.test == 'auth' |
| 149 | + # running the "auth" tests means "all tests that are marked as auth" |
| 150 | + run: pytest -m "auth" -vx --cov binderhub |
| 151 | + - name: Run helm tests |
| 152 | + if: matrix.test == 'helm' |
| 153 | + run: | |
| 154 | + export BINDER_URL=http://localhost:30901 |
| 155 | + pytest -m "remote" -vx --cov binderhub |
| 156 | + - name: Kubernetes namespace report |
| 157 | + if: ${{ failure() }} |
| 158 | + run: | |
| 159 | + # Display debugging information |
| 160 | + . ci/common |
| 161 | + full_namespace_report |
| 162 | + - name: Upload coverage stats |
| 163 | + uses: codecov/codecov-action@v1 |
| 164 | + # https://help.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions |
| 165 | + # Upload regardless of whether tests pass or fail |
| 166 | + if: ${{ !cancelled() }} |
0 commit comments