Skip to content

Commit 2d03f19

Browse files
authored
add test workflow for upgrade (#2780)
2 parents 9b1310b + f871c31 commit 2d03f19

File tree

5 files changed

+234
-70
lines changed

5 files changed

+234
-70
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: health-check
2+
description: "Check health of Nebari deployment"
3+
4+
inputs:
5+
domain:
6+
description: Domain name
7+
required: true
8+
9+
runs:
10+
using: composite
11+
12+
steps:
13+
- name: List kubernetes components
14+
shell: bash
15+
run: kubectl get --all-namespaces all,cm,secret,pv,pvc,ing
16+
17+
- name: Check if JupyterHub login page is accessible
18+
shell: bash
19+
run: curl --insecure --include 'https://${{ inputs.domain }}/hub/home'
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: init-local
2+
description: "Initialize Nebari config for local deployment"
3+
4+
inputs:
5+
directory:
6+
description: "Path to directory to initialize in"
7+
required: false
8+
default: './local-deployment'
9+
10+
outputs:
11+
directory:
12+
description: "Path to config directory"
13+
value: ${{ steps.metadata.outputs.directory }}
14+
config:
15+
description: "Path to Nebari config"
16+
value: ${{ steps.metadata.outputs.config }}
17+
project:
18+
description: "Project name"
19+
value: ${{ steps.metadata.outputs.project }}
20+
domain:
21+
description: "Domain name"
22+
value: ${{ steps.metadata.outputs.domain }}
23+
24+
runs:
25+
using: composite
26+
27+
steps:
28+
- shell: bash
29+
id: metadata
30+
run: |
31+
# Setup metadata
32+
DIRECTORY=$(realpath '${{ inputs.directory }}')
33+
mkdir --parents "${DIRECTORY}"
34+
echo "directory=${DIRECTORY}" | tee --append "${GITHUB_OUTPUT}"
35+
36+
CONFIG="${DIRECTORY}/nebari-config.yaml"
37+
echo "config=${CONFIG}" | tee --append "${GITHUB_OUTPUT}"
38+
39+
PROJECT='github-actions'
40+
echo "project=${PROJECT}" | tee --append "${GITHUB_OUTPUT}"
41+
42+
DOMAIN='github-actions.nebari.dev'
43+
nslookup "${DOMAIN}"
44+
echo "domain=${DOMAIN}" | tee --append "${GITHUB_OUTPUT}"
45+
46+
- shell: bash -l {0}
47+
id: init
48+
working-directory: ${{ steps.metadata.outputs.directory }}
49+
run: |
50+
nebari init local \
51+
--project-name '${{ steps.metadata.outputs.project }}' \
52+
--domain-name '${{ steps.metadata.outputs.domain }}' \
53+
--auth-provider password \
54+
--output '${{ steps.metadata.outputs.config }}'
55+
56+
- shell: bash
57+
run: |
58+
# Update nebari config for CI
59+
60+
# Change default JupyterLab theme
61+
cat >> '${{ steps.metadata.outputs.config }}' <<- EOM
62+
jupyterlab:
63+
default_settings:
64+
"@jupyterlab/apputils-extension:themes":
65+
theme: JupyterLab Dark
66+
EOM
67+
68+
# Change default value for minio persistence size
69+
cat >> '${{ steps.metadata.outputs.config }}' <<- EOM
70+
monitoring:
71+
enabled: true
72+
overrides:
73+
minio:
74+
persistence:
75+
size: 1Gi
76+
EOM
77+
78+
- shell: bash
79+
run: |
80+
# Display Nebari config
81+
cat '${{ steps.metadata.outputs.config }}'
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: setup-local
2+
description: "Setup runner for local deployment"
3+
4+
inputs:
5+
kubectl-version:
6+
description: "Version of kubectl to install"
7+
required: false
8+
default: "1.19.16"
9+
10+
runs:
11+
using: composite
12+
13+
steps:
14+
- uses: azure/setup-kubectl@v4
15+
with:
16+
version: v${{ inputs.kubectl-version }}
17+
18+
- shell: bash
19+
run: |
20+
# Enable docker permissions for user
21+
sudo docker ps
22+
sudo usermod -aG docker $USER && newgrp docker
23+
24+
docker info
25+
docker ps
26+
27+
- shell: bash
28+
run: |
29+
# Get routing table for docker pods
30+
ip route

.github/workflows/test_local_integration.yaml

Lines changed: 19 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ jobs:
5353
with:
5454
fetch-depth: 0
5555

56+
- name: Setup runner for local deployment
57+
uses: ./.github/actions/setup-local
58+
5659
- name: Checkout the branch from the PR that triggered the job
5760
if: ${{ github.event_name == 'issue_comment' }}
5861
run: |
@@ -75,82 +78,29 @@ jobs:
7578
pip install .[dev]
7679
playwright install
7780
78-
- uses: azure/[email protected]
79-
with:
80-
version: v1.19.16
81-
82-
- name: Enable docker permissions for user
83-
run: |
84-
sudo docker ps
85-
sudo usermod -aG docker $USER && newgrp docker
86-
87-
docker info
88-
docker ps
89-
90-
- name: Get routing table for docker pods
91-
run: |
92-
ip route
93-
94-
- name: Initialize Nebari Cloud
95-
run: |
96-
mkdir -p local-deployment
97-
cd local-deployment
98-
nebari init local --project=thisisatest --domain github-actions.nebari.dev --auth-provider=password
99-
100-
# Need smaller profiles on Local Kind
101-
sed -i -E 's/(cpu_guarantee):\s+[0-9\.]+/\1: 0.25/g' "nebari-config.yaml"
102-
sed -i -E 's/(mem_guarantee):\s+[A-Za-z0-9\.]+/\1: 0.25G/g' "nebari-config.yaml"
103-
104-
# Change default JupyterLab theme
105-
cat >> nebari-config.yaml <<- EOM
106-
jupyterlab:
107-
default_settings:
108-
"@jupyterlab/apputils-extension:themes":
109-
theme: JupyterLab Dark
110-
EOM
111-
112-
# Change default value for minio persistence size
113-
cat >> nebari-config.yaml <<- EOM
114-
monitoring:
115-
enabled: true
116-
overrides:
117-
minio:
118-
persistence:
119-
size: 1Gi
120-
EOM
121-
122-
cat nebari-config.yaml
81+
- name: Initialize Nebari config for local deployment
82+
id: init
83+
uses: ./.github/actions/init-local
12384

12485
- name: Deploy Nebari
125-
working-directory: local-deployment
126-
run: |
127-
nebari deploy --config nebari-config.yaml --disable-prompt
86+
working-directory: ${{ steps.init.outputs.directory }}
87+
run: nebari deploy --config ${{ steps.init.outputs.config }} --disable-prompt
12888

129-
- name: Basic kubectl checks after deployment
130-
if: always()
131-
run: |
132-
kubectl get all,cm,secret,pv,pvc,ing -A
133-
134-
- name: Check github-actions.nebari.dev resolves
135-
run: |
136-
nslookup github-actions.nebari.dev
137-
138-
- name: Curl jupyterhub login page
139-
run: |
140-
curl -k https://github-actions.nebari.dev/hub/home -i
89+
- name: Health check
90+
uses: ./.github/actions/health-check
91+
with:
92+
domain: ${{ steps.init.outputs.domain }}
14193

14294
- name: Create example-user
143-
working-directory: local-deployment
95+
working-directory: ${{ steps.init.outputs.directory }}
14496
run: |
145-
nebari keycloak adduser --user "${TEST_USERNAME}" "${TEST_PASSWORD}" --config nebari-config.yaml
146-
nebari keycloak listusers --config nebari-config.yaml
147-
148-
- name: Get nebari-config.yaml full path
149-
run: echo "NEBARI_CONFIG_PATH=`realpath ./local-deployment/nebari-config.yaml`" >> "$GITHUB_ENV"
97+
nebari keycloak adduser --user "${TEST_USERNAME}" "${TEST_PASSWORD}" --config ${{ steps.init.outputs.config }}
98+
nebari keycloak listusers --config ${{ steps.init.outputs.config }}
15099
151100
### DEPLOYMENT TESTS
152101
- name: Deployment Pytests
153102
env:
103+
NEBARI_CONFIG_PATH: ${{ steps.init.outputs.config }}
154104
KEYCLOAK_USERNAME: ${{ env.TEST_USERNAME }}
155105
KEYCLOAK_PASSWORD: ${{ env.TEST_PASSWORD }}
156106
run: |
@@ -165,7 +115,7 @@ jobs:
165115
env:
166116
KEYCLOAK_USERNAME: ${{ env.TEST_USERNAME }}
167117
KEYCLOAK_PASSWORD: ${{ env.TEST_PASSWORD }}
168-
NEBARI_FULL_URL: https://github-actions.nebari.dev/
118+
NEBARI_FULL_URL: "https://${{ steps.init.outputs.domain }}/"
169119
working-directory: tests/tests_e2e/playwright
170120
run: |
171121
# create environment file
@@ -187,6 +137,5 @@ jobs:
187137
# in the CI, it makes sense to only run on merge to main or workflow_dispatch to speed
188138
# up feedback cycle
189139
if: github.ref_name == 'main' || github.event_name == 'workflow_dispatch'
190-
working-directory: local-deployment
191-
run: |
192-
nebari destroy --config nebari-config.yaml --disable-prompt
140+
working-directory: ${{ steps.init.outputs.directory }}
141+
run: nebari destroy --config ${{ steps.init.outputs.config }} --disable-prompt
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: "Local Upgrade Tests"
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- ".github/actions/**"
7+
- ".github/workflows/test_local_upgrade.yaml"
8+
release:
9+
types:
10+
- prereleased
11+
workflow_dispatch:
12+
13+
14+
concurrency:
15+
group: ${{ github.ref_name }}
16+
cancel-in-progress: true
17+
18+
env:
19+
NEBARI_IMAGE_TAG: "main"
20+
21+
jobs:
22+
test-local-upgrade:
23+
runs-on: "cirun-runner--${{ github.run_id }}"
24+
defaults:
25+
run:
26+
shell: bash -l {0}
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0
32+
33+
- name: Setup runner for local deployment
34+
uses: ./.github/actions/setup-local
35+
36+
- name: Setup Python
37+
uses: conda-incubator/setup-miniconda@v3
38+
env:
39+
CONDA: /home/runnerx/miniconda3
40+
with:
41+
auto-update-conda: true
42+
python-version: "3.11"
43+
miniconda-version: "latest"
44+
45+
- name: Install latest stable Nebari release
46+
run: pip install nebari
47+
48+
- name: Initialize Nebari config for local deployment
49+
id: init
50+
uses: ./.github/actions/init-local
51+
52+
- name: Extract old Nebari version
53+
run: |
54+
OLD_NEBARI_VERSION=$(grep 'nebari_version: ' ${{ steps.init.outputs.config }} | sed 's/nebari_version: //')
55+
echo "OLD_NEBARI_VERSION=${OLD_NEBARI_VERSION}" | tee --append "${GITHUB_ENV}"
56+
57+
- name: Deploy Nebari
58+
working-directory: ${{ steps.init.outputs.directory }}
59+
run: nebari deploy --config ${{ steps.init.outputs.config }} --disable-prompt
60+
61+
- name: Health check before upgrade
62+
id: health-check-before
63+
uses: ./.github/actions/health-check
64+
with:
65+
domain: ${{ steps.init.outputs.domain }}
66+
67+
- name: Install current Nebari
68+
run: pip install --upgrade .
69+
70+
- name: Upgrade Nebari config
71+
run: |
72+
git add --force ${{ steps.init.outputs.config }}
73+
nebari upgrade --config ${{ steps.init.outputs.config }} --attempt-fixes
74+
git diff
75+
nebari validate --config ${{ steps.init.outputs.config }}
76+
77+
- name: Redeploy Nebari
78+
working-directory: ${{ steps.init.outputs.directory }}
79+
run: nebari deploy --config ${{ steps.init.outputs.config }} --disable-prompt
80+
81+
- name: Health check after upgrade
82+
id: health-check-after
83+
uses: ./.github/actions/health-check
84+
with:
85+
domain: ${{ steps.init.outputs.domain }}

0 commit comments

Comments
 (0)