Skip to content

Commit 0710b5b

Browse files
committed
Run smallpt.ipynb in ci and test output for Safari, Chrome and Firefox
1 parent 0d78cb1 commit 0710b5b

File tree

2 files changed

+45
-7
lines changed

2 files changed

+45
-7
lines changed

.github/workflows/main.yml

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,12 +329,42 @@ jobs:
329329
fi
330330
timeout-minutes: 4
331331

332-
- name: Jupyter Lite integration
332+
- name: Jupyter Lite integration test
333333
shell: bash -l {0}
334334
run: |
335+
set -e
335336
micromamba create -n xeus-lite-host jupyterlite-core=0.6 jupyterlite-xeus -c conda-forge
336337
micromamba activate xeus-lite-host
337-
jupyter lite build --XeusAddon.prefix=${{ env.PREFIX }}
338+
if [[ "${{ matrix.os }}" == "macos"* ]]; then
339+
brew install coreutils
340+
export PATH="$HOMEBREW_PREFIX/opt/coreutils/libexec/gnubin:$PATH"
341+
fi
342+
timeout 1500 jupyter lite serve --settings-overrides=overrides.json --XeusAddon.prefix=${{ env.PREFIX }} \
343+
--XeusAddon.mounts="${{ env.PREFIX }}/share/xeus-cpp/tagfiles:/share/xeus-cpp/tagfiles" \
344+
--XeusAddon.mounts="${{ env.PREFIX }}/etc/xeus-cpp/tags.d:/etc/xeus-cpp/tags.d" \
345+
--contents README.md \
346+
--contents notebooks/xeus-cpp-lite-demo.ipynb \
347+
--contents notebooks/smallpt.ipynb \
348+
--contents notebooks/images/marie.png \
349+
--contents notebooks/audio/audio.wav &
350+
python -m pip install nbdime
351+
python -m pip install selenium
352+
# This sleep is to force enough time for the jupyter site to build before trying
353+
# to run notebooks in it. If you try to run the notebooks before the website is
354+
# ready the ci python script will crash saying ti cannot access the url
355+
sleep 10
356+
python scripts/automated-notebook-run-script.py --driver chrome
357+
nbdiff notebooks/smallpt.ipynb $HOME/Downloads/smallpt.ipynb
358+
rm $HOME/Downloads/smallpt.ipynb
359+
python scripts/automated-notebook-run-script.py --driver firefox
360+
nbdiff notebooks/smallpt.ipynb $HOME/Downloads/smallpt.ipynb
361+
rm $HOME/Downloads/smallpt.ipynb
362+
if [[ "${{ matrix.os }}" == "macos"* ]]; then
363+
python scripts/automated-notebook-run-script.py --driver safari
364+
nbdiff notebooks/smallpt.ipynb $HOME/Downloads/smallpt.ipynb
365+
rm $HOME/Downloads/smallpt.ipynb
366+
fi
367+
timeout-minutes: 25
338368

339369
- name: Setup tmate session
340370
if: ${{ failure() && runner.debug }}

scripts/automated-notebook-run-script.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import argparse
22
from selenium import webdriver
3+
from selenium.webdriver.chrome.options import Options as ChromeOptions
4+
from selenium.webdriver.firefox.options import Options as FirefoxOptions
35
from selenium.webdriver.support.ui import WebDriverWait
46
from selenium.webdriver.support import expected_conditions as EC
57
from selenium.webdriver.common.action_chains import ActionChains
@@ -24,10 +26,15 @@ def main():
2426
# This will start the right driver depending on what
2527
# driver option is chosen
2628
if args.driver == "chrome":
27-
driver = webdriver.Chrome()
29+
options = ChromeOptions()
30+
options.add_argument("--headless")
31+
options.add_argument("--no-sandbox")
32+
driver = webdriver.Chrome(options=options)
2833

2934
elif args.driver == "firefox":
30-
driver = webdriver.Firefox()
35+
options = FirefoxOptions()
36+
options.add_argument("--headless")
37+
driver = webdriver.Firefox(options=options)
3138

3239
elif args.driver == "safari":
3340
driver = webdriver.Safari()
@@ -63,7 +70,7 @@ def main():
6370
)
6471
)
6572
actions.move_to_element(run_all_menu).click().perform()
66-
time.sleep(100)
73+
time.sleep(300)
6774

6875
elif args.driver == "firefox":
6976
print("Opening Run Menu")
@@ -79,7 +86,7 @@ def main():
7986
)
8087
)
8188
actions.move_to_element(run_all_menu).click().perform()
82-
time.sleep(100)
89+
time.sleep(200)
8390

8491
elif args.driver == "safari":
8592
print("Running all cells using Shift+Enter...")
@@ -102,7 +109,7 @@ def main():
102109
notebook_area.send_keys(Keys.SHIFT, Keys.ENTER)
103110
time.sleep(0.5)
104111

105-
time.sleep(145)
112+
time.sleep(650)
106113

107114
if args.driver == "chrome" or args.driver == "firefox":
108115
print("Saving notebook")
@@ -163,6 +170,7 @@ def main():
163170

164171
download_button = driver.execute_script(search_script)
165172

173+
time.sleep(2)
166174
driver.execute_script(
167175
"""
168176
const el = arguments[0];

0 commit comments

Comments
 (0)