Skip to content

Fix c++ tests, enable C++ tests in CI, added rdact (act wrapper) for running GitHub actions locallyAb fix tests #980

Fix c++ tests, enable C++ tests in CI, added rdact (act wrapper) for running GitHub actions locallyAb fix tests

Fix c++ tests, enable C++ tests in CI, added rdact (act wrapper) for running GitHub actions locallyAb fix tests #980

Workflow file for this run

name: build-rd-cpp
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
env:
NINJA_VERSION: 1.9.0
BUILD_TYPE: Release
jobs:
build:
env:
working-dir: ${{ github.workspace}}${{ matrix.config.SEP }}rd-cpp
artifact: ${{ matrix.config.artifact }}${{ github.run_number }}.zip
GRADLE_USER_HOME: ${{ github.workspace }}/.github/gradle
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- {
name: "RD CPP Windows VS 2019", artifact: "RD-CPP-Windows-MSVC-2019-",
os: windows-2019,
cc: "cl", cxx: "cl",
environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat",
SEP: \,
suffix: win-vs19
}
- {
name: "RD CPP Ubuntu Latest Clang", artifact: "RD-CPP-Linux-Clang-",
os: ubuntu-latest,
cc: "clang", cxx: "clang++",
SEP: /,
suffix: linux-clang
}
- {
name: "RD CPP macOS Latest Clang", artifact: "RD-CPP-macOS-Clang-",
os: macos-latest,
cc: "clang", cxx: "clang++",
SEP: /,
suffix: mac-clang
}
steps:
- uses: actions/checkout@v3
- name: Cache submodules
uses: actions/cache@v3
id: cache-submodules
with:
path: |
rd-cpp/thirdparty/spdlog
rd-cpp/thirdparty/googletest
key: ${{ matrix.config.os }}-submodules-${{ hashFiles('.gitmodules') }}
- name: Get submodules
if: steps.cache-submodules.outputs.cache-hit != 'true'
run: git submodule update --init --recursive
- name: Get nuget
if: steps.cache-nuget.outputs.cache-hit != 'true'
uses: nuget/setup-nuget@v1
with:
nuget-version: '5.x'
- name: Gradle JVM Cache
uses: actions/cache@v3
with:
path: ~/.local/share/gradle-jvm
key: ${{ runner.os }}.gradle-jvm-cache.${{ hashFiles('gradle/**') }}
- name: Gradle Wrapper Cache
uses: actions/cache@v3
with:
path: ${{ env.GRADLE_USER_HOME }}/wrapper
key: ${{ runner.os }}.gradle-wrapper.${{ hashFiles('gradle/**') }}
- name: Gradle Cache
uses: actions/cache@v3
with:
path: ${{ env.GRADLE_USER_HOME }}/caches/modules-2
key: ${{ runner.os }}.gradle.${{ hashFiles('**/*.gradle.kts') }}
- name: Generate everything
working-directory: ${{ env.working-dir }}/..
run: ./gradlew generateEverything
- name: Cache Ninja
uses: actions/cache@v3
id: cache-ninja
with:
path: |
rd-cpp/ninja
rd-cpp/ninja.exe
key: ${{ matrix.config.os }}-Ninja-${{ env.NINJA_VERSION }}
- name: Download Ninja
if: steps.cache-ninja.outputs.cache-hit != 'true'
id: download_ninja
working-directory: ${{ env.working-dir }}
shell: cmake -P {0}
run: |
set(ninja_version $ENV{NINJA_VERSION})
message(STATUS "Using host CMake version: ${CMAKE_VERSION}")
if ("${{ runner.os }}" STREQUAL "Windows")
set(ninja_suffix "win.zip")
elseif ("${{ runner.os }}" STREQUAL "Linux")
set(ninja_suffix "linux.zip")
elseif ("${{ runner.os }}" STREQUAL "macOS")
set(ninja_suffix "mac.zip")
endif()
set(ninja_url "https://github.com/ninja-build/ninja/releases/download/v${ninja_version}/ninja-${ninja_suffix}")
file(DOWNLOAD "${ninja_url}" ./ninja.zip SHOW_PROGRESS)
execute_process(COMMAND
${CMAKE_COMMAND} -E tar xvf ./ninja.zip
RESULT_VARIABLE download_ninja_result)
if (NOT download_ninja_result EQUAL 0)
message(FATAL_ERROR "Bad exit status. Fail downloading Ninja")
endif()
if (NOT "${{ runner.os }}" STREQUAL "Windows")
execute_process(COMMAND chmod +x ninja)
endif()
- name: Configure
working-directory: ${{ env.working-dir }}
shell: cmake -P {0}
run: |
set(ENV{CC} ${{ matrix.config.cc }})
set(ENV{CXX} ${{ matrix.config.cxx }})
file(GLOB all_files "*")
message(${all_files})
if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x")
execute_process(
COMMAND "${{ matrix.config.environment_script }}" && set
OUTPUT_FILE environment_script_output.txt
RESULT_VARIABLE execute_vcvars_result
)
if (NOT execute_vcvars_result EQUAL 0)
message(FATAL_ERROR "Bad exit status ${execute_vcvars_result}. Fail running ${{ matrix.config.environment_script }}")
endif()
file(STRINGS environment_script_output.txt output_lines)
foreach(line IN LISTS output_lines)
if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$")
set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}")
endif()
endforeach()
endif()
set(path_separator ":")
if ("${{ runner.os }}" STREQUAL "Windows")
set(path_separator ";")
endif()
set(ENV{PATH} "$ENV{GITHUB_WORKSPACE}${path_separator}$ENV{PATH}")
file(MAKE_DIRECTORY build)
execute_process(
COMMAND ${CMAKE_COMMAND}
-S .
-B build
-DENABLE_TESTS_OPTION:BOOL=ON
-DCMAKE_BUILD_TYPE=$ENV{BUILD_TYPE}
-G Ninja
-DCMAKE_MAKE_PROGRAM=${CMAKE_CURRENT_SOURCE_DIR}/ninja
RESULT_VARIABLE build_result
)
if (NOT build_result EQUAL 0)
message(FATAL_ERROR "Bad exit status. Fail building RD CPP")
endif()
- name: Upload environment script log
uses: actions/upload-artifact@v3
if: always()
with:
name: build-log-${{ matrix.config.os }}
path: environment_script_output.txt
- name: Build
working-directory: ${{ env.working-dir }}
shell: cmake -P {0}
run: |
set(ENV{NINJA_STATUS} "[%f/%t %o/sec] ")
file(GLOB all_files "*")
message(${all_files})
if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x")
file(STRINGS environment_script_output.txt output_lines)
foreach(line IN LISTS output_lines)
if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$")
set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}")
endif()
endforeach()
endif()
set(path_separator ":")
if ("${{ runner.os }}" STREQUAL "Windows")
set(path_separator ";")
endif()
set(ENV{PATH} "$ENV{GITHUB_WORKSPACE}${path_separator}$ENV{PATH}")
execute_process(
COMMAND ${CMAKE_COMMAND} --build build --config ${{ env.BUILD_TYPE }}
RESULT_VARIABLE result
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "Bad exit status")
endif()
- name: Run core tests
working-directory: ${{ env.working-dir }}
run: build/src/rd_core_cpp/src/test/rd_core_cpp_test
- name: Run framework tests
working-directory: ${{ env.working-dir }}
run: build/src/rd_framework_cpp/src/test/rd_framework_cpp_test
- name: Install Strip
working-directory: ${{ env.working-dir }}
run: cd build && cmake --config ${{ env.BUILD_TYPE }} -P cmake_install.cmake
- name: Pack
working-directory: ${{ env.working-dir }}
run: cd export && cmake -E tar "cfv" ../${{ env.artifact }} --format=zip include libs
- name: Upload
uses: actions/upload-artifact@v3
with:
path: |
${{ env.working-dir }}${{ matrix.config.SEP }}export${{ matrix.config.SEP }}**
name: ${{ env.artifact }}