Skip to content

tests: Handle exceptions during script evaluation in tests #46

tests: Handle exceptions during script evaluation in tests

tests: Handle exceptions during script evaluation in tests #46

Workflow file for this run

name: CI/CD
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build-and-test:
name: "${{ matrix.os }} | ${{ matrix.compiler }} | ${{ matrix.backend }}"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# ======================= Ubuntu (Linux) =======================
- os: ubuntu-latest
compiler: gcc
backend: quickjs
- os: ubuntu-latest
compiler: gcc
backend: v8
v8_url: https://github.com/kuoruan/libv8/releases/download/v12.9.202.27/v8_Linux_x64.tar.xz
v8_inc: deps/v8/include
v8_lib: deps/v8/libv8_monolith.a
- os: ubuntu-latest
compiler: clang
backend: quickjs
- os: ubuntu-latest
compiler: clang
backend: v8
v8_url: https://github.com/kuoruan/libv8/releases/download/v12.9.202.27/v8_Linux_x64.tar.xz
v8_inc: deps/v8/include
v8_lib: deps/v8/libv8_monolith.a
# =========================== macOS ===========================
# 注意:目前的 macos-latest 默认是 ARM64(M1) 架构
- os: macos-latest
compiler: appleclang
backend: quickjs
- os: macos-latest
compiler: appleclang
backend: v8
v8_url: https://github.com/kuoruan/libv8/releases/download/v12.9.202.27/v8_macOS_arm64.tar.xz
v8_inc: deps/v8/include
v8_lib: deps/v8/libv8_monolith.a
# ========================== Windows ==========================
- os: windows-latest
compiler: msvc
backend: quickjs
- os: windows-latest
compiler: msvc
backend: v8
v8_url: https://github.com/kuoruan/libv8/releases/download/v12.9.202.27/v8_Windows_x64.7z
v8_inc: deps/v8
v8_lib: deps/v8/v8_monolith.lib
- os: windows-latest
compiler: clang-cl
backend: quickjs
- os: windows-latest
compiler: clang-cl
backend: v8
v8_url: https://github.com/kuoruan/libv8/releases/download/v12.9.202.27/v8_Windows_x64.7z
v8_inc: deps/v8
v8_lib: deps/v8/v8_monolith.lib
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Fetch QuickJS-NG
if: matrix.backend == 'quickjs'
shell: bash
run: |
git clone --depth 1 --branch v0.14.0 https://github.com/quickjs-ng/quickjs.git deps/quickjs-ng
- name: Fetch V8
if: matrix.backend == 'v8'
shell: bash
run: |
mkdir -p deps/v8
if [ "$RUNNER_OS" == "Windows" ]; then
curl -L -o v8.7z ${{ matrix.v8_url }}
7z x v8.7z -odeps/v8
else
curl -L -o v8.tar.xz ${{ matrix.v8_url }}
tar -xf v8.tar.xz -C deps/v8
fi
- name: Configure CMake
shell: bash
run: |
# 修复 Windows 下路径的转义问题
WORKSPACE_PATH="${GITHUB_WORKSPACE//\\//}"
CMAKE_ARGS="-DJSPP_BACKEND=${{ matrix.backend }} -DJSPP_BUILD_TESTS=ON"
# 根据矩阵配置编译器
if [ "${{ matrix.compiler }}" == "gcc" ]; then
export CC=gcc
export CXX=g++
elif [ "${{ matrix.compiler }}" == "clang" ]; then
export CC=clang
export CXX=clang++
elif [ "${{ matrix.compiler }}" == "clang-cl" ]; then
# Windows 的 MSBuild 生成器支持通过 -T ClangCL 切换成 clang-cl 工具链
CMAKE_ARGS="$CMAKE_ARGS -T ClangCL"
fi
# 挂载预构建的 V8 头文件和静态库
if [ "${{ matrix.backend }}" == "v8" ]; then
CMAKE_ARGS="$CMAKE_ARGS -DJSPP_EXTERNAL_INC=$WORKSPACE_PATH/${{ matrix.v8_inc }} -DJSPP_EXTERNAL_LIB=$WORKSPACE_PATH/${{ matrix.v8_lib }}"
fi
cmake -S . -B build $CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release
- name: Build
run: cmake --build build --config Release --parallel 4
- name: Run Tests
shell: bash
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
./bin/Release/jspp_test.exe
else
./bin/jspp_test
fi