Skip to content

Commit 5e3d553

Browse files
committed
Add dual mode smoke tests and CI package artifact
1 parent 43ea5e4 commit 5e3d553

3 files changed

Lines changed: 227 additions & 19 deletions

File tree

.github/workflows/smoke.yml

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
name: smoke
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
pull_request:
9+
workflow_dispatch:
10+
11+
env:
12+
BUILD_TYPE: Release
13+
CMAKE_GENERATOR: Ninja
14+
WEBVULKAN_CACHE_VERSION: v1
15+
LLVM_PREBUILT_URL: ${{ vars.WEBVULKAN_LLVM_PREBUILT_URL }}
16+
LLVM_PREBUILT_SHA256: ${{ vars.WEBVULKAN_LLVM_PREBUILT_SHA256 }}
17+
18+
jobs:
19+
in_tree_add_subdirectory:
20+
name: in-tree add_subdirectory smoke
21+
runs-on: ubuntu-latest
22+
timeout-minutes: 240
23+
24+
steps:
25+
- uses: actions/checkout@v4
26+
27+
- name: Install host tools
28+
run: |
29+
sudo apt-get update
30+
sudo apt-get install -y ninja-build flex bison python3-pip
31+
python3 -m pip install --upgrade pip
32+
python3 -m pip install cmake==4.2.0
33+
34+
- name: Restore third-party cache
35+
uses: actions/cache@v4
36+
with:
37+
path: |
38+
.3rdparty
39+
key: ${{ runner.os }}-webvulkan-thirdparty-${{ env.WEBVULKAN_CACHE_VERSION }}
40+
41+
- name: Validate LLVM prebuilt settings
42+
run: |
43+
if [ -z "${LLVM_PREBUILT_URL}" ]; then
44+
echo "Repository variable WEBVULKAN_LLVM_PREBUILT_URL is required"
45+
exit 1
46+
fi
47+
48+
- name: Configure root project
49+
run: |
50+
cmake -S . -B build -G "${CMAKE_GENERATOR}" \
51+
-DCMAKE_BUILD_TYPE="${BUILD_TYPE}" \
52+
-DWEBVULKAN_BUILD_TESTS=ON \
53+
-DLLVM_PROVIDER=prebuilt \
54+
-DLLVM_PREBUILT_URL="${LLVM_PREBUILT_URL}" \
55+
-DLLVM_PREBUILT_SHA256="${LLVM_PREBUILT_SHA256}"
56+
57+
- name: Build and run in-tree smoke
58+
run: |
59+
cmake --build build --target runtime_smoke --config "${BUILD_TYPE}"
60+
61+
- name: Install relocatable package
62+
run: |
63+
cmake --install build --prefix "${GITHUB_WORKSPACE}/package"
64+
65+
- name: Upload relocatable package
66+
uses: actions/upload-artifact@v4
67+
with:
68+
name: webvulkan-package
69+
path: package
70+
if-no-files-found: error
71+
72+
package_sparse_tests:
73+
name: package sparse-tests smoke
74+
runs-on: ubuntu-latest
75+
timeout-minutes: 180
76+
needs:
77+
- in_tree_add_subdirectory
78+
79+
steps:
80+
- uses: actions/checkout@v4
81+
with:
82+
path: tests-only
83+
sparse-checkout: |
84+
tests
85+
sparse-checkout-cone-mode: false
86+
87+
- name: Install host tools
88+
run: |
89+
sudo apt-get update
90+
sudo apt-get install -y ninja-build python3-pip
91+
python3 -m pip install --upgrade pip
92+
python3 -m pip install cmake==4.2.0
93+
94+
- name: Restore third-party cache
95+
uses: actions/cache@v4
96+
with:
97+
path: |
98+
.3rdparty
99+
key: ${{ runner.os }}-webvulkan-thirdparty-${{ env.WEBVULKAN_CACHE_VERSION }}
100+
101+
- name: Bootstrap emsdk when cache is empty
102+
run: |
103+
if [ ! -x "${GITHUB_WORKSPACE}/.3rdparty/emsdk/upstream/emscripten/emcc" ]; then
104+
rm -rf "${GITHUB_WORKSPACE}/.3rdparty/emsdk"
105+
git clone --depth 1 https://github.com/emscripten-core/emsdk.git "${GITHUB_WORKSPACE}/.3rdparty/emsdk"
106+
"${GITHUB_WORKSPACE}/.3rdparty/emsdk/emsdk" install latest
107+
"${GITHUB_WORKSPACE}/.3rdparty/emsdk/emsdk" activate latest
108+
fi
109+
110+
- name: Download relocatable package
111+
uses: actions/download-artifact@v4
112+
with:
113+
name: webvulkan-package
114+
path: package
115+
116+
- name: Configure sparse tests against package
117+
run: |
118+
cmake -S tests-only/tests -B tests-only/build -G "${CMAKE_GENERATOR}" \
119+
-DCMAKE_BUILD_TYPE="${BUILD_TYPE}" \
120+
-DWEBVULKAN_TEST_MODE=package \
121+
-DWEBVULKAN_TEST_PACKAGE_PREFIX="${GITHUB_WORKSPACE}/package" \
122+
-DEMSDK_ROOT="${GITHUB_WORKSPACE}/.3rdparty/emsdk" \
123+
-DWEBVULKAN_EMSCRIPTEN_TOOLCHAIN_FILE="${GITHUB_WORKSPACE}/.3rdparty/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake"
124+
125+
- name: Build and run package smoke
126+
run: |
127+
cmake --build tests-only/build --target runtime_smoke --config "${BUILD_TYPE}"

tests/CMakeLists.txt

Lines changed: 93 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,83 @@
1-
if(NOT TARGET llvmpipe_wasm_spike)
2-
message(FATAL_ERROR "tests require llvmpipe_wasm_spike target from the parent project")
1+
cmake_minimum_required(VERSION 4.2)
2+
3+
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
4+
project(webvulkan_tests LANGUAGES NONE)
5+
endif()
6+
7+
set(WEBVULKAN_TEST_MODE "auto" CACHE STRING "Test mode: auto, in-tree, or package")
8+
set_property(CACHE WEBVULKAN_TEST_MODE PROPERTY STRINGS auto in-tree package)
9+
set(WEBVULKAN_TEST_PACKAGE_PREFIX "" CACHE PATH "Install prefix for WebVulkan package mode")
10+
set(WEBVULKAN_TEST_WASM_BUILD_DIR "${CMAKE_BINARY_DIR}/wasm" CACHE PATH "WASM smoke build directory")
11+
12+
set(_webvulkan_test_mode "${WEBVULKAN_TEST_MODE}")
13+
if(_webvulkan_test_mode STREQUAL "auto")
14+
if(TARGET llvmpipe_wasm_spike)
15+
set(_webvulkan_test_mode "in-tree")
16+
else()
17+
set(_webvulkan_test_mode "package")
18+
endif()
19+
endif()
20+
21+
if(NOT DEFINED EMSDK_ROOT OR EMSDK_ROOT STREQUAL "")
22+
if(DEFINED ENV{EMSDK} AND NOT "$ENV{EMSDK}" STREQUAL "")
23+
set(EMSDK_ROOT "$ENV{EMSDK}")
24+
endif()
25+
endif()
26+
27+
if(NOT DEFINED WEBVULKAN_EMSCRIPTEN_TOOLCHAIN_FILE OR WEBVULKAN_EMSCRIPTEN_TOOLCHAIN_FILE STREQUAL "")
28+
if(DEFINED EMSDK_ROOT AND NOT EMSDK_ROOT STREQUAL "")
29+
set(WEBVULKAN_EMSCRIPTEN_TOOLCHAIN_FILE
30+
"${EMSDK_ROOT}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake")
31+
endif()
32+
endif()
33+
34+
if(NOT DEFINED SUBBUILD_GENERATOR OR SUBBUILD_GENERATOR STREQUAL "")
35+
set(SUBBUILD_GENERATOR "${CMAKE_GENERATOR}")
36+
endif()
37+
38+
if(NOT DEFINED WASM_BUILD_DIR OR WASM_BUILD_DIR STREQUAL "")
39+
set(WASM_BUILD_DIR "${WEBVULKAN_TEST_WASM_BUILD_DIR}")
40+
endif()
41+
42+
if(NOT DEFINED EMSDK_ROOT OR EMSDK_ROOT STREQUAL "")
43+
message(FATAL_ERROR "EMSDK_ROOT is required for runtime smoke tests")
44+
endif()
45+
46+
if(NOT EXISTS "${WEBVULKAN_EMSCRIPTEN_TOOLCHAIN_FILE}")
47+
message(FATAL_ERROR "Emscripten toolchain file was not found at ${WEBVULKAN_EMSCRIPTEN_TOOLCHAIN_FILE}")
48+
endif()
49+
50+
if(NOT SUBBUILD_GENERATOR)
51+
message(FATAL_ERROR "No CMake generator is available for wasm smoke sub-build")
52+
endif()
53+
54+
if(_webvulkan_test_mode STREQUAL "in-tree")
55+
if(NOT TARGET llvmpipe_wasm_spike)
56+
message(FATAL_ERROR "in-tree test mode requires llvmpipe_wasm_spike target")
57+
endif()
58+
if(NOT DEFINED WEBVULKAN_DRIVER_ARCHIVE OR WEBVULKAN_DRIVER_ARCHIVE STREQUAL "")
59+
message(FATAL_ERROR "in-tree test mode requires WEBVULKAN_DRIVER_ARCHIVE")
60+
endif()
61+
if(NOT DEFINED MESA_SRC_DIR OR MESA_SRC_DIR STREQUAL "")
62+
message(FATAL_ERROR "in-tree test mode requires MESA_SRC_DIR")
63+
endif()
64+
set(_webvulkan_driver_archive "${WEBVULKAN_DRIVER_ARCHIVE}")
65+
set(_webvulkan_smoke_include_dirs
66+
"${MESA_SRC_DIR}/include"
67+
"${MESA_SRC_DIR}/src"
68+
)
69+
elseif(_webvulkan_test_mode STREQUAL "package")
70+
if(NOT WEBVULKAN_TEST_PACKAGE_PREFIX)
71+
message(FATAL_ERROR "package test mode requires WEBVULKAN_TEST_PACKAGE_PREFIX")
72+
endif()
73+
set(_webvulkan_driver_archive "${WEBVULKAN_TEST_PACKAGE_PREFIX}/lib/libwebvulkan_driver.a")
74+
set(_webvulkan_smoke_include_dirs
75+
"${WEBVULKAN_TEST_PACKAGE_PREFIX}/include/mesa"
76+
"${WEBVULKAN_TEST_PACKAGE_PREFIX}/include/mesa/src"
77+
"${WEBVULKAN_TEST_PACKAGE_PREFIX}/include/llvm"
78+
)
79+
else()
80+
message(FATAL_ERROR "Unsupported WEBVULKAN_TEST_MODE='${WEBVULKAN_TEST_MODE}'")
381
endif()
482

583
set(WEBVULKAN_WASM_SMOKE_OK "${WASM_BUILD_DIR}/runtime_smoke.ok")
@@ -24,24 +102,29 @@ add_custom_target(wasm_runtime_smoke DEPENDS "${WEBVULKAN_WASM_SMOKE_OK}")
24102

25103
set(WEBVULKAN_LAVAPIPE_SMOKE_OK "${CMAKE_BINARY_DIR}/lavapipe_runtime_smoke.ok")
26104
set(WEBVULKAN_LAVAPIPE_SMOKE_JS "${CMAKE_BINARY_DIR}/lavapipe-smoke/lavapipe_runtime_smoke.js")
105+
set(_webvulkan_lavapipe_depends
106+
"${CMAKE_CURRENT_LIST_DIR}/RunLavapipeRuntimeSmoke.cmake"
107+
"${CMAKE_CURRENT_LIST_DIR}/wasm/src/lavapipe_runtime_smoke.c"
108+
"${CMAKE_CURRENT_LIST_DIR}/wasm/tools/smoke_runtime.mjs"
109+
"${_webvulkan_driver_archive}"
110+
)
111+
if(_webvulkan_test_mode STREQUAL "in-tree")
112+
list(APPEND _webvulkan_lavapipe_depends llvmpipe_wasm_spike)
113+
endif()
114+
27115
add_custom_command(
28116
OUTPUT "${WEBVULKAN_LAVAPIPE_SMOKE_OK}"
29117
COMMAND
30118
"${CMAKE_COMMAND}"
31119
-DEMSDK_ROOT=${EMSDK_ROOT}
32-
-DMESA_SRC_DIR=${MESA_SRC_DIR}
33-
-DMESA_BUILD_DIR=${MESA_WASM_BUILD_DIR}
34-
-DDRIVER_ARCHIVE=${WEBVULKAN_DRIVER_ARCHIVE}
120+
-DDRIVER_ARCHIVE=${_webvulkan_driver_archive}
121+
-DSMOKE_INCLUDE_DIRS=${_webvulkan_smoke_include_dirs}
35122
-DSMOKE_SOURCE=${CMAKE_CURRENT_LIST_DIR}/wasm/src/lavapipe_runtime_smoke.c
36123
-DSMOKE_JS_OUT=${WEBVULKAN_LAVAPIPE_SMOKE_JS}
37124
-DSMOKE_SCRIPT=${CMAKE_CURRENT_LIST_DIR}/wasm/tools/smoke_runtime.mjs
38125
-P "${CMAKE_CURRENT_LIST_DIR}/RunLavapipeRuntimeSmoke.cmake"
39126
COMMAND "${CMAKE_COMMAND}" -E touch "${WEBVULKAN_LAVAPIPE_SMOKE_OK}"
40-
DEPENDS
41-
llvmpipe_wasm_spike
42-
"${CMAKE_CURRENT_LIST_DIR}/RunLavapipeRuntimeSmoke.cmake"
43-
"${CMAKE_CURRENT_LIST_DIR}/wasm/src/lavapipe_runtime_smoke.c"
44-
"${CMAKE_CURRENT_LIST_DIR}/wasm/tools/smoke_runtime.mjs"
127+
DEPENDS ${_webvulkan_lavapipe_depends}
45128
USES_TERMINAL
46129
VERBATIM
47130
)

tests/RunLavapipeRuntimeSmoke.cmake

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ function(require_var VAR_NAME)
77
endfunction()
88

99
require_var(EMSDK_ROOT)
10-
require_var(MESA_SRC_DIR)
11-
require_var(MESA_BUILD_DIR)
1210
require_var(DRIVER_ARCHIVE)
11+
require_var(SMOKE_INCLUDE_DIRS)
1312
require_var(SMOKE_SOURCE)
1413
require_var(SMOKE_JS_OUT)
1514
require_var(SMOKE_SCRIPT)
@@ -32,11 +31,6 @@ endif()
3231
list(SORT NODE_CANDIDATES COMPARE NATURAL ORDER DESCENDING)
3332
list(GET NODE_CANDIDATES 0 NODE_EXE)
3433

35-
set(MESA_LAVAPIPE_ARCHIVE "${MESA_BUILD_DIR}/src/gallium/frontends/lavapipe/liblavapipe_st.a")
36-
if(NOT EXISTS "${MESA_LAVAPIPE_ARCHIVE}")
37-
message(FATAL_ERROR "Missing lavapipe archive ${MESA_LAVAPIPE_ARCHIVE}")
38-
endif()
39-
4034
if(NOT EXISTS "${DRIVER_ARCHIVE}")
4135
message(FATAL_ERROR "Missing driver archive ${DRIVER_ARCHIVE}")
4236
endif()
@@ -55,8 +49,12 @@ append_rsp("${SMOKE_SOURCE}")
5549
append_rsp("-o")
5650
append_rsp("${SMOKE_JS_OUT}")
5751
append_rsp("-std=c11")
58-
append_rsp("-I${MESA_SRC_DIR}/include")
59-
append_rsp("-I${MESA_SRC_DIR}/src")
52+
foreach(SMOKE_INCLUDE_DIR IN LISTS SMOKE_INCLUDE_DIRS)
53+
if(NOT EXISTS "${SMOKE_INCLUDE_DIR}")
54+
message(FATAL_ERROR "Missing include directory ${SMOKE_INCLUDE_DIR}")
55+
endif()
56+
append_rsp("-I${SMOKE_INCLUDE_DIR}")
57+
endforeach()
6058
append_rsp("-sALLOW_MEMORY_GROWTH=1")
6159
append_rsp("-sMODULARIZE=1")
6260
append_rsp("-sEXPORT_ES6=1")

0 commit comments

Comments
 (0)