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

chore: add codecov github action #5

Merged
merged 14 commits into from
Dec 23, 2023
38 changes: 26 additions & 12 deletions .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: C/C++ CI
name: CI

on:
push:
Expand All @@ -9,28 +9,42 @@ on:
jobs:
build:
runs-on: ubuntu-latest
name: Debug Test
steps:
- name: Set up GCC
uses: egor-tensin/setup-gcc@v1
with:
version: 12
platform: x64

- name: Check out repository
uses: actions/checkout@v3

- name: Setup GCC
uses: Dup4/actions-setup-gcc@v1
with:
version: 12

- name: Install dependencies
run: sudo apt install -y libaio-dev
run: sudo apt install -y libaio-dev gcovr

- name: Config project
run: cmake -B build -S .
run: cmake -B build/debug -S . -DCMAKE_BUILD_TYPE=Debug -DBUILD_WITH_COVERAGE=ON

- name: Build project
run: cmake --build build -j `nproc`
run: cmake --build build/debug -j `nproc`

- name: Test
run: ctest --test-dir build/debug

- name: Test test
run: ctest --test-dir build --output-on-failure
- name: Generate coverage file
run: gcovr -v -r . --json-pretty --json=coverage.json --xml-pretty --xml=coverage.xml --exclude 'build/*' --exclude 'tests/*'

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: coverage.xml
verbose: true

- name: Setup tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
if: ${{ failure() }}
with:
limit-access-to-actor: true
15 changes: 14 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,25 @@ if (NOT UNIX)
message(SEND_ERROR "unsupported platform")
endif ()

# Define custom build options
option(BUILD_WITH_COVERAGE "Build the library with code coverage" OFF)

option(THIRD_PARTY_SRC_DIR "The directory to store downloaded third-party sources" "${CMAKE_CURRENT_BINARY_DIR}/third-party-src")
if(NOT THIRD_PARTY_SRC_DIR)
set(THIRD_PARTY_SRC_DIR ${CMAKE_CURRENT_BINARY_DIR}/third-party-src)
endif()
message(STATUS "THIRD_PARTY_SRC_DIR: ${THIRD_PARTY_SRC_DIR}")


enable_language(ASM)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -rdynamic -fno-omit-frame-pointer -g3 -static-libstdc++")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused -Wunreachable-code")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
if(BUILD_WITH_COVERAGE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage -g -O0")
endif()

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

if (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)")
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[![CI](https://github.com/zz-jason/leanstore/actions/workflows/c-cpp.yml/badge.svg)](https://github.com/zz-jason/leanstore/actions/workflows/c-cpp.yml)
[![codecov](https://codecov.io/github/zz-jason/leanstore/graph/badge.svg?token=MBS1H361JJ)](https://codecov.io/github/zz-jason/leanstore)

# LeanStore

[LeanStore](https://db.in.tum.de/~leis/papers/leanstore.pdf) is a
Expand All @@ -17,8 +20,8 @@ hope to make it usable in production in the future.

```sh
# install dependencies
sudo apt-get update
sudo apt-get install -y libaio-dev
sudo apt update
sudo apt install -y libaio-dev gcovr lcov

# build
cmake -DCMAKE_BUILD_TYPE=Debug -B build -S .
Expand Down
1 change: 1 addition & 0 deletions cmake/Modules/LeanStoreAddExternalHeaderOnlyLib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ function(leanstore_add_ext_header_only_lib TARGET_NAME GIT_REPO GIT_TAG)
set(LIB_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/third-party)
set(TARGET_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/third-party/${TARGET_NAME}-src)
ExternalProject_Add(${TARGET_NAME}_internal
SOURCE_DIR ${THIRD_PARTY_SRC_DIR}/${TARGET_NAME}_src
PREFIX ${TARGET_PREFIX}
GIT_REPOSITORY ${GIT_REPO}
GIT_TAG ${GIT_TAG}
Expand Down
1 change: 1 addition & 0 deletions cmake/Modules/LeanStoreAddExternalLib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ function(leanstore_add_ext_lib TARGET_NAME LIB_NAME GIT_REPO GIT_TAG)
set(TARGET_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/third-party/${TARGET_NAME}-src)
set(TARGET_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/third-party/${TARGET_NAME})
ExternalProject_Add(${TARGET_NAME}_internal
SOURCE_DIR ${THIRD_PARTY_SRC_DIR}/${TARGET_NAME}_src
PREFIX ${TARGET_PREFIX}
GIT_REPOSITORY ${GIT_REPO}
GIT_TAG ${GIT_TAG}
Expand Down
18 changes: 15 additions & 3 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
include(GoogleTest)
enable_testing()

set(TEST_EXECUTABLES "")

# Define a cmake function to add a test file linked with Google Test
function(leanstore_add_test TARGET_NAME)
add_executable(
Expand All @@ -13,8 +15,9 @@ function(leanstore_add_test TARGET_NAME)
gtest
leanstore
)
target_compile_options(${TARGET_NAME} PRIVATE -fprofile-arcs -ftest-coverage)
gtest_discover_tests(${TARGET_NAME})
list(APPEND TEST_EXECUTABLES ${TARGET_NAME})

endfunction(leanstore_add_test)

function(leanstore_add_test_without_gtest_main TARGET_NAME)
Expand All @@ -27,8 +30,8 @@ function(leanstore_add_test_without_gtest_main TARGET_NAME)
gtest
leanstore
)
target_compile_options(${TARGET_NAME} PRIVATE -fprofile-arcs -ftest-coverage)
gtest_discover_tests(${TARGET_NAME})
list(APPEND TEST_EXECUTABLES ${TARGET_NAME})
endfunction(leanstore_add_test_without_gtest_main)


Expand All @@ -37,4 +40,13 @@ leanstore_add_test(BTreeLLTest)
leanstore_add_test(BTreeVILoggingAndRecoveryTest)
leanstore_add_test(BufferFrameTest)

leanstore_add_test_without_gtest_main(BTreeVITest)
leanstore_add_test_without_gtest_main(BTreeVITest)

# # for code coverages
# if(BUILD_WITH_COVERAGE)
# add_custom_target(coverage
# COMMAND gcovr -r . --json-pretty -json coverage.json --xml-pretty -xml coverage.xml --exclude 'build/*' --exclude 'tests/*'
# COMMENT "Generating code coverage reports"
# DEPENDS ${TEST_EXECUTABLES}
# )
# endif()
1 change: 1 addition & 0 deletions third-party/gbench.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set(GIT_TAG v1.8.3)
set(TARGET_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/third-party/${TARGET_NAME}-src)
set(TARGET_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/third-party/${TARGET_NAME})
ExternalProject_Add(${TARGET_NAME}_internal
SOURCE_DIR ${THIRD_PARTY_SRC_DIR}/${TARGET_NAME}_src
PREFIX ${TARGET_PREFIX}
GIT_REPOSITORY ${GIT_REPO}
GIT_TAG ${GIT_TAG}
Expand Down
1 change: 1 addition & 0 deletions third-party/gtest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set(GIT_TAG v1.14.0)
set(TARGET_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/third-party/${TARGET_NAME}-src)
set(TARGET_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/third-party/${TARGET_NAME})
ExternalProject_Add(${TARGET_NAME}_internal
SOURCE_DIR ${THIRD_PARTY_SRC_DIR}/${TARGET_NAME}_src
PREFIX ${TARGET_PREFIX}
GIT_REPOSITORY ${GIT_REPO}
GIT_TAG ${GIT_TAG}
Expand Down
1 change: 1 addition & 0 deletions third-party/onetbb.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ set(GIT_TAG v2021.11.0)
set(TARGET_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/third-party/${TARGET_NAME}-src)
set(TARGET_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/third-party/${TARGET_NAME})
ExternalProject_Add(${TARGET_NAME}_internal
SOURCE_DIR ${THIRD_PARTY_SRC_DIR}/${TARGET_NAME}_src
PREFIX ${TARGET_PREFIX}
GIT_REPOSITORY ${GIT_REPO}
GIT_TAG ${GIT_TAG}
Expand Down
1 change: 1 addition & 0 deletions third-party/prometheus-cpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ set(GIT_TAG v1.1.0)
set(TARGET_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/third-party/${TARGET_NAME}-src)
set(TARGET_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/third-party/${TARGET_NAME})
ExternalProject_Add(${TARGET_NAME}_internal
SOURCE_DIR ${THIRD_PARTY_SRC_DIR}/${TARGET_NAME}_src
PREFIX ${TARGET_PREFIX}
GIT_REPOSITORY ${GIT_REPO}
GIT_TAG ${GIT_TAG}
Expand Down