forked from jupyterhub/binderhub
-
Notifications
You must be signed in to change notification settings - Fork 0
256 lines (214 loc) · 8.21 KB
/
test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
name: Tests
on:
pull_request:
push:
workflow_dispatch:
jobs:
lint:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: check embedded chart code
run: ./ci/check_embedded_chart_code.py
# Most of the "main", "auth" and "helm" jobs are the same and only differ
# in small things. Unfortunately there is no easy way to share steps between
# jobs or have "template" jobs, so we use `if` conditions on steps
tests:
runs-on: ubuntu-20.04
strategy:
# keep running so we can see if tests with other k3s/k8s/helm versions pass
fail-fast: false
matrix:
k3s-channel:
- v1.19
helm-version:
- v3.5.0
test:
- main
- auth
- helm
steps:
- uses: actions/checkout@v2
with:
# chartpress requires the full history
fetch-depth: 0
- uses: jupyterhub/action-k3s-helm@v1
with:
k3s-version: ${{ matrix.k3s-version }}
helm-version: ${{ matrix.helm-version }}
metrics-enabled: false
traefik-enabled: false
docker-enabled: true
- name: Setup OS level dependencies
run: |
sudo apt-get update
sudo apt-get install --yes \
build-essential \
curl \
libcurl4-openssl-dev \
libssl-dev
- uses: actions/setup-node@v2-beta
with:
node-version: '14'
- name: Cache npm
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Run webpack to build static assets
run: |
npm install
npm run webpack
- uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-python-${{ hashFiles('**/*requirements.txt') }}
restore-keys: |
${{ runner.os }}-python-${{ hashFiles('**/*requirements.txt') }}
${{ runner.os }}-python-
- name: Update pip
run: |
pip install --upgrade pip
pip install --upgrade setuptools wheel
- name: Setup Python package dependencies
run: |
pip install -r dev-requirements.txt -r helm-chart/images/binderhub/requirements.txt
pip install .
- name: Install JupyterHub chart for main tests
if: matrix.test == 'main'
run: |
./testing/local-binder-k8s-hub/install-jupyterhub-chart
- name: Install JupyterHub chart for auth tests
if: matrix.test == 'auth'
run: |
./testing/local-binder-k8s-hub/install-jupyterhub-chart --auth
- name: Use chartpress to create the helm chart
if: matrix.test == 'helm'
run: |
# Use chartpress to create the helm chart and build its images
helm dependency update ./helm-chart/binderhub
(cd helm-chart && chartpress)
git --no-pager diff --color=always
- name: Generate values.schema.json from schema.yaml
if: matrix.test == 'helm'
run: |
tools/generate-json-schema.py
- name: "Helm template --validate (with lint-and-validate-values.yaml)"
if: matrix.test == 'helm'
run: |
helm template --validate binderhub-test helm-chart/binderhub \
--values tools/templates/lint-and-validate-values.yaml
- name: Validate the chart against the k8s API
if: matrix.test == 'helm'
run: |
helm template --validate binderhub-test helm-chart/binderhub \
--values testing/k8s-binder-k8s-hub/binderhub-chart-config.yaml \
--set config.BinderHub.hub_url=http://localhost:30902 \
--set config.BinderHub.access_token=$GITHUB_ACCESS_TOKEN
- name: Install the chart
if: matrix.test == 'helm'
run: |
helm upgrade --install binderhub-test helm-chart/binderhub \
--values testing/k8s-binder-k8s-hub/binderhub-chart-config.yaml \
--set config.BinderHub.hub_url=http://localhost:30902 \
--set config.BinderHub.hub_url_local=http://proxy-public \
--set config.BinderHub.access_token=$GITHUB_ACCESS_TOKEN
- name: Await and curl JupyterHub
run: |
. ci/common
await_jupyterhub
echo curl http://localhost:30902/hub/api/ should print the JupyterHub version
curl http://localhost:30902/hub/api/ --max-time 5 --retry 5 --retry-delay 1 --retry-connrefused
- name: Await and curl BinderHub
if: matrix.test == 'helm'
run: |
. ci/common
await_binderhub
echo curl http://localhost:30901/health to check BinderHub\'s health
curl http://localhost:30901/health --max-time 5 --retry 5 --retry-delay 1 --retry-connrefused
- name: Run main tests
if: matrix.test == 'main'
# running the "main" tests means "all tests that aren't auth"
run: pytest -m "not auth" -v --maxfail=10 --cov binderhub --durations=10 --color=yes
- name: Run auth tests
if: matrix.test == 'auth'
# running the "auth" tests means "all tests that are marked as auth"
run: pytest -m "auth" -v --maxfail=10 --cov binderhub --durations=10 --color=yes
- name: Run helm tests
if: matrix.test == 'helm'
run: |
export BINDER_URL=http://localhost:30901
pytest -m "remote" -v --maxfail=10 --cov binderhub --durations=10 --color=yes
# GitHub Action reference: https://github.com/jupyterhub/action-k8s-namespace-report
- name: Kubernetes namespace report
uses: jupyterhub/action-k8s-namespace-report@v1
if: always()
with:
important-workloads: deploy/binder deploy/hub deploy/proxy
# GitHub action reference: https://github.com/codecov/codecov-action
- name: Upload coverage stats
uses: codecov/codecov-action@v1
if: ${{ always() }}
test-local:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Setup OS level dependencies
run: |
sudo apt-get update
sudo apt-get install --yes \
build-essential \
curl \
libcurl4-openssl-dev \
libssl-dev
- uses: actions/setup-node@v2-beta
with:
node-version: '14'
- name: Cache npm
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.os }}-node-
- uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-python-${{ hashFiles('**/*requirements.txt') }}
restore-keys: |
${{ runner.os }}-python-${{ hashFiles('**/*requirements.txt') }}
${{ runner.os }}-python-
- name: Update pip
run: |
pip install --upgrade pip
pip install --upgrade setuptools wheel
- name: Setup Python package dependencies
run: |
pip install -r dev-requirements.txt -r testing/local-binder-local-hub/requirements.txt
pip install .
- name: Setup JupyterHub NPM dependencies
run: npm install -g configurable-http-proxy
- name: Await and curl JupyterHub
run: |
cd testing/local-binder-local-hub
jupyterhub --config=jupyterhub_config.py > jupyterhub.log 2>&1 &
sleep 5
echo curl http://localhost:8000/hub/api/ should print the JupyterHub version
curl http://localhost:8000/hub/api/ --max-time 5 --retry 5 --retry-delay 1 --retry-connrefused
- name: Run remote tests
run: |
export BINDER_URL=http://localhost:8000/services/binder/
pytest -m remote -v --color=yes
- name: Show hub logs
if: always()
run: cat testing/local-binder-local-hub/jupyterhub.log