Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GH Actions #9

Merged
merged 8 commits into from
Oct 6, 2020
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 139 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
name: C++ CI Workflow

on:
push:
pull_request:
schedule:
# * is a special character in YAML so you have to quote this string
# Execute a "nightly" build at 2 AM UTC
- cron: '0 2 * * *'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I remember there is a time limit for the GitHub action when the repo is private. Probably we should avoid to periodically run the action every 2AM

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I have removed it in c5e43bd


env:
# commit from vcpkg's master branch on 2020/10/06
vcpkg_TAG: 76a7e9248fb3c57350b559966dcaa2d52a5e4458
Catch2_TAG: v2.11.3

jobs:
build:
name: '[${{ matrix.os }}@${{ matrix.build_type }}]'
runs-on: ${{ matrix.os }}
strategy:
matrix:
build_type: [Release, Debug]
os: [ubuntu-latest, windows-latest, macOS-latest]
fail-fast: false

steps:
- uses: actions/checkout@master

# Print environment variables to simplify development and debugging
- name: Environment Variables
shell: bash
run: env

# ============
# DEPENDENCIES
# ============

# Remove apt repos that are known to break from time to time
# See https://github.com/actions/virtual-environments/issues/323
- name: Remove broken apt repos [Ubuntu]
if: matrix.os == 'ubuntu-latest'
run: |
for apt_file in `grep -lr microsoft /etc/apt/sources.list.d/`; do sudo rm $apt_file; done


# Restore from cache the previously built ports. If "cache miss"
# then provision vcpkg, install desired ports, finally cache everything for the next run.
- name: Dependencies [Windows]
if: matrix.os == 'windows-latest'
uses: lukka/run-vcpkg@v3
with:
vcpkgArguments: '--triplet x64-windows matio catch2'
vcpkgGitCommitId: ${{ env.vcpkg_TAG }}

- name: Dependencies [macOS]
if: matrix.os == 'macOS-latest'
run: |
brew update
brew install libmatio catch2

- name: Dependencies [Ubuntu]
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install libmatio-dev valgrind

- name: Cache Source-based Dependencies
id: cache-source-deps
uses: actions/cache@v1
with:
path: ${{ github.workspace }}/install/deps
# Including ${{ runner.temp }} is a workaround taken from https://github.com/robotology/whole-body-estimators/pull/62 to fix macos configuration failure on https://github.com/dic-iit/bipedal-locomotion-framework/pull/45
key: source-deps-${{ runner.os }}-${{runner.temp}}-build-type-${{ matrix.build_type }}-vcpkg-${{ env.vcpkg_TAG }}-catch2-${{ env.Catch2_TAG }}


- name: Source-based Dependencies [Ubuntu]
if: steps.cache-source-deps.outputs.cache-hit != 'true' && matrix.os == 'ubuntu-latest'
shell: bash
run: |
# Catch2
git clone -b ${Catch2_TAG} https://github.com/catchorg/Catch2.git
cd Catch2
mkdir -p build
cd build
cmake -DCMAKE_PREFIX_PATH=${GITHUB_WORKSPACE}/install/deps \
-DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/install/deps \
-DBUILD_TESTING=OFF ..

cmake --build . --config ${{ matrix.build_type }} --target install

# ===================
# CMAKE-BASED PROJECT
# ===================

- name: Configure [Windows]
# Use bash also on Windows (otherwise cd, mkdir, ... do not work)
if: matrix.os == 'windows-latest'
shell: bash
run: |
mkdir -p build
cd build
cmake -A x64 -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake \
-DCMAKE_PREFIX_PATH=${GITHUB_WORKSPACE}/install/deps \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/install \
-DBUILD_TESTING:BOOL=ON ..

- name: Configure [Ubuntu]
if: matrix.os == 'ubuntu-latest'
shell: bash
run: |
mkdir -p build
cd build
cmake -DCMAKE_PREFIX_PATH=${GITHUB_WORKSPACE}/install/deps \
-DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/install \
-DBUILD_TESTING:BOOL=ON \
-DFRAMEWORK_RUN_Valgrind_tests:BOOL=ON ..

- name: Configure [macOS]
if: matrix.os == 'macOS-latest'
shell: bash
run: |
mkdir -p build
cd build
cmake -DCMAKE_PREFIX_PATH=${GITHUB_WORKSPACE}/install/deps \
-DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/install \
-DBUILD_TESTING:BOOL=ON ..

- name: Build
shell: bash
run: |
cd build
cmake --build . --config ${{ matrix.build_type }}

- name: Test
shell: bash
run: |
cd build
ctest --output-on-failure -C ${{ matrix.build_type }} .

4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# extensions off.
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 14)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this is required? Please check this issue: robotology/how-to-export-cpp-library#44

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On MacOs it was not compiling because it was not getting the correct standard. I bumped the CMake minimum version to 3.10 to have the cxx_std_14 compile feature.

set(CMAKE_CXX_STANDARD_REQUIRED ON)

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

Expand Down Expand Up @@ -121,6 +123,8 @@ target_include_directories(matioCpp PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SO

target_link_libraries(matioCpp PUBLIC MATIO::MATIO)

target_compile_features(matioCpp PUBLIC cxx_constexpr)

set_target_properties(matioCpp PROPERTIES
OUTPUT_NAME matioCpp
VERSION ${${PROJECT_NAME}_VERSION}
Expand Down
12 changes: 8 additions & 4 deletions test/SpanUnitTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1216,15 +1216,19 @@ TEST_CASE("interop_with_std_regex")
REQUIRE(match.ready());
REQUIRE(!match.empty());
REQUIRE(match[0].matched);
REQUIRE(match[0].first == s.begin());
REQUIRE(match[0].second == s.end());
bool ok = (match[0].first == s.begin());
REQUIRE(ok);
ok = (match[0].second == s.end());
REQUIRE(ok);

std::regex_search(s.begin(), s.end(), match, std::regex("F"));
REQUIRE(match.ready());
REQUIRE(!match.empty());
REQUIRE(match[0].matched);
REQUIRE(match[0].first == f_it);
REQUIRE(match[0].second == (f_it + 1));
ok = (match[0].first == f_it);
REQUIRE(ok);
ok = (match[0].second == (f_it + 1));
REQUIRE(ok);
}

TEST_CASE("default_constructible")
Expand Down