CI: Create wasm artifact and use it in the js-benchmarks workflow

This commit is contained in:
Luke Wilde 2025-08-11 15:54:20 +01:00 committed by Jelle Raaijmakers
parent 73a05f9163
commit 12dc771186
5 changed files with 62 additions and 9 deletions

View File

@ -54,7 +54,7 @@ jobs:
runner_labels: ${{ matrix.runner_labels }} runner_labels: ${{ matrix.runner_labels }}
os: ${{ matrix.os_name }} os: ${{ matrix.os_name }}
arch: ${{ matrix.arch }} arch: ${{ matrix.arch }}
cache_key_extra: 'LibJS Artifacts' cache_key_extra: 'LibJS and LibWasm Artifacts'
ccache_path: ${{ env.CCACHE_DIR }} ccache_path: ${{ env.CCACHE_DIR }}
download_cache_path: ${{ github.workspace }}/Build/caches download_cache_path: ${{ github.workspace }}/Build/caches
vcpkg_cache_path: ${{ github.workspace }}/Build/caches/vcpkg-binary-cache vcpkg_cache_path: ${{ github.workspace }}/Build/caches/vcpkg-binary-cache
@ -78,10 +78,19 @@ jobs:
-DENABLE_GUI_TARGETS=OFF -DENABLE_GUI_TARGETS=OFF
if: ${{ matrix.os_name == 'macOS' }} if: ${{ matrix.os_name == 'macOS' }}
- name: Build and package js - name: Build js
working-directory: Build/distribution working-directory: Build/distribution
run: | run: |
ninja js ninja js
- name: Build wasm
working-directory: Build/distribution
run: |
ninja wasm
- name: Package js and wasm
working-directory: Build/distribution
run: |
cpack cpack
- name: Save Caches - name: Save Caches
@ -99,15 +108,33 @@ jobs:
run: | run: |
set -e set -e
tar -xvzf Build/distribution/ladybird-js-${{ matrix.package_type }}.tar.gz tar -xvzf Build/distribution/ladybird-js-${{ matrix.package_type }}.tar.gz
./bin/js -c "console.log('Hello, World\!');" > out.txt ./bin/js -c "console.log('Hello, World\!');" > js-repl-out.txt
if ! grep -q "\"Hello, World\!\"" out.txt; then if ! grep -q "\"Hello, World\!\"" js-repl-out.txt; then
echo "Sanity check failed: \"Hello, World\!\" not found in output." echo "Sanity check failed: \"Hello, World\!\" not found in output."
exit 1 exit 1
fi fi
- name: Sanity-check the wasm repl
shell: bash
run: |
set -e
tar -xvzf Build/distribution/ladybird-wasm-${{ matrix.package_type }}.tar.gz
./bin/wasm -e run_sanity_check -w ${{ github.workspace }}/Libraries/LibWasm/Tests/CI/ci-sanity-check.wasm > wasm-repl-out.txt
if ! grep -q "Hello, World\!" wasm-repl-out.txt; then
echo "Sanity check failed: Hello, World\! not found in output."
exit 1
fi
- name: Upload js package - name: Upload js package
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: ladybird-js-${{ matrix.package_type }} name: ladybird-js-${{ matrix.package_type }}
path: Build/distribution/ladybird-js*.tar.gz path: Build/distribution/ladybird-js-*.tar.gz
retention-days: 7
- name: Upload wasm package
uses: actions/upload-artifact@v4
with:
name: ladybird-wasm-${{ matrix.package_type }}
path: Build/distribution/ladybird-wasm-*.tar.gz
retention-days: 7 retention-days: 7

View File

@ -45,7 +45,7 @@ jobs:
sudo apt-get install -y python3-venv sudo apt-get install -y python3-venv
- name: 'Download JS repl artifact' - name: 'Download JS repl artifact'
id: download-artifact id: download-js-artifact
uses: dawidd6/action-download-artifact@v11 uses: dawidd6/action-download-artifact@v11
with: with:
run_id: ${{ github.event.workflow_run.id }} run_id: ${{ github.event.workflow_run.id }}
@ -58,14 +58,28 @@ jobs:
cd js-repl cd js-repl
tar -xvzf ladybird-js-${{ matrix.os_name }}-${{ matrix.arch }}.tar.gz tar -xvzf ladybird-js-${{ matrix.os_name }}-${{ matrix.arch }}.tar.gz
- name: 'Run the JS benchmarks' - name: 'Download Wasm repl artifact'
id: download-wasm-artifact
uses: dawidd6/action-download-artifact@v11
with:
run_id: ${{ github.event.workflow_run.id }}
name: ladybird-wasm-${{ matrix.package_type }}
path: wasm-repl
- name: 'Extract Wasm repl'
shell: bash
run: |
cd wasm-repl
tar -xvzf ladybird-wasm-${{ matrix.os_name }}-${{ matrix.arch }}.tar.gz
- name: 'Run the JS and Wasm benchmarks'
shell: bash shell: bash
run: | run: |
cd js-benchmarks cd js-benchmarks
python3 -m venv .venv python3 -m venv .venv
source .venv/bin/activate source .venv/bin/activate
python3 -m pip install -r requirements.txt python3 -m pip install -r requirements.txt
./run.py --executable=${{ github.workspace }}/js-repl/bin/js --iterations=5 ./run.py --executable=${{ github.workspace }}/js-repl/bin/js --wasm-executable=${{ github.workspace }}/wasm-repl/bin/wasm --iterations=5
- name: 'Save results as an artifact' - name: 'Save results as an artifact'
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4

View File

@ -0,0 +1,9 @@
#include <emscripten.h>
#include <stdio.h>
// Compiled with: -O3 -g0
EMSCRIPTEN_KEEPALIVE
void run_sanity_check() {
printf("Hello, World!\n");
}

Binary file not shown.

View File

@ -39,11 +39,13 @@ lagom_utility(xml SOURCES xml.cpp LIBS LibFileSystem LibMain LibXML LibURL)
if (NOT CMAKE_SKIP_INSTALL_RULES) if (NOT CMAKE_SKIP_INSTALL_RULES)
install(TARGETS js COMPONENT js) install(TARGETS js COMPONENT js)
install(TARGETS wasm COMPONENT wasm)
set(CPACK_GENERATOR "TGZ") set(CPACK_GENERATOR "TGZ")
set(CPACK_STRIP_FILES TRUE) set(CPACK_STRIP_FILES TRUE)
set(CPACK_ARCHIVE_COMPONENT_INSTALL ON) set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
set(CPACK_COMPONENTS_ALL js) set(CPACK_COMPONENTS_ALL js wasm)
set(CPACK_COMPONENTS_GROUPING ONE_PER_GROUP)
if (APPLE) if (APPLE)
if("arm64" IN_LIST CMAKE_OSX_ARCHITECTURES AND "x86_64" IN_LIST CMAKE_OSX_ARCHITECTURES) if("arm64" IN_LIST CMAKE_OSX_ARCHITECTURES AND "x86_64" IN_LIST CMAKE_OSX_ARCHITECTURES)
set(CPACK_SYSTEM_NAME "macOS-universal2") set(CPACK_SYSTEM_NAME "macOS-universal2")
@ -55,6 +57,7 @@ if (NOT CMAKE_SKIP_INSTALL_RULES)
endif() endif()
set(CPACK_ARCHIVE_JS_FILE_NAME "ladybird-js-${CPACK_SYSTEM_NAME}") set(CPACK_ARCHIVE_JS_FILE_NAME "ladybird-js-${CPACK_SYSTEM_NAME}")
set(CPACK_ARCHIVE_WASM_FILE_NAME "ladybird-wasm-${CPACK_SYSTEM_NAME}")
set(CPACK_PACKAGE_FILE_NAME "ladybird-js-${CPACK_SYSTEM_NAME}") set(CPACK_PACKAGE_FILE_NAME "ladybird-js-${CPACK_SYSTEM_NAME}")
include(CPack) include(CPack)
endif() endif()