From 1f15702cc1b1e894886b16780d3e7ed1ec830026 Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Wed, 18 Oct 2023 11:54:57 -0400 Subject: [PATCH] [test] Set up a GitHub Actions workflow for CI --- .github/workflows/build-and-run-tests.yml | 49 +++++++++++++++++++++++ CMakeLists.txt | 6 +-- README.md | 2 +- 3 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/build-and-run-tests.yml diff --git a/.github/workflows/build-and-run-tests.yml b/.github/workflows/build-and-run-tests.yml new file mode 100644 index 0000000..822c85e --- /dev/null +++ b/.github/workflows/build-and-run-tests.yml @@ -0,0 +1,49 @@ +name: Build and run tests + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + strategy: + fail-fast: true + + matrix: + os: [ubuntu-latest, windows-latest] + build_type: [Debug, RelWithDebInfo, Release] + cpp_compiler: [g++, clang++] + cpp_standard: [14, 17, 20, 23] + exclude: + - os: ubuntu-latest + cpp_compiler: clang++ + cpp_standard: 20 + - os: ubuntu-latest + cpp_compiler: clang++ + cpp_standard: 23 + - os: windows-latest + cpp_compiler: clang++ + - os: windows-latest + cpp_compiler: g++ + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v3 + + - name: Install Google Test (Linux) + if: matrix.os == 'ubuntu-latest' + run: | + sudo apt-get install libgtest-dev + + - name: Build and Test + run: | + cmake -S ${{ github.workspace }} -B ${{ github.workspace }}/build \ + -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} \ + -DCMAKE_CXX_STANDARD=${{ matrix.cpp_standard }} \ + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + cd ${{ github.workspace }}/build + make + ./bin/utest diff --git a/CMakeLists.txt b/CMakeLists.txt index e592f19..f96bca5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,13 +37,13 @@ elseif ("${CMAKE_CXX_STANDARD}" EQUAL 17) elseif ("${CMAKE_CXX_STANDARD}" EQUAL 20) check_cxx_compiler_flag("-std=c++20" HAVE_REALFLAG) check_cxx_compiler_flag("-std=c++2a" HAVE_FAKEFLAG) - check_cxx_compiler_flag("-std:c++latest" HAVE_MSVCFLAG) + check_cxx_compiler_flag("-std:c++20" HAVE_MSVCFLAG) if (HAVE_REALFLAG) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20") elseif (HAVE_FAKEFLAG) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++2a") elseif (HAVE_MSVCFLAG) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std:c++latest") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std:c++20") else() message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++20 support. Please use a different C++ compiler.") endif() @@ -89,7 +89,7 @@ target_include_directories(${PROJECT_NAME} INTERFACE $ ) -add_subdirectory(benchmarks) +# add_subdirectory(benchmarks) add_subdirectory(test) install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}_targets) diff --git a/README.md b/README.md index 0363c7b..a656ade 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # SG14 -[![Build Status](https://travis-ci.org/Quuxplusone/SG14.svg?branch=master)](https://travis-ci.org/Quuxplusone/SG14) +[![Build Status](https://github.com/Quuxplusone/SG14/actions/workflows/build-and-run-tests.yml/badge.svg?branch=master)](https://github.com/Quuxplusone/SG14/actions/workflows/build-and-run-tests.yml) A library of containers and algorithms pioneered by the ISO C++ Committee's "Low-Latency and Embedded" study group (SG14). For more information on