Skip to content

Commit

Permalink
[INFRA] Simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
eseiler committed Mar 11, 2024
1 parent 2d6439a commit 2464270
Show file tree
Hide file tree
Showing 20 changed files with 103 additions and 326 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/ci_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ jobs:
include:
- name: "gcc13"
compiler: "gcc-13"
build: coverage
build_type: Coverage

steps:
# How many commits do we need to fetch to also fetch the branch point?
Expand All @@ -56,7 +54,7 @@ jobs:
- name: Install CMake
uses: seqan/actions/setup-cmake@main
with:
cmake: 3.21.7
cmake: 3.25.3

- name: Install gcovr
run: |
Expand All @@ -67,12 +65,14 @@ jobs:
run: |
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
cmake .. -DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_FLAGS="--coverage -fprofile-arcs -ftest-coverage" \
-DCMAKE_C_FLAGS="--coverage -fprofile-arcs -ftest-coverage" \
-DCMAKE_EXE_LINKER_FLAGS="-Wl,-lgcov" \
-DCMAKE_SHARED_LINKER_FLAGS="-Wl,-lgcov"
make -j2 -k gtest_main yaml-cpp
- name: Build tests
env:
CCACHE_IGNOREOPTIONS: "-fprofile-abs-path"
run: |
ccache -z
cd build
Expand All @@ -82,7 +82,7 @@ jobs:
- name: Generate coverage report
run: |
gcovr --gcov-executable ${{ github.workspace }}/.github/workflows/scripts/gcov.sh \
--root ${{ github.workspace }}/test/coverage \
--root ${{ github.workspace }}/test \
${{ github.workspace }}/build \
--filter ${{ github.workspace }}/include \
--filter ${{ github.workspace }}/src \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_license.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
check:
name: REUSE Compliance
runs-on: ubuntu-22.04
timeout-minutes: 120
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
- name: Install CMake
uses: seqan/actions/setup-cmake@main
with:
cmake: 3.21.7
cmake: 3.25.3

- name: Configure
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
- name: Install CMake
uses: seqan/actions/setup-cmake@main
with:
cmake: 3.21.7
cmake: 3.25.3

- name: Configure
run: |
Expand Down
50 changes: 19 additions & 31 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,9 @@

cmake_minimum_required (VERSION 3.16)

## CUSTOMISE

# Define the application name and version.
project (app-template VERSION 1.0.0)

# Needed for CPM
find_package (Git REQUIRED)

## BUILD

# Make Release default build type
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE
Release
CACHE STRING "Choose the type of build, options are: Debug Release Coverage RelWithDebInfo MinSizeRel." FORCE
)
endif ()

# Specify the directories where to store the built archives, libraries and executables
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")

# Messages
string (ASCII 27 Esc)
set (FontBold "${Esc}[1m")
set (FontReset "${Esc}[m")

# Allow to include CMake scripts from the app-template.
list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")

Expand All @@ -42,16 +17,29 @@ require_ccache ()
# Add packages.
set (CPM_INDENT " CMake Package Manager CPM: ")
include (CPM)
include (CPMGetSystemPackage)
CPMUsePackageLock (${CMAKE_CURRENT_LIST_DIR}/cmake/package-lock.cmake)

CPMGetSystemPackage (hibf)
CPMGetSystemPackage (sharg)
CPMGetSystemPackage (seqan3)
CPMGetPackage (hibf)
CPMGetPackage (sharg)
CPMGetPackage (seqan3)

# Add the application.
add_subdirectory (src)
message (STATUS "${FontBold}You can run `make` to build the application.${FontReset}")
# A interface to reuse common properties.
# You can add more external include paths of other projects that are needed for your project.
add_library ("${PROJECT_NAME}_interface" INTERFACE)
target_link_libraries ("${PROJECT_NAME}_interface" INTERFACE seqan3::seqan3)
target_link_libraries ("${PROJECT_NAME}_interface" INTERFACE sharg::sharg)
target_link_libraries ("${PROJECT_NAME}_interface" INTERFACE seqan::hibf)
target_include_directories ("${PROJECT_NAME}_interface" INTERFACE "include")
target_compile_options ("${PROJECT_NAME}_interface" INTERFACE "-pedantic" "-Wall" "-Wextra")

# An object library (without main) to be used in multiple targets.
add_library ("${PROJECT_NAME}_lib" STATIC src/fastq_conversion.cpp)
target_link_libraries ("${PROJECT_NAME}_lib" PUBLIC "${PROJECT_NAME}_interface")

add_executable ("${PROJECT_NAME}" src/main.cpp)
target_link_libraries ("${PROJECT_NAME}" PRIVATE "${PROJECT_NAME}_lib")


## TEST
option (${PROJECT_NAME}_TEST "Enable testing for ${PROJECT_NAME}." ON)
Expand Down
30 changes: 0 additions & 30 deletions cmake/CPMGetSystemPackage.cmake

This file was deleted.

File renamed without changes.
63 changes: 63 additions & 0 deletions cmake/test_config.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
# SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
# SPDX-License-Identifier: CC0-1.0

# Add googletest.
CPMGetPackage (googletest)
include (GoogleTest OPTIONAL)

# Set directories for test output files, input data and binaries.
file (MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/output)
add_definitions (-DOUTPUTDIR=\"${CMAKE_CURRENT_BINARY_DIR}/output/\")
add_definitions (-DDATADIR=\"${CMAKE_CURRENT_BINARY_DIR}/data/\")
add_definitions (-DBINDIR=\"${CMAKE_CURRENT_BINARY_DIR}/../\")
add_definitions (-DAPPNAME=\"${PROJECT_NAME}\")

# # Test executables and libraries should not mix with the application files.
# # This must happen after setting the output directories.
# unset (CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
# unset (CMAKE_LIBRARY_OUTPUT_DIRECTORY)
# unset (CMAKE_RUNTIME_OUTPUT_DIRECTORY)

# Add the test interface library.
if (NOT TARGET ${PROJECT_NAME}_test)
add_library (${PROJECT_NAME}_test INTERFACE)
target_compile_options (${PROJECT_NAME}_test INTERFACE "-pedantic" "-Wall" "-Wextra" "-Werror")

# GCC12 and above: Disable warning about std::hardware_destructive_interference_size not being ABI-stable.
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 12)
target_compile_options (${PROJECT_NAME}_test INTERFACE "-Wno-interference-size")
endif ()
endif ()

# GCC12 has some bogus warnings. They will not be fixed in googletest.
# https://github.com/google/googletest/issues/4232
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 12 AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13)
target_compile_options (${PROJECT_NAME}_test INTERFACE "-Wno-restrict")
endif ()
endif ()

target_link_libraries (${PROJECT_NAME}_test INTERFACE "${PROJECT_NAME}_lib" "GTest::gtest_main")
add_library (${PROJECT_NAME}::test ALIAS ${PROJECT_NAME}_test)
endif ()

# Add the check target that builds and runs tests.
add_custom_target (check COMMAND ${CMAKE_CTEST_COMMAND} ${CMAKE_CTEST_ARGUMENTS})

macro (add_app_test test_filename)
file (RELATIVE_PATH source_file "${CMAKE_SOURCE_DIR}" "${CMAKE_CURRENT_LIST_DIR}/${test_filename}")
get_filename_component (target "${source_file}" NAME_WE)

add_executable (${target} ${test_filename})
target_link_libraries (${target} ${PROJECT_NAME}::test)

add_dependencies (${target} ${PROJECT_NAME})
add_dependencies (check ${target})

add_test (NAME ${target} COMMAND ${target})

unset (source_file)
unset (target)
endmacro ()
21 changes: 0 additions & 21 deletions src/CMakeLists.txt

This file was deleted.

83 changes: 6 additions & 77 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,83 +4,12 @@

cmake_minimum_required (VERSION 3.16)

# Add googletest.
CPMGetSystemPackage (googletest)
include (GoogleTest OPTIONAL)

# Allow to include CMake scripts from seqan3.
list (APPEND CMAKE_MODULE_PATH "${seqan3_SOURCE_DIR}/test/cmake/")
# Allow to include CMake scripts from the app-template.
list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/")

# Set directories for test output files, input data and binaries.
file (MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/output)
add_definitions (-DOUTPUTDIR=\"${CMAKE_CURRENT_BINARY_DIR}/output/\")
add_definitions (-DDATADIR=\"${CMAKE_CURRENT_BINARY_DIR}/data/\")
add_definitions (-DBINDIR=\"${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/\")
add_definitions (-DAPPNAME=\"${PROJECT_NAME}\")

# Test executables and libraries should not mix with the application files.
# This must happen after setting the output directories.
unset (CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
unset (CMAKE_LIBRARY_OUTPUT_DIRECTORY)
unset (CMAKE_RUNTIME_OUTPUT_DIRECTORY)

# Add the test interface library.
if (NOT TARGET ${PROJECT_NAME}_test)
add_library (${PROJECT_NAME}_test INTERFACE)
target_compile_options (${PROJECT_NAME}_test INTERFACE "-pedantic" "-Wall" "-Wextra" "-Werror")

# GCC12 and above: Disable warning about std::hardware_destructive_interference_size not being ABI-stable.
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 12)
target_compile_options (${PROJECT_NAME}_test INTERFACE "-Wno-interference-size")
endif ()
endif ()

# GCC12 has some bogus warnings. They will not be fixed in googletest.
# https://github.com/google/googletest/issues/4232
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 12 AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13)
target_compile_options (${PROJECT_NAME}_test INTERFACE "-Wno-restrict")
endif ()
endif ()

target_link_libraries (${PROJECT_NAME}_test INTERFACE "${PROJECT_NAME}_lib" "GTest::gtest_main")
target_include_directories (${PROJECT_NAME}_test INTERFACE "${seqan3_SOURCE_DIR}/test/include")
add_library (${PROJECT_NAME}::test ALIAS ${PROJECT_NAME}_test)
endif ()

# Add the check target that builds and runs tests.
add_custom_target (check COMMAND ${CMAKE_CTEST_COMMAND} ${CMAKE_CTEST_ARGUMENTS})

include (seqan3_test_component)
# A macro that adds an api or cli test.
macro (add_app_test test_filename)
# Extract the test target name.
file (RELATIVE_PATH source_file "${CMAKE_SOURCE_DIR}" "${CMAKE_CURRENT_LIST_DIR}/${test_filename}")
seqan3_test_component (target "${source_file}" TARGET_NAME)
seqan3_test_component (test_name "${source_file}" TEST_NAME)

# Create the test target.
add_executable (${target} ${test_filename})
target_link_libraries (${target} ${PROJECT_NAME}::test)
add_dependencies (${target} ${PROJECT_NAME})
add_dependencies (check ${target})

# Generate and set the test name.
add_test (NAME "${test_name}" COMMAND ${target})
include (test_config)
include (data/datasources.cmake)

unset (source_file)
unset (target)
unset (test_name)
endmacro ()
message (STATUS "You can run `make check` to build and run tests.")

# Fetch data and add the tests.
include (data/datasources.cmake)
add_subdirectory (api)
add_subdirectory (cli)
add_subdirectory (header)
add_subdirectory (coverage)
add_app_test (api_fastq_coversion_test.cpp)
add_app_test (cli_fastq_coversion_test.cpp)

message (STATUS "${FontBold}You can run `make check` to build and run tests.${FontReset}")
target_use_datasources (check FILES in.fastq out.fasta)
9 changes: 0 additions & 9 deletions test/api/CMakeLists.txt

This file was deleted.

12 changes: 0 additions & 12 deletions test/api/README.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

#include <gtest/gtest.h>

#include "../app_test.hpp"
#include "fastq_conversion.hpp"
#include <fastq_conversion.hpp>

#include "app_test.hpp"

// To prevent issues when running multiple API tests in parallel, give each API test unique names:
struct fastq_to_fasta : public app_test
Expand Down
9 changes: 0 additions & 9 deletions test/cli/CMakeLists.txt

This file was deleted.

Loading

0 comments on commit 2464270

Please sign in to comment.