From 225f40e854d21b6c8653db5c048de516a7cd0dd3 Mon Sep 17 00:00:00 2001 From: Vitaly Bogdanov Date: Wed, 20 Dec 2023 11:32:47 +0300 Subject: [PATCH] Add minimal CI workflow It is indicative workflow. It doesn't prevent PR merge. --- .github/workflows/minimal.yml | 101 ++++++++++++++++++++++++++++++++++ CMakeLists.txt | 1 + c/CMakeLists.txt | 5 +- 3 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/minimal.yml diff --git a/.github/workflows/minimal.yml b/.github/workflows/minimal.yml new file mode 100644 index 000000000..be9353903 --- /dev/null +++ b/.github/workflows/minimal.yml @@ -0,0 +1,101 @@ +# This workflow is intended to run tests on minimal MeTTa interpreter. +# It is indicative and temporary, it doesn't prevent any changes from merging. + +# This workflow uses actions that are not certified by GitHub. They are +# provided by a third-party and are governed by separate terms of service, +# privacy policy, and support documentation. + +name: minimal + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + run: + runs-on: ubuntu-20.04 + + steps: + - name: Check out repository code + uses: actions/checkout@v3 + + - name: Install Rust stable + uses: actions-rs/toolchain@v1.0.6 + with: + toolchain: stable + override: true + + - name: Build Rust library + working-directory: ./lib + run: | + cargo check --features minimal + cargo build --features minimal + + - name: Test Rust library + working-directory: ./lib + run: | + RUST_LOG=hyperon=debug cargo test --features minimal + + - name: Install cbindgen + uses: actions-rs/cargo@v1.0.1 + with: + command: install + args: cbindgen + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3.7 + + - name: Install CMake + uses: jwlawson/actions-setup-cmake@v1.14.1 + with: + cmake-version: 3.16.x + + - name: Install Conan + uses: turtlebrowser/get-conan@v1.2 + with: + version: 1.60.2 + + - name: Setup Conan profile + run: | + conan profile new --detect default + + - name: Print environment + run: | + echo "rustc --version" + rustc --version + echo "cbindgen --version" + cbindgen --version + echo "python --version" + python --version + echo "conan --version" + conan --version + echo "conan profile show default" + conan profile show default + echo "gcc --version" + gcc --version + echo "cmake --version" + cmake --version + echo "make --version" + make --version + + - name: Setup C API build + run: | + mkdir -p build + cd build + # specify C compiler as conan could not find it automatically + # see https://github.com/conan-io/conan/issues/4322 + cmake -DCARGO_ARGS="--features hyperon/minimal" -DCMAKE_BUILD_TYPE=Release -DPython3_EXECUTABLE=`which python` -DCMAKE_C_COMPILER=gcc .. + + - name: Build C API + working-directory: ./build + run: make + + - name: Test C API + working-directory: ./build + run: make check diff --git a/CMakeLists.txt b/CMakeLists.txt index f040c1d4e..89b229101 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,7 @@ ExternalProject_Add( CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=${HYPERONC_INSTALL_PREFIX}" "-DCMAKE_BUILD_TYPE=${BUILD_CONFIGURATION}" + "-DCARGO_ARGS=${CARGO_ARGS}" ) ExternalProject_Get_Property(hyperonc BINARY_DIR) diff --git a/c/CMakeLists.txt b/c/CMakeLists.txt index b80568e77..0e94587c9 100644 --- a/c/CMakeLists.txt +++ b/c/CMakeLists.txt @@ -32,9 +32,11 @@ add_custom_target(show-build-type-vars COMMAND ${CMAKE_COMMAND} -E echo set(HYPERONC_STATIC_LIB_FILE ${CMAKE_STATIC_LIBRARY_PREFIX}hyperonc${CMAKE_STATIC_LIBRARY_SUFFIX}) set(HYPERONC_STATIC_LIB_PATH ${HYPERONC_TARGET_DIR}/${HYPERONC_STATIC_LIB_FILE}) set(HYPERONC_INCLUDE_DIR ${HYPERONC_TARGET_DIR}/hyperon) +separate_arguments(CARGO_ARGS_LIST NATIVE_COMMAND ${CARGO_ARGS}) add_custom_target(build-hyperonc ALL COMMAND cargo build + ${CARGO_ARGS_LIST} $<${IS_RELEASE_BUILD}:--release> --target-dir ${HYPERONC_TARGET_DIR} @@ -115,5 +117,6 @@ install(DIRECTORY "${HYPERONC_INCLUDE_DIR}" install(FILES "${CMAKE_CURRENT_BINARY_DIR}/hyperonc-config.cmake" DESTINATION "${CONFIG_INSTALL_PATH}") -add_test(NAME rust_c_api COMMAND cargo test --target-dir ${HYPERONC_TARGET_DIR} +add_test(NAME rust_c_api + COMMAND cargo test ${CARGO_ARGS_LIST} --target-dir ${HYPERONC_TARGET_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})