-
Notifications
You must be signed in to change notification settings - Fork 93
199 lines (177 loc) · 6.45 KB
/
kubernetes_test.yaml
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
name: "Kubernetes Tests"
on:
pull_request:
paths:
- ".github/workflows/kubernetes_test.yaml"
- "tests/**"
- "tests_deployment/**"
- "tests_e2e/**"
- "scripts/**"
- "src/**"
- "pyproject.toml"
- "pytest.ini"
push:
branches:
- main
- develop
- release/\d{4}.\d{1,2}.\d{1,2}
paths:
- ".github/workflows/kubernetes_test.yaml"
- "tests/**"
- "tests_deployment/**"
- "tests_e2e/**"
- "scripts/**"
- "src/**"
- "pyproject.toml"
- "pytest.ini"
workflow_call:
inputs:
pr_number:
required: true
type: string
jobs:
test-kubernetes:
name: "Kubernetes Tests"
runs-on: "cirun-runner--${{ github.run_id }}"
defaults:
run:
shell: bash -l {0}
steps:
- name: "Set NEBARI_IMAGE_TAG=main"
run: |
echo "NEBARI_IMAGE_TAG=main" >> "$GITHUB_ENV"
echo "GITHUB_BASE_REF: ${GITHUB_BASE_REF}"
echo "GITHUB_HEAD_REF: ${GITHUB_HEAD_REF}"
echo "GITHUB_REF: ${GITHUB_REF}"
- name: 'Checkout Infrastructure'
uses: actions/checkout@main
- name: Checkout the branch from the PR that triggered the job
if: ${{ github.event_name == 'issue_comment' }}
run: |
hub version
hub pr checkout ${{ inputs.pr_number }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
uses: conda-incubator/setup-miniconda@v2
env:
CONDA: /home/runnerx/miniconda3
with:
python-version: 3.8
miniconda-version: "latest"
- name: Install Nebari
run: |
conda install --quiet --yes -c anaconda pip
pip install .[dev]
playwright install
- name: Download and Install Kubectl
run: |
mkdir -p bin
pushd bin
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.19.0/bin/linux/amd64/kubectl
chmod +x kubectl
echo "$PWD" >> $GITHUB_PATH
popd
- name: Enable docker permissions for user
run: |
sudo docker ps
sudo usermod -aG docker $USER && newgrp docker
docker info
docker ps
- name: Get routing table for docker pods
run: |
ip route
- name: Initialize Nebari Cloud
run: |
mkdir -p local-deployment
cd local-deployment
nebari init local --project=thisisatest --domain github-actions.nebari.dev --auth-provider=password
# Need smaller profiles on Local Kind
sed -i -E 's/(cpu_guarantee):\s+[0-9\.]+/\1: 0.25/g' "nebari-config.yaml"
sed -i -E 's/(mem_guarantee):\s+[A-Za-z0-9\.]+/\1: 0.25G/g' "nebari-config.yaml"
cat nebari-config.yaml
- name: Deploy Nebari
run: |
cd local-deployment
nebari deploy --config nebari-config.yaml --disable-prompt
- name: Basic kubectl checks after deployment
if: always()
run: |
kubectl get all,cm,secret,ing -A
- name: Check github-actions.nebari.dev resolves
run: |
nslookup github-actions.nebari.dev
- name: Curl jupyterhub login page
run: |
curl -k https://github-actions.nebari.dev/hub/home -i
### CYPRESS TESTS
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '16'
- name: npm version
run: |
npm --version
- name: Install Cypress dependencies
run: |
sudo apt-get -y update
sudo apt-get install -y libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb
- name: Get nebari-config.yaml full path
run: echo "NEBARI_CONFIG_PATH=`realpath ./local-deployment/nebari-config.yaml`" >> "$GITHUB_ENV"
- name: Create example-user
run: |
export CYPRESS_EXAMPLE_USER_NAME=example-user
export CYPRESS_EXAMPLE_USER_PASSWORD=P@sswo3d
echo "CYPRESS_EXAMPLE_USER_NAME=${CYPRESS_EXAMPLE_USER_NAME}" >> $GITHUB_ENV
echo "CYPRESS_EXAMPLE_USER_PASSWORD=${CYPRESS_EXAMPLE_USER_PASSWORD}" >> $GITHUB_ENV
nebari keycloak adduser --user "${CYPRESS_EXAMPLE_USER_NAME}" "${CYPRESS_EXAMPLE_USER_PASSWORD}" --config "${NEBARI_CONFIG_PATH}"
nebari keycloak listusers --config "${NEBARI_CONFIG_PATH}"
- name: Cypress run
uses: cypress-io/github-action@v4
env:
CYPRESS_BASE_URL: https://github-actions.nebari.dev/
with:
working-directory: tests_e2e
- name: Playwright Tests
env:
KEYCLOAK_USERNAME: ${{ env.CYPRESS_EXAMPLE_USER_NAME }}
KEYCLOAK_PASSWORD: ${{ env.CYPRESS_EXAMPLE_USER_PASSWORD }}
NEBARI_FULL_URL: https://github-actions.nebari.dev/
working-directory: tests_e2e/playwright
run: |
# create environment file
envsubst < .env.tpl > .env
# run playwright pytest tests in headed mode with the chromium browser
xvfb-run pytest --browser chromium
- name: Save Cypress screenshots and videos
if: always()
uses: actions/upload-artifact@v3
with:
name: e2e-cypress
path: |
./tests_e2e/cypress/screenshots/
./tests_e2e/cypress/videos/
./tests_e2e/playwright/videos/
- name: Deployment Pytests
run: |
export KEYCLOAK_USERNAME=${CYPRESS_EXAMPLE_USER_NAME}
export KEYCLOAK_PASSWORD=${CYPRESS_EXAMPLE_USER_PASSWORD}
pytest tests_deployment/ -v -s
- name: JupyterHub Notebook Tests
# run jhub-client after pytest since jhubctl can cleanup
# the running server
run: |
sleep 60
export JUPYTERHUB_USERNAME=${CYPRESS_EXAMPLE_USER_NAME}
export JUPYTERHUB_PASSWORD=${CYPRESS_EXAMPLE_USER_PASSWORD}
jhubctl --verbose run --hub=https://github-actions.nebari.dev \
--auth-type=keycloak \
--validate --no-verify-ssl \
--kernel python3 \
--stop-server \
--notebook tests_deployment/assets/notebook/simple.ipynb \
### CLEANUP AFTER TESTS
- name: Cleanup nebari deployment
run: |
cd local-deployment
nebari destroy --config nebari-config.yaml --disable-prompt