Skip to content

Commit 9ade43d

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

File tree

2 files changed

+57
-12
lines changed

2 files changed

+57
-12
lines changed

.github/workflows/main.yml

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ jobs:
202202
include:
203203
- name: ubu24
204204
os: ubuntu-24.04
205-
- name: osx15-arm
206-
os: macos-15
205+
- name: osx26-arm
206+
os: macos-26
207207

208208
steps:
209209
- uses: actions/checkout@v5
@@ -329,12 +329,44 @@ 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 1400 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+
defaults write com.apple.Safari AskBeforeDownloading -bool false
364+
python scripts/automated-notebook-run-script.py --driver safari
365+
find $HOME -name "*smallpt*"
366+
nbdiff notebooks/smallpt.ipynb $HOME/Downloads/smallpt.ipynb
367+
rm $HOME/Downloads/smallpt.ipynb
368+
fi
369+
timeout-minutes: 25
338370

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

scripts/automated-notebook-run-script.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
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
68
from selenium.webdriver.common.by import By
79
from selenium.webdriver.common.keys import Keys
810
import time
9-
11+
import subprocess
1012

1113
def main():
1214
parser = argparse.ArgumentParser(description="Run Selenium with a chosen driver")
@@ -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(600)
106113

107114
if args.driver == "chrome" or args.driver == "firefox":
108115
print("Saving notebook")
@@ -161,8 +168,13 @@ def main():
161168
return deepQuerySelector(document, "jp-button[data-command='docmanager:download']");
162169
"""
163170

164-
download_button = driver.execute_script(search_script)
171+
download_button = WebDriverWait(driver, 20).until(
172+
lambda d: d.execute_script(search_script)
173+
)
174+
175+
print("Found element:", download_button)
165176

177+
time.sleep(20)
166178
driver.execute_script(
167179
"""
168180
const el = arguments[0];
@@ -182,7 +194,8 @@ def main():
182194
""",
183195
download_button,
184196
)
185-
time.sleep(2)
197+
198+
time.sleep(20)
186199

187200
# Close browser
188201
driver.quit()

0 commit comments

Comments
 (0)