Skip to content

Remove restriction on number of processes for Emscripten static libra… #556

Remove restriction on number of processes for Emscripten static libra…

Remove restriction on number of processes for Emscripten static libra… #556

Workflow file for this run

name: Build and Deploy
on:
workflow_dispatch:
push:
branches:
- main
schedule:
- cron: '30 20 * * *' # Warning: Timezone dep - 20:00 is 1:00
permissions:
contents: read
pages: write
id-token: write
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- name: osx15-arm-clang-repl-20-emscripten_wasm
os: macos-15
clang-runtime: '20'
cling: Off
micromamba_shell_init: bash
emsdk_ver: "3.1.73"
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Save PR Info
uses: ./.github/actions/Miscellaneous/Save_PR_Info
- name: Setup default Build Type
uses: ./.github/actions/Miscellaneous/Select_Default_Build_Type
- name: install mamba
uses: mamba-org/setup-micromamba@main
with:
init-shell: >-
${{ matrix.micromamba_shell_init }}
- name: Setup emsdk
shell: bash -l {0}
run: |
git clone --depth=1 https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install ${{ matrix.emsdk_ver }}
- name: Restore cached LLVM-${{ matrix.clang-runtime }} and ${{ matrix.cling == 'On' && 'Cling' || 'Clang-REPL' }} build
uses: actions/cache/restore@v4
id: cache
with:
path: |
llvm-project
${{ matrix.cling=='On' && 'cling' || '' }}
key: ${{ env.CLING_HASH }}-${{ runner.os }}-${{ matrix.os }}-clang-${{ matrix.clang-runtime }}.x-emscripten
- name: Emscripten build of CppInterOp on Unix systems
if: ${{ runner.os != 'windows' }}
shell: bash -l {0}
run: |
set -e
./emsdk/emsdk activate ${{matrix.emsdk_ver}}
source ./emsdk/emsdk_env.sh
micromamba create -f environment-wasm.yml --platform=emscripten-wasm32
export SYSROOT_PATH=$PWD/emsdk/upstream/emscripten/cache/sysroot
export PREFIX=$MAMBA_ROOT_PREFIX/envs/CppInterOp-wasm
export CMAKE_PREFIX_PATH=$PREFIX
export CMAKE_SYSTEM_PREFIX_PATH=$PREFIX
LLVM_DIR="$(pwd)/llvm-project"
LLVM_BUILD_DIR="$(pwd)/llvm-project/build"
cling_on=$(echo "${{ matrix.cling }}" | tr '[:lower:]' '[:upper:]')
if [[ "${cling_on}" == "ON" ]]; then
CLING_DIR="$(pwd)/cling"
CLING_BUILD_DIR="$(pwd)/cling/build"
CPLUS_INCLUDE_PATH="${CLING_DIR}/tools/cling/include:${CLING_BUILD_DIR}/include:${LLVM_DIR}/llvm/include:${LLVM_DIR}/clang/include:${LLVM_BUILD_DIR}/include:${LLVM_BUILD_DIR}/tools/clang/include:$PWD/include"
else
CPLUS_INCLUDE_PATH="${LLVM_DIR}/llvm/include:${LLVM_DIR}/clang/include:${LLVM_BUILD_DIR}/include:${LLVM_BUILD_DIR}/tools/clang/include:$PWD/include"
fi
# Build CppInterOp next to cling and llvm-project.
mkdir build
cd build
if [[ "${cling_on}" == "ON" ]]; then
emcmake cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
-DCPPINTEROP_USE_CLING=ON \
-DCPPINTEROP_USE_REPL=OFF \
-DCMAKE_PREFIX_PATH=$PREFIX \
-DCling_DIR=$LLVM_BUILD_DIR/tools/cling \
-DLLVM_DIR=$LLVM_BUILD_DIR/lib/cmake/llvm \
-DLLD_DIR=$LLVM_BUILD_DIR/lib/cmake/lld \
-DClang_DIR=$LLVM_BUILD_DIR/lib/cmake/clang \
-DBUILD_SHARED_LIBS=ON \
-DCODE_COVERAGE=${{ env.CODE_COVERAGE }} \
-DCMAKE_INSTALL_PREFIX=$PREFIX \
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \
-DSYSROOT_PATH=$SYSROOT_PATH \
../
else
emcmake cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
-DCMAKE_PREFIX_PATH=$PREFIX \
-DLLVM_DIR=$LLVM_BUILD_DIR/lib/cmake/llvm \
-DLLD_DIR=$LLVM_BUILD_DIR/lib/cmake/lld \
-DClang_DIR=$LLVM_BUILD_DIR/lib/cmake/clang \
-DBUILD_SHARED_LIBS=ON \
-DCODE_COVERAGE=${{ env.CODE_COVERAGE }} \
-DCMAKE_INSTALL_PREFIX=$PREFIX \
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \
-DSYSROOT_PATH=$SYSROOT_PATH \
../
fi
emmake make -j ${{ env.ncpus }} check-cppinterop
cd ./unittests/CppInterOp/
# Fresh install browsers, and run Emscripten tests in them
# This is to match the Emscripten build instructions, where
# we run in a fresh browser, to stop any extra installed
# stuff interferring with the running of the tests
# Explaination of options for emrun
# --browser (name of browser on path)
# --kill_exit makes it so that when emrun finishes,
# that the headless browser we create is killed along with it
# --timeout 60 is such that emrun is killed after 60 seconds if
# still running. emrun should have finished long before then,
# so if it is still running, something went wrong (such as a test
# which crashed the html file). This will cause the ci to fail,
# as a non 0 value of will be returned.
# In the case of Chrome we have the extra --no-sandbox flag, as on
# Ubuntu Chrome will refuse to run otherwise, as it expects to have
# been installed with admin privileges. This flag allows it to run
# in userspace.
# 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 CppInterOpTests in Firefox"
emrun --browser="firefox" --kill_exit --timeout 60 --browser-args="--headless" CppInterOpTests.html
echo "Running DynamicLibraryManagerTests in Firefox"
emrun --browser="firefox" --kill_exit --timeout 60 --browser-args="--headless" DynamicLibraryManagerTests.html
echo "Running CppInterOpTests in Google Chrome"
emrun --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html
echo "Running DynamicLibraryManagerTests in Google Chrome"
emrun --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html
sudo safaridriver --enable
python -m pip install selenium
echo "Running CppInterOpTests in Safari"
emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html &
python ../../../scripts/browser_tests_safari.py CppInterOpTests.html
echo "Running DynamicLibraryManagerTests in Safari"
emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html &
python ../../../scripts/browser_tests_safari.py DynamicLibraryManagerTests.html
cd ../../
emmake make -j ${{ env.ncpus }} install
cd ..
echo "SYSROOT_PATH=$SYSROOT_PATH" >> $GITHUB_ENV
echo "CB_PYTHON_DIR=$CB_PYTHON_DIR" >> $GITHUB_ENV
echo "CPPINTEROP_DIR=$CPPINTEROP_DIR" >> $GITHUB_ENV
echo "LLVM_BUILD_DIR=$LLVM_BUILD_DIR" >> $GITHUB_ENV
echo "CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH" >> $GITHUB_ENV
echo "PREFIX=$PREFIX" >> $GITHUB_ENV
- name: Build xeus-cpp
shell: bash -l {0}
run: |
./emsdk/emsdk activate ${{matrix.emsdk_ver}}
source ./emsdk/emsdk_env.sh
micromamba activate CppInterOp-wasm
git clone --depth=1 https://github.com/compiler-research/xeus-cpp.git
cd ./xeus-cpp
mkdir build
pushd build
export CMAKE_PREFIX_PATH=${{ env.PREFIX }}
export CMAKE_SYSTEM_PREFIX_PATH=${{ env.PREFIX }}
emcmake cmake \
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
-DCMAKE_PREFIX_PATH=${{ env.PREFIX }} \
-DCMAKE_INSTALL_PREFIX=${{ env.PREFIX }} \
-DXEUS_CPP_EMSCRIPTEN_WASM_BUILD=ON \
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \
-DXEUS_CPP_RESOURCE_DIR=${{ env.LLVM_BUILD_DIR }}/lib/clang/${{ matrix.clang-runtime }} \
-DSYSROOT_PATH=${{ env.SYSROOT_PATH }} \
..
emmake make -j ${{ env.ncpus }} install
- name: Test xeus-cpp C++ Emscripten
shell: bash -l {0}
run: |
set -e
micromamba activate CppInterOp-wasm
cd ./xeus-cpp/build/test
node test_xeus_cpp.js
- name: Jupyter Lite integration
shell: bash -l {0}
run: |
cd ./xeus-cpp/
micromamba create -n xeus-lite-host jupyterlite-core=0.6 jupyterlite-xeus jupyter_server jupyterlab notebook python-libarchive-c -c conda-forge
micromamba activate xeus-lite-host
jupyter lite build --XeusAddon.prefix=${{ env.PREFIX }} \
--contents notebooks/xeus-cpp-lite-demo.ipynb \
--contents notebooks/smallpt.ipynb \
--contents notebooks/images/marie.png \
--contents notebooks/audio/audio.wav \
--XeusAddon.mounts="${{ env.PREFIX }}/share/xeus-cpp/tagfiles:/share/xeus-cpp/tagfiles" \
--XeusAddon.mounts="${{ env.PREFIX }}/etc/xeus-cpp/tags.d:/etc/xeus-cpp/tags.d" --output-dir dist
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./xeus-cpp/dist/
deploy:
needs: build
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-22.04
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4