From d2795fd3fa699b6e371a40ae821117655b1c9a4d Mon Sep 17 00:00:00 2001 From: Xu Jun Date: Tue, 26 Dec 2023 14:59:46 +0800 Subject: [PATCH] add CI for MacOS (#123) * Add CI for macos --------- Signed-off-by: Xu Jun --- .github/workflows/ts2wasm_macos.yml | 117 ++++++++++++++++++++++++++++ runtime-library/CMakeLists.txt | 8 +- runtime-library/wamr_config.cmake | 4 +- 3 files changed, 126 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/ts2wasm_macos.yml diff --git a/.github/workflows/ts2wasm_macos.yml b/.github/workflows/ts2wasm_macos.yml new file mode 100644 index 00000000..b869ab64 --- /dev/null +++ b/.github/workflows/ts2wasm_macos.yml @@ -0,0 +1,117 @@ +# +# Copyright (C) 2023 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# + +name: ts2wasm-compiler CI MacOS + +on: + push: + paths-ignore: + - "doc/**" + - "README.md" + pull_request: + types: + - opened + - synchronize + paths-ignore: + - "doc/**" + - "README.md" + # allow to be triggered manually + workflow_dispatch: + +# Cancel any in-flight jobs for the same PR/branch so there's only one active +# at a time +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + install_dependencies: + runs-on: ${{ matrix.os }} + strategy: + matrix: + # node-version: [10.x, 12.x, 14.x, 15.x, 16.x] + # Test the latest version of Node.js plus the last two LTS versions. + # node-version: + # - "*" + # - lts/* + # - lts/-1 + node-version: [16.x, 18.x] + os: [macos-12] + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 5 + + - name: Use node version ${{ matrix.node-version }} + uses: actions/setup-node@v3 + - run: npm install + + - name: Linter + run: npx lint-staged + + validate_compilation: + strategy: + matrix: + # node-version: [10.x, 12.x, 14.x, 15.x, 16.x] + # Test the latest version of Node.js plus the last two LTS versions. + # node-version: + # - "*" + # - lts/* + # - lts/-1 + os: [macos-12] + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 5 + - run: npm install + + - name: build the compiler + run: npm run build + + - name: compile single file + run: node build/cli/ts2wasm.js tests/samples/any_as_string.ts -o test.wasm + + - name: Test compilation + run: + npm run test + + validate_execution: + needs: + [install_dependencies] + runs-on: macos-latest + strategy: + matrix: + target: [ + "X86_64" + ] + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 5 + + - name: Use node version node-16 + uses: actions/setup-node@v3 + with: + node-version: 16.x + + - name: download dependencies + run: | + ./download.sh + working-directory: runtime-library/deps + + - name: Build runtime + run: | + mkdir build && cd build + cmake .. -DWAMR_BUILD_PLATFORM="darwin" -DWAMR_BUILD_TARGET=${{ matrix.target }} -DWAMR_GC_IN_EVERY_ALLOCATION=1 && make -j$(nproc) + working-directory: runtime-library/ + + # TODO: fix validation for MacOS CI + # - name: Validate execution + # run: + # npm start + # working-directory: tools/validate/wamr diff --git a/runtime-library/CMakeLists.txt b/runtime-library/CMakeLists.txt index 95f2b198..2c03fb5b 100644 --- a/runtime-library/CMakeLists.txt +++ b/runtime-library/CMakeLists.txt @@ -15,8 +15,12 @@ if (NOT DEFINED USE_SIMPLE_LIBDYNTYPE) set(USE_SIMPLE_LIBDYNTYPE 0) endif () -set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdata-sections -ffunction-sections -Wall -Werror -Wformat") -set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections") +set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdata-sections -ffunction-sections -Wformat") + +if (NOT "${WAMR_BUILD_PLATFORM}" STREQUAL "darwin") + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror") + set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections") +endif() if (USE_SANITIZER EQUAL 1) message("Sanitizer enabled") diff --git a/runtime-library/wamr_config.cmake b/runtime-library/wamr_config.cmake index 98612b02..6e7d8ec9 100644 --- a/runtime-library/wamr_config.cmake +++ b/runtime-library/wamr_config.cmake @@ -5,7 +5,9 @@ set (WAMR_DIR ${CMAKE_CURRENT_LIST_DIR}/deps/wamr-gc) -set (WAMR_BUILD_PLATFORM "linux") +if (NOT DEFINED WAMR_BUILD_PLATFORM) + set (WAMR_BUILD_PLATFORM "linux") +endif() set (WAMR_BUILD_INTERP 1) set (WAMR_BUILD_LIBC_BUILTIN 1)