Skip to content

Commit 5e0c0fe

Browse files
authored
Merge branch 'master' into include-title
2 parents 3f70da7 + 42f8538 commit 5e0c0fe

File tree

16 files changed

+357
-252
lines changed

16 files changed

+357
-252
lines changed

.github/workflows/publish.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Publish helm chart and docker images
2+
3+
# Trigger the workflow on tags or commits to the main or master branch.
4+
on:
5+
push:
6+
branches: [main, master]
7+
tags:
8+
9+
defaults:
10+
run:
11+
# Declare bash be used by default in this workflow's "run" steps.
12+
#
13+
# NOTE: bash will by default run with:
14+
# --noprofile: Ignore ~/.profile etc.
15+
# --norc: Ignore ~/.bashrc etc.
16+
# -e: Exit directly on errors
17+
# -o pipefail: Don't mask errors from a command piped into another command
18+
shell: bash
19+
20+
jobs:
21+
# Builds and pushes docker images to DockerHub, packages the Helm chart and
22+
# pushes it to jupyterhub/helm-chart@gh-pages where index.yaml represents the
23+
# JupyterHub organization Helm chart repository.
24+
#
25+
# ref: https://github.com/jupyterhub/helm-chart
26+
# ref: https://hub.docker.com/orgs/jupyterhub
27+
#
28+
Publish:
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v2
32+
with:
33+
# chartpress requires the full history
34+
fetch-depth: 0
35+
- uses: actions/setup-python@v2
36+
with:
37+
python-version: '3.8'
38+
39+
- name: Install chart publishing dependencies (chartpress, helm)
40+
run: |
41+
. ./ci/common
42+
setup_helm v3.4.0
43+
pip install --no-cache-dir chartpress
44+
45+
- name: Setup push rights to jupyterhub/helm-chart
46+
# This was setup by...
47+
# 1. Generating a private/public key pair:
48+
# ssh-keygen -t ed25519 -C "jupyterhub/binderhub" -f /tmp/id_ed25519
49+
# 2. Registering the private key (/tmp/id_ed25519) as a secret for this
50+
# repo:
51+
# https://github.com/jupyterhub/binderhub/settings/secrets/actions
52+
# 3. Registering the public key (/tmp/id_ed25519.pub) as a deploy key
53+
# with push rights for the jupyterhub/helm chart repo:
54+
# https://github.com/jupyterhub/helm-chart/settings/keys
55+
#
56+
run: |
57+
mkdir -p ~/.ssh
58+
ssh-keyscan github.com >> ~/.ssh/known_hosts
59+
echo "${{ secrets.JUPYTERHUB_HELM_CHART_DEPLOY_KEY }}" > ~/.ssh/id_ed25519
60+
chmod 600 ~/.ssh/id_ed25519
61+
62+
- name: Setup push rights to Docker Hub
63+
# This was setup by...
64+
# 1. Creating a Docker Hub service account "jupyterhubbot"
65+
# 2. Making the account part of the "bots" team, and granting that team
66+
# permissions to push to the relevant images:
67+
# https://hub.docker.com/orgs/jupyterhub/teams/bots/permissions
68+
# 3. Registering the username and password as a secret for this repo:
69+
# https://github.com/jupyterhub/binderhub/settings/secrets/actions
70+
#
71+
run: |
72+
docker login -u "${{ secrets.DOCKER_USERNAME }}" -p "${{ secrets.DOCKER_PASSWORD }}"
73+
74+
- name: Configure a git user
75+
# Having a user.email and user.name configured with git is required to
76+
# make commits, which is something chartpress does when publishing.
77+
# While Travis CI had a dummy user by default, GitHub Actions doesn't
78+
# and require this explicitly setup.
79+
run: |
80+
git config --global user.email "[email protected]"
81+
git config --global user.name "GitHub Actions user"
82+
83+
- name: Publish images and chart with chartpress
84+
env:
85+
GITHUB_REPOSITORY: "${{ github.repository }}"
86+
run: |
87+
./ci/publish

.github/workflows/test.yml

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
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+
- uses: manics/[email protected]
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

Comments
 (0)