Skip to content

Commit

Permalink
Migrate to eProsima-CI (#195)
Browse files Browse the repository at this point in the history
* Refs #20423: Migrate to eProsima-CI and add Windows 2019 run

Signed-off-by: EduPonz <eduardoponz@eprosima.com>

* Refs #20423: Require CMake 3.22 for testing

Signed-off-by: EduPonz <eduardoponz@eprosima.com>

* Refs #20423: Add a test summary step

Signed-off-by: EduPonz <eduardoponz@eprosima.com>

* Refs #20423: Set v0 version for eProsima-CI actions

Signed-off-by: EduPonz <eduardoponz@eprosima.com>

---------

Signed-off-by: EduPonz <eduardoponz@eprosima.com>
(cherry picked from commit c045c23)
  • Loading branch information
EduPonz authored and JesusPoderoso committed Feb 14, 2024
1 parent 992e712 commit 833a20f
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 28 deletions.
81 changes: 53 additions & 28 deletions .github/workflows/fastcdr-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,65 +40,90 @@ concurrency:
cancel-in-progress: true

jobs:

#############################
###### UBUNTU BUILD #######
#############################
ubuntu-build-and-test:
build-and-test:
name: Colcon build and test

if: ${{ !(contains(github.event.pull_request.labels.*.name, 'no-test') ||
contains(github.event.pull_request.labels.*.name, 'skip-ci')) }}

runs-on: ${{ matrix.ubuntu-version }}
runs-on: ${{ matrix.runner-image }}
strategy:
fail-fast: false
matrix:
ubuntu-version:
runner-image:
- 'ubuntu-20.04'
- 'ubuntu-22.04'
- 'windows-2019'

steps:
- name: Sync eProsima/Fast-CDR repository
uses: actions/checkout@v3
uses: eProsima/eProsima-CI/external/checkout@v0
with:
path: src/Fast-CDR

- name: Get minimum supported version of CMake
uses: eProsima/eProsima-CI/external/get-cmake@v0
with:
cmakeVersion: '3.22.6'

- name: Install Colcon dependencies
uses: eProsima/eProsima-CI/ubuntu/install_colcon@main
uses: eProsima/eProsima-CI/multiplatform/install_colcon@v0

# Temporal step as this platform will be discontinued soon
- name: Install Gtest Backwards Compatibility
if: ${{ matrix.ubuntu-version == 'ubuntu-20.04' }}
if: ${{ matrix.runner-image == 'ubuntu-20.04' }}
run: |
git clone --branch release-1.12.1 https://github.com/google/googletest.git && \
colcon build \
--event-handlers=console_direct+ \
--packages-select googletest-distribution
- name: Install Gtest
if: ${{ matrix.ubuntu-version == 'ubuntu-22.04' }}
uses: eProsima/eProsima-CI/ubuntu/install_gtest@feature/install_gtest

- name: Build
run: |
colcon build \
--event-handlers=console_direct+ \
--packages-select fastcdr \
--cmake-args -DCMAKE_BUILD_TYPE=RelWithDebInfo -DEPROSIMA_BUILD_TESTS=ON \
${{ inputs.cmake_args }}
if: ${{ matrix.runner-image != 'ubuntu-20.04' }}
uses: eProsima/eProsima-CI/multiplatform/install_gtest@v0

- name: Run Tests
run: |
colcon test \
--event-handlers=console_direct+ \
--packages-select fastcdr \
--return-code-on-test-failure \
--ctest-args ${{ inputs.ctest_args }}
- name: Colcon build
uses: eProsima/eProsima-CI/multiplatform/colcon_build@v0
with:
colcon_build_args_default: --event-handlers=console_direct+
cmake_args: ${{ inputs.cmake_args }}
cmake_args_default: -DBUILD_TESTING=ON
cmake_build_type: RelWithDebInfo
workspace: ${{ github.workspace }}

- name: Colcon test
id: test
uses: eProsima/eProsima-CI/multiplatform/colcon_test@v0
with:
colcon_test_args_default: --event-handlers=console_direct+ --return-code-on-test-failure
ctest_args: ${{ inputs.ctest_args }}
ctest_args_default: --repeat until-pass:3 --timeout 300 --output-junit junit/junit.xml
packages_names: fastcdr
workspace: ${{ github.workspace }}

- name: Test summary
uses: eProsima/eProsima-CI/multiplatform/junit_summary@v0
if: ${{ !cancelled() && !contains(github.event.pull_request.labels.*.name, 'no-test') }}
with:
junit_reports_dir: "${{ steps.test.outputs.ctest_results_path }}"
print_summary: 'True'
show_failed: 'True'
show_disabled: 'False'
show_skipped: 'False'

- name: Test Report
uses: eProsima/eProsima-CI/external/test-reporter@v0
if: ${{ !cancelled() && !contains(github.event.pull_request.labels.*.name, 'no-test') }}
with:
name: "Report: ${{ matrix.runner-image }}"
path: "${{ steps.test.outputs.ctest_results_path }}*.xml"
working-directory: 'src/Fast-CDR'
path-replace-backslashes: 'true'
list-tests: 'failed'

- name: Archive Test Results
if: always()
uses: actions/upload-artifact@v1
with:
name: test-results-${{ matrix.ubuntu-version }}
name: test-results-${{ matrix.runner-image }}
path: log/latest_test/fastcdr
30 changes: 30 additions & 0 deletions cmake/testing/GoogleTest.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima).
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

include(GoogleTest)

function(gtest_discover_tests TARGET)
cmake_minimum_required(VERSION 3.22)
if (WIN32)
add_custom_command(
TARGET ${TARGET} POST_BUILD
COMMAND ${CMAKE_COMMAND} -DTARGET=${TARGET} -DCONFIG=$<CONFIG> -DRUNTIME_LIST=$<TARGET_RUNTIME_DLLS:${TARGET}> -P ${CMAKE_SOURCE_DIR}/cmake/testing/generate_google_test_win_wrapper.cmake
COMMAND_EXPAND_LISTS
VERBATIM
)

set(CMAKE_COMMAND "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_win_wrapper_$<CONFIG>.bat")
endif()
_gtest_discover_tests(${TARGET} ${ARGN})
endfunction()

0 comments on commit 833a20f

Please sign in to comment.