Skip to content

Commit 1337898

Browse files
committed
Run smallpt.ipynb and xeus-cpp-lite-demo.ipynb in ci and test output for Safari, Chrome and Firefox
1 parent d5de374 commit 1337898

File tree

5 files changed

+479
-10
lines changed

5 files changed

+479
-10
lines changed

.github/workflows/main.yml

Lines changed: 63 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,15 +195,14 @@ jobs:
195195
emscripten_wasm:
196196

197197
runs-on: ${{ matrix.os }}
198+
name: ${{ matrix.os}}-${{ matrix.notebook }}-${{ matrix.kernel }}
198199

199200
strategy:
200201
fail-fast: false
201202
matrix:
202-
include:
203-
- name: ubu24
204-
os: ubuntu-24.04
205-
- name: osx15-arm
206-
os: macos-15
203+
os: [ubuntu-24.04, macos-15]
204+
notebook: [smallpt.ipynb, xeus-cpp-lite-demo.ipynb]
205+
kernel: [C++17,C++20,C++23]
207206

208207
steps:
209208
- uses: actions/checkout@v5
@@ -329,12 +328,69 @@ jobs:
329328
fi
330329
timeout-minutes: 4
331330

332-
- name: Jupyter Lite integration
331+
- name: Jupyter Lite integration test
333332
shell: bash -l {0}
334333
run: |
334+
set -e
335335
micromamba create -n xeus-lite-host jupyterlite-core=0.6 jupyterlite-xeus -c conda-forge
336336
micromamba activate xeus-lite-host
337-
jupyter lite build --XeusAddon.prefix=${{ env.PREFIX }}
337+
if [[ "${{ matrix.os }}" == "macos"* ]]; then
338+
brew install coreutils
339+
export PATH="$HOMEBREW_PREFIX/opt/coreutils/libexec/gnubin:$PATH"
340+
fi
341+
export INPUT_TEXT=""
342+
if [[ "${{ matrix.notebook }}" == "xeus-cpp-lite-demo.ipynb"* ]]; then
343+
export INPUT_TEXT="--stdin Test_Name"
344+
fi
345+
timeout 900 jupyter lite serve --settings-overrides=overrides.json --XeusAddon.prefix=${{ env.PREFIX }} \
346+
--XeusAddon.mounts="${{ env.PREFIX }}/share/xeus-cpp/tagfiles:/share/xeus-cpp/tagfiles" \
347+
--XeusAddon.mounts="${{ env.PREFIX }}/etc/xeus-cpp/tags.d:/etc/xeus-cpp/tags.d" \
348+
--contents README.md \
349+
--contents notebooks/xeus-cpp-lite-demo.ipynb \
350+
--contents notebooks/smallpt.ipynb \
351+
--contents notebooks/images/marie.png \
352+
--contents notebooks/audio/audio.wav &
353+
# There is a bug in nbdime after 3.2.0 where it will show the filenames as if there was a diff
354+
# but there is no diff with the options chosen below (the latest doesn't show a diff, just the filenames with +++
355+
# and --- as if it was planning to show a diff. This only happens for xeus-cpp-lite-demo.ipynb.
356+
python -m pip install nbdime==3.2.0
357+
python -m pip install selenium
358+
# This sleep is to force enough time for the jupyter site to build before trying
359+
# to run notebooks in it. If you try to run the notebooks before the website is
360+
# ready the ci python script will crash saying ti cannot access the url
361+
sleep 10
362+
echo "Running xeus-cpp in Jupter Lite in Chrome"
363+
python -u scripts/automated-notebook-run-script.py --driver chrome --notebook ${{ matrix.notebook }} --kernel ${{ matrix.kernel }} $INPUT_TEXT
364+
nbdiff notebooks/${{ matrix.notebook }} $HOME/Downloads/${{ matrix.notebook }} --ignore-id --ignore-metadata >> chrome_diff.txt
365+
export CHROME_TESTS_RETURN_VALUE=$( [ -s chrome_diff.txt ] && echo 1 || echo 0 )
366+
echo "Running xeus-cpp in Jupter Lite in Firefox"
367+
python -u scripts/automated-notebook-run-script.py --driver firefox --notebook ${{ matrix.notebook }} --kernel ${{ matrix.kernel }} $INPUT_TEXT
368+
nbdiff notebooks/${{ matrix.notebook }} $HOME/Downloads/${{ matrix.notebook }} --ignore-id --ignore-metadata >> firefox_diff.txt
369+
export FIREFOX_TESTS_RETURN_VALUE=$( [ -s firefox_diff.txt ] && echo 1 || echo 0 )
370+
rm $HOME/Downloads/${{ matrix.notebook }}
371+
export SAFARI_TESTS_RETURN_VALUE=0
372+
touch safari_diff.txt
373+
if [[ "${{ matrix.os }}" == "macos"* ]]; then
374+
python -m pip install PyAutoGUI
375+
python scripts/enable-downloads-safari-github-ci.py
376+
echo "Running xeus-cpp in Jupter Lite in Safari"
377+
python -u scripts/automated-notebook-run-script.py --driver safari --notebook ${{ matrix.notebook }} --kernel ${{ matrix.kernel }} $INPUT_TEXT
378+
nbdiff notebooks/${{ matrix.notebook }} $HOME/Downloads/${{ matrix.notebook }} --ignore-id --ignore-metadata >> safari_diff.txt
379+
export SAFARI_TESTS_RETURN_VALUE=$( [ -s safari_diff.txt ] && echo 1 || echo 0 )
380+
rm $HOME/Downloads/${{ matrix.notebook }}
381+
fi
382+
if [[ $SAFARI_TESTS_RETURN_VALUE -ne 0 || $FIREFOX_TESTS_RETURN_VALUE -ne 0 || $CHROME_TESTS_RETURN_VALUE -ne 0 ]]; then
383+
if [[ "${{ matrix.os }}" == "macos"* ]]; then
384+
echo "Diff Safari (blank means no diff)"
385+
cat safari_diff.txt
386+
fi
387+
echo "Diff Firefox (blank means no diff)"
388+
cat firefox_diff.txt
389+
echo "Diff Chrome (blank means no diff)"
390+
cat chrome_diff.txt
391+
exit 1
392+
fi
393+
timeout-minutes: 15
338394

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

notebooks/xeus-cpp-lite-demo.ipynb

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -585,8 +585,14 @@
585585
"metadata": {
586586
"trusted": true
587587
},
588-
"outputs": [],
589-
"execution_count": null
588+
"outputs": [
589+
{
590+
"output_type": "stream",
591+
"name": "stdin",
592+
"text": " Test_Name\n"
593+
}
594+
],
595+
"execution_count": 29
590596
},
591597
{
592598
"id": "8ec65830-4cb5-4d01-a860-f6c46ac4f60f",
@@ -595,8 +601,24 @@
595601
"metadata": {
596602
"trusted": true
597603
},
604+
"outputs": [
605+
{
606+
"name": "stdout",
607+
"output_type": "stream",
608+
"text": "Your name is Test_Name"
609+
}
610+
],
611+
"execution_count": 30
612+
},
613+
{
614+
"id": "5d649107-9b69-42ad-b5ea-c50b3ee5add3",
615+
"cell_type": "code",
616+
"source": "",
617+
"metadata": {
618+
"trusted": true
619+
},
598620
"outputs": [],
599621
"execution_count": null
600622
}
601623
]
602-
}
624+
}

overrides.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"@jupyterlab/notebook-extension:panel": {
3+
"toolbar": [
4+
{
5+
"name": "download",
6+
"label": "Download",
7+
"args": {},
8+
"command": "docmanager:download",
9+
"icon": "ui-components:download",
10+
"rank": 50
11+
}
12+
]
13+
}
14+
}

0 commit comments

Comments
 (0)