-
Notifications
You must be signed in to change notification settings - Fork 36
Run Emscripten tests in a browser #294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,7 @@ jobs: | |
pushd build | ||
|
||
export BUILD_PREFIX=$MAMBA_ROOT_PREFIX/envs/xeus-cpp-wasm-build | ||
echo "BUILD_PREFIX=$BUILD_PREFIX" >> $GITHUB_ENV | ||
export PREFIX=$MAMBA_ROOT_PREFIX/envs/xeus-cpp-wasm-host | ||
echo "PREFIX=$PREFIX" >> $GITHUB_ENV | ||
export SYSROOT_PATH=$BUILD_PREFIX/opt/emsdk/upstream/emscripten/cache/sysroot | ||
|
@@ -64,6 +65,60 @@ jobs: | |
.. | ||
emmake make -j ${{ env.ncpus }} install | ||
|
||
- name: Test xeus-cpp C++ Emscripten | ||
shell: bash -l {0} | ||
run: | | ||
set -e | ||
micromamba create -n xeus-lite-host jupyterlite-core | ||
micromamba activate xeus-lite-host | ||
cd build/test | ||
os="${{ matrix.os }}" | ||
if [[ "${os}" == "macos"* ]]; then | ||
# Install Firefox | ||
wget "https://download.mozilla.org/?product=firefox-latest&os=osx&lang=en-US" -O Firefox-latest.dmg | ||
hdiutil attach Firefox-latest.dmg | ||
cp -r /Volumes/Firefox/Firefox.app $PWD | ||
hdiutil detach /Volumes/Firefox | ||
cd ./Firefox.app/Contents/MacOS/ | ||
export PATH="$PWD:$PATH" | ||
cd – | ||
|
||
# Install Google Chrome | ||
wget https://dl.google.com/chrome/mac/stable/accept_tos%3Dhttps%253A%252F%252Fwww.google.com%252Fintl%252Fen_ph%252Fchrome%252Fterms%252F%26_and_accept_tos%3Dhttps%253A%252F%252Fpolicies.google.com%252Fterms/googlechrome.pkg | ||
pkgutil --expand-full googlechrome.pkg google-chrome | ||
cd ./google-chrome/GoogleChrome.pkg/Payload/Google\ Chrome.app/Contents/MacOS/ | ||
export PATH="$PWD:$PATH" | ||
cd – | ||
|
||
# Run tests in browsers | ||
echo "Running test_xeus_cpp in Firefox" | ||
python ${{ env.BUILD_PREFIX }}/bin/emrun.py --browser="firefox" --kill_exit --browser-args="--headless" test_xeus_cpp.html | ||
echo "Running test_xeus_cpp in Google Chrome" | ||
python ${{ env.BUILD_PREFIX }}/bin/emrun.py --browser="Google Chrome" --kill_exit --browser-args="--headless" test_xeus_cpp.html | ||
else | ||
# Install Google Chrome | ||
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb | ||
dpkg-deb -x google-chrome-stable_current_amd64.deb $PWD/chrome | ||
cd ./chrome/opt/google/chrome/ | ||
export PATH="$PWD:$PATH" | ||
cd - | ||
|
||
# Install Firefox | ||
wget https://ftp.mozilla.org/pub/firefox/releases/138.0.1/linux-x86_64/en-GB/firefox-138.0.1.tar.xz | ||
tar -xJf firefox-138.0.1.tar.xz | ||
cd ./firefox | ||
export PATH="$PWD:$PATH" | ||
cd - | ||
|
||
# Run tests in browsers | ||
echo "Running test_xeus_cpp in Firefox" | ||
python ${{ env.BUILD_PREFIX }}/bin/emrun.py --browser="firefox" --kill_exit --timeout 60 --browser-args="--headless" test_xeus_cpp.html | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given emrun is not on our PATH, I have to reference the exact path to emrun.py . I could add
|
||
echo "Running test_xeus_cpp in Google Chrome" | ||
python ${{ env.BUILD_PREFIX }}/bin/emrun.py --browser="google-chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" test_xeus_cpp.html | ||
fi | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the case of Chrome we have the extra |
||
node test_xeus_cpp.js | ||
timeout-minutes: 4 | ||
|
||
- name: Jupyter Lite integration | ||
shell: bash -l {0} | ||
run: | | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,7 +56,9 @@ if(EMSCRIPTEN) | |
target_compile_options(test_xeus_cpp | ||
PUBLIC "SHELL: -fexceptions" | ||
) | ||
|
||
set_target_properties(test_xeus_cpp PROPERTIES | ||
SUFFIX ".html" | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So that we create a html file, as well as the javascript file. |
||
target_link_options(test_xeus_cpp | ||
PUBLIC "SHELL: -fexceptions" | ||
PUBLIC "SHELL: -s MAIN_MODULE=1" | ||
|
@@ -69,6 +71,8 @@ if(EMSCRIPTEN) | |
PUBLIC "SHELL: --preload-file ${SYSROOT_PATH}/include@/include" | ||
PUBLIC "SHELL: --preload-file ../${XEUS_CPP_DATA_DIR}@/share/xeus-cpp" | ||
PUBLIC "SHELL: --preload-file ../${XEUS_CPP_CONF_DIR}@/etc/xeus-cpp" | ||
PUBLIC "SHELL: --emrun" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The above is taken from emruns documentation https://emscripten.org/docs/compiling/Running-html-files-with-emrun.html |
||
PUBLIC "SHELL: -s MINIFY_HTML=0" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Without this MINIFY_HTML=0 flag you end up with the situation where the creation of the test_xeus_cpp.html file breaks on MacOS, but not Ubuntu as can be seen here https://github.com/compiler-research/xeus-cpp/actions/runs/14780201517 |
||
) | ||
|
||
target_include_directories(test_xeus_cpp PRIVATE ${XEUS_CPP_INCLUDE_DIR}) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason we install a fresh install of Firefox and Chome is to follow what is done in the Emscripten repo (for example here with Firefox https://github.com/emscripten-core/emscripten/blob/38e16464cffc8f886364fe4919a712131a4c9456/.circleci/config.yml#L363 ). It has the added advantage by not using the users installed versions of these browsers (if they have them installed), that there are no add ons, etc that could be causing issues with the tests running. I have made the instructions, such that a developer without admin privileges on there machine can install them.