Skip to content

Commit a92a91c

Browse files
committed
Run smallpt.ipynb in ci and test output for Safari, Chrome and Firefox
1 parent 8719ca8 commit a92a91c

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
@@ -316,12 +316,42 @@ jobs:
316316
fi
317317
timeout-minutes: 4
318318

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

326356
- name: Setup tmate session
327357
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)