Skip to content

Commit c5c521a

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

File tree

12 files changed

+703
-24
lines changed

12 files changed

+703
-24
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: 'Run kernel in notebook within Jupyter Lite'
2+
description: 'This action runs the chosen kernel in notebook within Jupyter Lite'
3+
4+
inputs:
5+
notebook:
6+
description: "The notebook to run the kernel in"
7+
required: true
8+
type: string
9+
kernel:
10+
description: "The kernel to use"
11+
required: true
12+
type: string
13+
14+
runs:
15+
using: composite
16+
steps:
17+
- name: Jupyter Lite integration test
18+
shell: bash -l {0}
19+
run: |
20+
set -e
21+
micromamba activate xeus-lite-host
22+
export INPUT_TEXT=""
23+
if [[ "${{ inputs.notebook }}" == "xeus-cpp-lite-demo.ipynb"* ]]; then
24+
export INPUT_TEXT="--stdin Smudge"
25+
fi
26+
echo "Running xeus-cpp in Jupter Lite in Chrome"
27+
python -u scripts/automated-notebook-run-script.py --driver chrome --notebook ${{ inputs.notebook }} --kernel ${{ inputs.kernel }} $INPUT_TEXT
28+
nbdiff notebooks/${{ inputs.notebook }} $HOME/Downloads/${{ inputs.notebook }} --ignore-id --ignore-metadata >> chrome_diff.txt
29+
export CHROME_TESTS_RETURN_VALUE=$( [ -s chrome_diff.txt ] && echo 1 || echo 0 )
30+
rm $HOME/Downloads/${{ inputs.notebook }}
31+
echo "Running xeus-cpp in Jupter Lite in Firefox"
32+
python -u scripts/automated-notebook-run-script.py --driver firefox --notebook ${{ inputs.notebook }} --kernel ${{ inputs.kernel }} $INPUT_TEXT
33+
nbdiff notebooks/${{ inputs.notebook }} $HOME/Downloads/${{ inputs.notebook }} --ignore-id --ignore-metadata >> firefox_diff.txt
34+
export FIREFOX_TESTS_RETURN_VALUE=$( [ -s firefox_diff.txt ] && echo 1 || echo 0 )
35+
rm $HOME/Downloads/${{ inputs.notebook }}
36+
export SAFARI_TESTS_RETURN_VALUE=0
37+
touch safari_diff.txt
38+
if [[ "${{ matrix.os }}" == "macos"* ]]; then
39+
echo "Running xeus-cpp in Jupter Lite in Safari"
40+
python -u scripts/automated-notebook-run-script.py --driver safari --notebook ${{ inputs.notebook }} --kernel ${{ inputs.kernel }} $INPUT_TEXT
41+
nbdiff notebooks/${{ inputs.notebook }} $HOME/Downloads/${{ inputs.notebook }} --ignore-id --ignore-metadata >> safari_diff.txt
42+
export SAFARI_TESTS_RETURN_VALUE=$( [ -s safari_diff.txt ] && echo 1 || echo 0 )
43+
rm $HOME/Downloads/${{ inputs.notebook }}
44+
fi
45+
if [[ $SAFARI_TESTS_RETURN_VALUE -ne 0 || $FIREFOX_TESTS_RETURN_VALUE -ne 0 || $CHROME_TESTS_RETURN_VALUE -ne 0 ]]; then
46+
if [[ "${{ matrix.os }}" == "macos"* ]]; then
47+
echo "Diff Safari (blank means no diff)"
48+
cat safari_diff.txt
49+
fi
50+
echo "Diff Firefox (blank means no diff)"
51+
cat firefox_diff.txt
52+
echo "Diff Chrome (blank means no diff)"
53+
cat chrome_diff.txt
54+
exit 1
55+
fi
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: 'This sets up our Jupyter Lite website, so we can run xeus-cpp in it'
2+
description: 'This action sets up our Jupyter Lite website, so we can run xeus-cpp in it'
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- name: Jupyter Lite integration test
8+
shell: bash -l {0}
9+
run: |
10+
set -e
11+
micromamba create -n xeus-lite-host jupyter_server jupyterlite-xeus -c conda-forge
12+
micromamba activate xeus-lite-host
13+
if [[ "${{ matrix.os }}" == "macos"* ]]; then
14+
brew install coreutils
15+
export PATH="$HOMEBREW_PREFIX/opt/coreutils/libexec/gnubin:$PATH"
16+
fi
17+
timeout 900 jupyter lite serve --settings-overrides=overrides.json \
18+
--XeusAddon.prefix=${{ env.PREFIX }} \
19+
--XeusAddon.mounts="${{ env.PREFIX }}/share/xeus-cpp/tagfiles:/share/xeus-cpp/tagfiles" \
20+
--XeusAddon.mounts="${{ env.PREFIX }}/etc/xeus-cpp/tags.d:/etc/xeus-cpp/tags.d" \
21+
--contents README.md \
22+
--contents notebooks/xeus-cpp-lite-demo.ipynb \
23+
--contents notebooks/tinyraytracer.ipynb \
24+
--contents notebooks/images/marie.png \
25+
--contents notebooks/audio/audio.wav \
26+
--output-dir dist &
27+
# There is a bug in nbdime after 3.2.0 where it will show the filenames as if there was a diff
28+
# but there is no diff with the options chosen below (the latest doesn't show a diff, just the filenames with +++
29+
# and --- as if it was planning to show a diff. This only happens for xeus-cpp-lite-demo.ipynb.
30+
python -m pip install nbdime==3.2.0
31+
if [[ "${{ matrix.os }}" == "macos"* ]]; then
32+
python -m pip install PyAutoGUI
33+
python scripts/enable-downloads-safari-github-ci.py
34+
fi
35+
python -m pip install selenium
36+
# This sleep is to force enough time for the jupyter site to build before trying
37+
# to run notebooks in it. If you try to run the notebooks before the website is
38+
# ready the ci python script will crash saying ti cannot access the url
39+
sleep 10

.github/workflows/deploy-github-page.yml

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -139,21 +139,50 @@ jobs:
139139
fi
140140
timeout-minutes: 4
141141

142-
- name: Jupyter Lite integration
143-
shell: bash -l {0}
144-
run: |
145-
micromamba create -n xeus-lite-host jupyter_server jupyterlite-xeus -c conda-forge
146-
micromamba activate xeus-lite-host
147-
jupyter lite build \
148-
--XeusAddon.prefix=${{ env.PREFIX }} \
149-
--XeusAddon.mounts="${{ env.PREFIX }}/share/xeus-cpp/tagfiles:/share/xeus-cpp/tagfiles" \
150-
--XeusAddon.mounts="${{ env.PREFIX }}/etc/xeus-cpp/tags.d:/etc/xeus-cpp/tags.d" \
151-
--contents README.md \
152-
--contents notebooks/xeus-cpp-lite-demo.ipynb \
153-
--contents notebooks/tinyraytracer.ipynb \
154-
--contents notebooks/images/marie.png \
155-
--contents notebooks/audio/audio.wav \
156-
--output-dir dist
142+
- name: Serve Jupyter Lite website
143+
uses: ./.github/actions/Jupyter-serve
144+
145+
- name: Test C++17 kernel in xeus-cpp-lite-demo.ipynb
146+
uses: ./.github/actions/Emscripten-Notebook-Tests
147+
with:
148+
notebook: "xeus-cpp-lite-demo.ipynb"
149+
kernel: "C++17"
150+
timeout-minutes: 5
151+
152+
- name: Test C++20 kernel in xeus-cpp-lite-demo.ipynb
153+
uses: ./.github/actions/Emscripten-Notebook-Tests
154+
with:
155+
notebook: "xeus-cpp-lite-demo.ipynb"
156+
kernel: "C++20"
157+
timeout-minutes: 5
158+
159+
- name: Test C++23 kernel in xeus-cpp-lite-demo.ipynb
160+
uses: ./.github/actions/Emscripten-Notebook-Tests
161+
with:
162+
notebook: "xeus-cpp-lite-demo.ipynb"
163+
kernel: "C++23"
164+
timeout-minutes: 5
165+
166+
- name: Test C++17 kernel in tinyraytracer.ipynb
167+
uses: ./.github/actions/Emscripten-Notebook-Tests
168+
with:
169+
notebook: "tinyraytracer.ipynb"
170+
kernel: "C++17"
171+
timeout-minutes: 5
172+
173+
- name: Test C++20 kernel in tinyraytracer.ipynb
174+
uses: ./.github/actions/Emscripten-Notebook-Tests
175+
with:
176+
notebook: "tinyraytracer.ipynb"
177+
kernel: "C++20"
178+
timeout-minutes: 5
179+
180+
- name: Test C++23 kernel in tinyraytracer.ipynb
181+
uses: ./.github/actions/Emscripten-Notebook-Tests
182+
with:
183+
notebook: "tinyraytracer.ipynb"
184+
kernel: "C++23"
185+
timeout-minutes: 5
157186

158187
- name: Upload artifact
159188
uses: actions/upload-pages-artifact@v3

.github/workflows/main.yml

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

332-
- name: Jupyter Lite integration
333-
shell: bash -l {0}
334-
run: |
335-
micromamba create -n xeus-lite-host jupyterlite-xeus -c conda-forge
336-
micromamba activate xeus-lite-host
337-
jupyter lite build --XeusAddon.prefix=${{ env.PREFIX }}
332+
- name: Serve Jupyter Lite website
333+
uses: ./.github/actions/Jupyter-serve
334+
335+
- name: Test C++17 kernel in xeus-cpp-lite-demo.ipynb
336+
uses: ./.github/actions/Emscripten-Notebook-Tests
337+
with:
338+
notebook: "xeus-cpp-lite-demo.ipynb"
339+
kernel: "C++17"
340+
timeout-minutes: 5
341+
342+
- name: Test C++20 kernel in xeus-cpp-lite-demo.ipynb
343+
uses: ./.github/actions/Emscripten-Notebook-Tests
344+
with:
345+
notebook: "xeus-cpp-lite-demo.ipynb"
346+
kernel: "C++20"
347+
timeout-minutes: 5
348+
349+
- name: Test C++23 kernel in xeus-cpp-lite-demo.ipynb
350+
uses: ./.github/actions/Emscripten-Notebook-Tests
351+
with:
352+
notebook: "xeus-cpp-lite-demo.ipynb"
353+
kernel: "C++23"
354+
timeout-minutes: 5
355+
356+
- name: Test C++17 kernel in tinyraytracer.ipynb
357+
uses: ./.github/actions/Emscripten-Notebook-Tests
358+
with:
359+
notebook: "tinyraytracer.ipynb"
360+
kernel: "C++17"
361+
timeout-minutes: 5
362+
363+
- name: Test C++20 kernel in tinyraytracer.ipynb
364+
uses: ./.github/actions/Emscripten-Notebook-Tests
365+
with:
366+
notebook: "tinyraytracer.ipynb"
367+
kernel: "C++20"
368+
timeout-minutes: 5
369+
370+
- name: Test C++23 kernel in tinyraytracer.ipynb
371+
uses: ./.github/actions/Emscripten-Notebook-Tests
372+
with:
373+
notebook: "tinyraytracer.ipynb"
374+
kernel: "C++23"
375+
timeout-minutes: 5
338376

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

CONTRIBUTING.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,4 +165,43 @@ jupyter lite serve --XeusAddon.prefix=$PREFIX \
165165
--contents notebooks/tinyraytracer.ipynb \
166166
--contents notebooks/images/marie.png \
167167
--contents notebooks/audio/audio.wav
168+
169+
### xeus-cpp Jupyter Lite tests
170+
171+
It is possible to run test the xeus-cpp in Jupyter Lite deployment, using a Selenium based script and the nbdiff Jupyter tool.
172+
In order to install these dependencies execute the following (you will need the Jupyter Lite website running in the background when
173+
executing the python script)
174+
175+
```bash
176+
python -m pip install nbdime==3.2.0 selenium
177+
```
178+
179+
Then to run the by executing (--run-browser-gui option exists if you want Chrome or Firefox to show a gui browser as they run)
180+
181+
```bash
182+
python -u scripts/automated-notebook-run-script.py --driver browser --notebook notebook --kernel kernel --stdin Test_Input --timeout timeout
183+
```
184+
185+
For example
186+
187+
```bash
188+
python -u scripts/automated-notebook-run-script.py --driver chrome --notebook xeus-cpp-lite-demo.ipynb --kernel C++20 --stdin Smudge --timeout 200
189+
```
190+
191+
will run the xeus-cpp-lite-demo.ipynb notebook in chrome, with the C++20 kernel, enter Test_Name in the standard input box in this notebook,
192+
and stop the script, if the notebook has finished running after 200 seconds. This works for Safari, Chrome and Firefox. It should be noted
193+
that in the case of Safari, safari driver must be enabled, and downloads must be enabled from 127.0.0.1 . Once the script has finished
194+
executing you can compare the notebook download from the one in the repo, to check the deployment works as expected, by executing
195+
(replace notebook_run with the notebook chosen for the Python script)
196+
197+
```bash
198+
nbdiff notebook_run $HOME/Downlaods/notebook_run --ignore-id --ignore-metadata
199+
```
200+
201+
For example after running the above test command, to test no changes have occurred, execute
202+
203+
```bash
204+
nbdiff xeus-cpp-lite-demo.ipynb $HOME/Downlaods/xeus-cpp-lite-demo.ipynb --ignore-id --ignore-metadata
205+
```
206+
168207
```

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,44 @@ jupyter lite serve --XeusAddon.prefix=$PREFIX \
182182
--contents notebooks/audio/audio.wav
183183
```
184184

185+
### xeus-cpp Jupyter Lite tests
186+
187+
It is possible to run test the xeus-cpp in Jupyter Lite deployment, using a Selenium based script and the nbdiff Jupyter tool.
188+
In order to install these dependencies execute the following (you will need the Jupyter Lite website running in the background when
189+
executing the python script)
190+
191+
```bash
192+
python -m pip install nbdime==3.2.0 selenium
193+
```
194+
195+
Then to run the by executing (--run-browser-gui option exists if you want Chrome or Firefox to show a gui browser as they run)
196+
197+
```bash
198+
python -u scripts/automated-notebook-run-script.py --driver browser --notebook notebook --kernel kernel --stdin Test_Input --timeout timeout
199+
```
200+
201+
For example
202+
203+
```bash
204+
python -u scripts/automated-notebook-run-script.py --driver chrome --notebook xeus-cpp-lite-demo.ipynb --kernel C++20 --stdin Smudge --timeout 200
205+
```
206+
207+
will run the xeus-cpp-lite-demo.ipynb notebook in chrome, with the C++20 kernel, enter Test_Name in the standard input box in this notebook,
208+
and stop the script, if the notebook has finished running after 200 seconds. This works for Safari, Chrome and Firefox. It should be noted
209+
that in the case of Safari, safari driver must be enabled, and downloads must be enabled from 127.0.0.1 . Once the script has finished
210+
executing you can compare the notebook download from the one in the repo, to check the deployment works as expected, by executing
211+
(replace notebook_run with the notebook chosen for the Python script)
212+
213+
```bash
214+
nbdiff notebook_run $HOME/Downlaods/notebook_run --ignore-id --ignore-metadata
215+
```
216+
217+
For example after running the above test command, to test no changes have occurred, execute
218+
219+
```bash
220+
nbdiff xeus-cpp-lite-demo.ipynb $HOME/Downlaods/xeus-cpp-lite-demo.ipynb --ignore-id --ignore-metadata
221+
```
222+
185223
## Trying it online
186224

187225
To try out xeus-cpp interactively in your web browser, just click on the binder link:

docs/source/InstallationAndUsage.rst

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,46 @@ To build and test Jupyter Lite with this kernel locally you can execute the foll
163163
--contents notebooks/images/marie.png \
164164
--contents notebooks/audio/audio.wav
165165
166+
xeus-cpp Jupyter Lite tests
167+
========================
168+
169+
It is possible to run test the xeus-cpp in Jupyter Lite deployment, using a Selenium based script and the nbdiff Jupyter tool.
170+
In order to install these dependencies execute the following (you will need the Jupyter Lite website running in the background when
171+
executing the python script)
172+
173+
.. code-block:: bash
174+
175+
python -m pip install nbdime==3.2.0 selenium
176+
177+
Then to run the by executing (--run-browser-gui option exists if you want Chrome or Firefox to show a gui browser as they run)
178+
179+
.. code-block:: bash
180+
181+
python -u scripts/automated-notebook-run-script.py --driver browser --notebook notebook --kernel kernel --stdin Test_Input --timeout timeout
182+
183+
For example
184+
185+
.. code-block:: bash
186+
187+
python -u scripts/automated-notebook-run-script.py --driver chrome --notebook xeus-cpp-lite-demo.ipynb --kernel C++20 --stdin Smudge --timeout 200
188+
189+
will run the xeus-cpp-lite-demo.ipynb notebook in chrome, with the C++20 kernel, enter Test_Name in the standard input box in this notebook,
190+
and stop the script, if the notebook has finished running after 200 seconds. This works for Safari, Chrome and Firefox. It should be noted
191+
that in the case of Safari, safari driver must be enabled, and downloads must be enabled from 127.0.0.1 . Once the script has finished
192+
executing you can compare the notebook download from the one in the repo, to check the deployment works as expected, by executing
193+
(replace notebook_run with the notebook chosen for the Python script)
194+
195+
.. code-block:: bash
196+
197+
nbdiff notebook_run $HOME/Downlaods/notebook_run --ignore-id --ignore-metadata
198+
199+
200+
For example after running the above test command, to test no changes have occurred, execute
201+
202+
.. code-block:: bash
203+
204+
nbdiff xeus-cpp-lite-demo.ipynb $HOME/Downlaods/xeus-cpp-lite-demo.ipynb --ignore-id --ignore-metadata
205+
166206
Installing from conda-forge
167207
===========================
168208

docs/source/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
micromamba create -n xeus-lite-host jupyter_server jupyterlite-xeus -c conda-forge -y;
4141
micromamba activate xeus-lite-host;
4242
jupyter lite build --XeusAddon.prefix=$PREFIX \\
43+
--XeusAddon.prefix=$PREFIX \\
4344
--XeusAddon.mounts="$PREFIX/share/xeus-cpp/tagfiles:/share/xeus-cpp/tagfiles" \
4445
--XeusAddon.mounts="$PREFIX/etc/xeus-cpp/tags.d:/etc/xeus-cpp/tags.d" \
4546
--contents notebooks/xeus-cpp-lite-demo.ipynb \\

0 commit comments

Comments
 (0)