From 4b9db0e26ebd145380db6fd1921dca90bcbc7a5d Mon Sep 17 00:00:00 2001 From: Tim Siebert Date: Mon, 18 Nov 2024 08:31:46 +0100 Subject: [PATCH 01/23] move test build to main cmake file --- ADOL-C/boost-test/CMakeLists.txt | 48 ++------------------------------ CMakeLists.txt | 7 +++++ 2 files changed, 10 insertions(+), 45 deletions(-) diff --git a/ADOL-C/boost-test/CMakeLists.txt b/ADOL-C/boost-test/CMakeLists.txt index bf23616c..6daa6f40 100644 --- a/ADOL-C/boost-test/CMakeLists.txt +++ b/ADOL-C/boost-test/CMakeLists.txt @@ -1,15 +1,7 @@ -cmake_minimum_required(VERSION 3.0) -project(boost-test-adolc CXX) - -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - -## BOOST set(3RDPARTY_BOOST_DIR "" CACHE PATH "The directory where BOOST library is installed") if(3RDPARTY_BOOST_DIR) set(BOOST_ROOT ${3RDPARTY_BOOST_DIR}) -# set(BOOST_INCLUDEDIR ${3RDPARTY_BOOST_DIR}/include) -# set(BOOST_LIBRARYDIR ${3RDPARTY_BOOST_DIR}/lib) endif() set(BOOST_MIN_VERSION "1.59.0") @@ -19,41 +11,8 @@ find_package(Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS unit_test_framework if(NOT Boost_FOUND) message(FATAL_ERROR "Fatal error: Boost (version >= 1.69.0) required.") -else() - message(STATUS "Setting up BOOST") - message(STATUS "Boost include: " ${Boost_INCLUDE_DIRS}) - message(STATUS "Boost library: " ${Boost_LIBRARY_DIRS}) endif() -## ADOL-C -set (ADOLC_BASE "" CACHE PATH "The directory where ADOL-C is installed") -if(ADOLC_BASE) - message(STATUS "Setting up ADOL-C") - - unset(ADOLC_INCLUDE_DIR CACHE) - find_path(ADOLC_INCLUDE_DIR NAMES adolc/adolc.h PATHS ${ADOLC_BASE}/include NO_DEFAULT_PATH) - if(NOT ADOLC_INCLUDE_DIR) - message(FATAL_ERROR "Fatal error: ADOL-C include directory not found, check if ADOLC_BASE path is correct") - endif() - - unset(ADOLC_LIBRARY CACHE) - find_library(ADOLC_LIBRARY NAMES adolc PATHS ${ADOLC_BASE}/lib64 ${ADOLC_BASE}/lib NO_DEFAULT_PATH) - if(NOT ADOLC_LIBRARY) - message(FATAL_ERROR "Fatal error: ADOL-C library not found, check if ADOLC_BASE path is correct") - endif() - - unset(ADOLC_LIBRARY_DIR CACHE) - get_filename_component(ADOLC_LIBRARY_DIR ${ADOLC_LIBRARY} DIRECTORY CACHE) - - message(STATUS "ADOL-C include: " ${ADOLC_INCLUDE_DIR}) - message(STATUS "ADOL-C library: " ${ADOLC_LIBRARY_DIR}) -else() - message(FATAL_ERROR "ADOLC_BASE directory has to be specified") -endif() - -include_directories(${Boost_INCLUDE_DIRS} ${ADOLC_INCLUDE_DIR}) -link_directories(${Boost_LIBRARY_DIRS} ${ADOLC_LIBRARY_DIR}) - set(SOURCE_FILES adouble.cpp main.cpp @@ -68,9 +27,8 @@ set(SOURCE_FILES traceFixedPointScalarTests.cpp ) add_executable(boost-test-adolc ${SOURCE_FILES}) - -target_link_libraries(boost-test-adolc - PRIVATE - ${ADOLC_LIBRARY} +target_include_directories(boost-test-adolc PRIVATE "${ADOLC_INCLUDE_DIR}") +target_link_libraries(boost-test-adolc PRIVATE + adolc Boost::system Boost::unit_test_framework) diff --git a/CMakeLists.txt b/CMakeLists.txt index 89d2f4a1..3794f997 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,6 +75,13 @@ if(BUILD_INTERFACE) DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/adolc) endif() +# build the tests +# ------------------------------------ +if(CMAKE_BUILD_TYPE STREQUAL "Tests") + set(ADOLC_INCLUDE_DIR "${CMAKE_BINARY_DIR}/ADOL-C/include") + add_subdirectory(ADOL-C/boost-test) +endif() + # export the targets # ------------------ From 1d879c5a7a2360141c9769d6b725630a1b52fc65 Mon Sep 17 00:00:00 2001 From: Tim Siebert Date: Mon, 18 Nov 2024 08:32:07 +0100 Subject: [PATCH 02/23] update workflow for new test build --- .github/workflows/tests.yml | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 542ad317..1fc4c2db 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,32 +11,26 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - - name: Configure CMake ADOL-C - run: > - cmake - -DCMAKE_CXX_COMPILER=g++ - -DCMAKE_C_COMPILER=gcc - -DCMAKE_BUILD_TYPE=Release - -S ${{ github.workspace }} - -DCMAKE_INSTALL_PREFIX=${{ github.workspace }} - - - name: Build ADOLC - run: | - make - make install - name: Install Boost shell: bash run: | sudo apt-get install libboost-all-dev - - name: Build and Run Boost-Test - shell: bash + - name: Configure and build ADOL-C run: | - cd ADOL-C/boost-test - mkdir build && cd build - cmake ../ -DADOLC_BASE=${{ github.workspace }} - make - ./boost-test-adolc + mkdir build + cd build + cmake \ + -DCMAKE_CXX_COMPILER=g++ \ + -DCMAKE_C_COMPILER=gcc \ + -DCMAKE_BUILD_TYPE=Tests \ + -S .. \ + -B . + cmake --build . + + - name: Run Tests + run: ./build/ADOL-C/boost-test/boost-test-adolc + + \ No newline at end of file From 271dbdcbfcdc7fcf91467ef2fbb75bf15ac0a412 Mon Sep 17 00:00:00 2001 From: Tim Siebert Date: Mon, 18 Nov 2024 08:43:15 +0100 Subject: [PATCH 03/23] enable ctest --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3794f997..9c024116 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,6 +80,12 @@ endif() if(CMAKE_BUILD_TYPE STREQUAL "Tests") set(ADOLC_INCLUDE_DIR "${CMAKE_BINARY_DIR}/ADOL-C/include") add_subdirectory(ADOL-C/boost-test) + + enable_testing() + add_test( + NAME boost-test-adolc + COMMAND boost-test-adolc + ) endif() # export the targets From 2037ca854bcd83e4e278142679e56f85c3d33ccb Mon Sep 17 00:00:00 2001 From: Tim Siebert Date: Mon, 18 Nov 2024 09:43:07 +0100 Subject: [PATCH 04/23] add coverage --- CMakeLists.txt | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c024116..91aff155 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,12 +82,26 @@ if(CMAKE_BUILD_TYPE STREQUAL "Tests") add_subdirectory(ADOL-C/boost-test) enable_testing() - add_test( - NAME boost-test-adolc - COMMAND boost-test-adolc - ) + add_test(NAME boost-test-adolc + COMMAND boost-test-adolc) endif() +# build the adolc and tests with coverage +# ------------------------------------ +if(CMAKE_BUILD_TYPE STREQUAL "TestsWithCov") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage -g") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage -g") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage") + + set(ADOLC_INCLUDE_DIR "${CMAKE_BINARY_DIR}/ADOL-C/include") + add_subdirectory(ADOL-C/boost-test) + + enable_testing() + add_test(NAME boost-test-adolc + COMMAND boost-test-adolc) +endif() + + # export the targets # ------------------ From 940e3e0f3cd297a9a38cba34c5c650a2589fb575 Mon Sep 17 00:00:00 2001 From: Tim Siebert Date: Mon, 18 Nov 2024 09:43:40 +0100 Subject: [PATCH 05/23] initial commit --- .github/workflows/coverage.yml | 42 ++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/coverage.yml diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 00000000..930a7d02 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,42 @@ +on: ["push", "pull_request"] + +name: Test Coveralls + +jobs: + + build: + name: Build + runs-on: ubuntu-latest + steps: + + - uses: actions/checkout@v4 + + - name: Install Boost + shell: bash + run: | + sudo apt-get install libboost-all-dev + + - name: Configure and build ADOL-C + run: | + mkdir build + cd build + cmake \ + -DCMAKE_CXX_COMPILER=g++ \ + -DCMAKE_C_COMPILER=gcc \ + -DCMAKE_BUILD_TYPE=TestsWithCov \ + -S .. \ + -B . + cmake --build . + + - name: Run Tests + run: ctest + + - name: Generate Coveralls Report + uses: threeal/gcovr-action@v1.1.0 + with: + coveralls-out: coveralls.json + + - name: Coveralls + uses: coverallsapp/github-action@v2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From 5addcc68a66bffb8a07f54f4b6adb6e3ee0ba458 Mon Sep 17 00:00:00 2001 From: Tim Siebert Date: Mon, 18 Nov 2024 09:49:32 +0100 Subject: [PATCH 06/23] fix test path --- .github/workflows/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 930a7d02..c1211aa2 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -29,7 +29,7 @@ jobs: cmake --build . - name: Run Tests - run: ctest + run: ctest --test-dir build/ - name: Generate Coveralls Report uses: threeal/gcovr-action@v1.1.0 From 3f231b3229c619a9cf2e3b7a1a45639328241509 Mon Sep 17 00:00:00 2001 From: Tim Siebert Date: Mon, 18 Nov 2024 09:50:58 +0100 Subject: [PATCH 07/23] update to ctest --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1fc4c2db..4f2e4370 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -30,7 +30,7 @@ jobs: cmake --build . - name: Run Tests - run: ./build/ADOL-C/boost-test/boost-test-adolc + run: ctest --test-dir build/ --output-on-failure \ No newline at end of file From 75b419befde711ae0b9cbd44de4cd78ce7ed6fe3 Mon Sep 17 00:00:00 2001 From: Tim Siebert Date: Mon, 18 Nov 2024 09:53:47 +0100 Subject: [PATCH 08/23] dont break when ctest finds errors --- .github/workflows/coverage.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index c1211aa2..f465e82f 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -29,7 +29,10 @@ jobs: cmake --build . - name: Run Tests - run: ctest --test-dir build/ + run: | + set +e + ctest --test-dir build/ + exit 0 - name: Generate Coveralls Report uses: threeal/gcovr-action@v1.1.0 From 5810f0d43f8d6c57efc7a9f4d6d9fb41a23ecb3b Mon Sep 17 00:00:00 2001 From: Tim Siebert Date: Mon, 18 Nov 2024 10:00:48 +0100 Subject: [PATCH 09/23] add comment --- .github/workflows/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index f465e82f..3aee8ee0 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -30,7 +30,7 @@ jobs: - name: Run Tests run: | - set +e + set +e # otherwise the coverage report fails if ctest finds errors ctest --test-dir build/ exit 0 From 0192e7b5d82194f13119bed2d56a6af873210261 Mon Sep 17 00:00:00 2001 From: Tim Siebert Date: Mon, 18 Nov 2024 10:15:51 +0100 Subject: [PATCH 10/23] add base path --- .github/workflows/coverage.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 3aee8ee0..b29139eb 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -42,4 +42,5 @@ jobs: - name: Coveralls uses: coverallsapp/github-action@v2 with: - github-token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + github-token: ${{ secrets.GITHUB_TOKEN }} + base-path: ${{github.workspace}} \ No newline at end of file From 74336e769010c0209d0b7f4984c9fdf5343c8ebc Mon Sep 17 00:00:00 2001 From: Tim Siebert Date: Mon, 18 Nov 2024 10:39:55 +0100 Subject: [PATCH 11/23] try codecov --- .github/workflows/coverage.yml | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index b29139eb..3b467e2e 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -33,14 +33,8 @@ jobs: set +e # otherwise the coverage report fails if ctest finds errors ctest --test-dir build/ exit 0 - - - name: Generate Coveralls Report - uses: threeal/gcovr-action@v1.1.0 - with: - coveralls-out: coveralls.json - - name: Coveralls - uses: coverallsapp/github-action@v2 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - base-path: ${{github.workspace}} \ No newline at end of file + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file From 725d182ff837ec89a5a0598d6dcf00d0075e4879 Mon Sep 17 00:00:00 2001 From: Tim Siebert Date: Mon, 18 Nov 2024 10:56:56 +0100 Subject: [PATCH 12/23] change to lcov --- CMakeLists.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 91aff155..a08e905f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,9 +89,8 @@ endif() # build the adolc and tests with coverage # ------------------------------------ if(CMAKE_BUILD_TYPE STREQUAL "TestsWithCov") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage -g") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage -g") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g --coverage") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g --coverage") set(ADOLC_INCLUDE_DIR "${CMAKE_BINARY_DIR}/ADOL-C/include") add_subdirectory(ADOL-C/boost-test) From 6143c3c45362a60b495777c16b647cc4525bafb4 Mon Sep 17 00:00:00 2001 From: Tim Siebert Date: Mon, 18 Nov 2024 11:01:37 +0100 Subject: [PATCH 13/23] change to lcov --- .github/workflows/coverage.yml | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 3b467e2e..de6641db 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -1,6 +1,6 @@ on: ["push", "pull_request"] -name: Test Coveralls +name: Test Coverage jobs: @@ -11,6 +11,11 @@ jobs: - uses: actions/checkout@v4 + - name: Install lcov + run: | + sudo apt-get update + sudo apt-get install -y lcov + - name: Install Boost shell: bash run: | @@ -34,7 +39,19 @@ jobs: ctest --test-dir build/ exit 0 + # Capture coverage data + - name: Generate coverage report + run: | + cd build + lcov --capture --directory . --output-file coverage.info + lcov --list coverage.info + + # Upload coverage report to Codecov - name: Upload coverage to Codecov uses: codecov/codecov-action@v4 - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file + with: + files: build/coverage.info + token: ${{ secrets.CODECOV_TOKEN }} + flags: unittests + name: code-coverage-report + \ No newline at end of file From c05036892152b9870e09ad5a1e8c7ce7db288178 Mon Sep 17 00:00:00 2001 From: Tim Siebert Date: Mon, 18 Nov 2024 11:12:03 +0100 Subject: [PATCH 14/23] remove unnecessary coveraged files --- .github/workflows/coverage.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index de6641db..e8d75228 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -44,6 +44,7 @@ jobs: run: | cd build lcov --capture --directory . --output-file coverage.info + lcov --remove coverage.info '/usr/*' 'boost/*' 'c++11/*' --output-file coverage.info lcov --list coverage.info # Upload coverage report to Codecov From b57640a6b7db776f5b527e34e74d4b10240935f4 Mon Sep 17 00:00:00 2001 From: Tim Siebert Date: Mon, 18 Nov 2024 11:47:18 +0100 Subject: [PATCH 15/23] update describtion for building tests --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bd7c2961..d01211f0 100644 --- a/README.md +++ b/README.md @@ -114,8 +114,12 @@ Please refer to the file `MSMSVisualStudio/v14/Readme_VC++.txt` for building the ## Unit tests -ADOL-C provides more than 400 unit tests to verify its basic functionality. -For more information on how to run the tests, please check the `README` file in `ADOL-C/boost-test` directory. +ADOL-C provides more than 500 unit tests to verify its basic functionality. +You can build and run them as follows: +`mkdir build && cd build` +`cmake -S .. -B . -DCMAKE_BUILD_TYPE=Tests` +`make` +`./ADOL-C/boost-test/boost-test-adolc` Enjoy this new version! From 5fde64d27aadabd1d3d4be5e893880fbfa823b66 Mon Sep 17 00:00:00 2001 From: Tim Siebert Date: Mon, 18 Nov 2024 11:55:02 +0100 Subject: [PATCH 16/23] add information from boost-test readme --- ADOL-C/boost-test/README.md | 22 ---------------------- README.md | 8 +++++--- 2 files changed, 5 insertions(+), 25 deletions(-) delete mode 100644 ADOL-C/boost-test/README.md diff --git a/ADOL-C/boost-test/README.md b/ADOL-C/boost-test/README.md deleted file mode 100644 index 63ac50aa..00000000 --- a/ADOL-C/boost-test/README.md +++ /dev/null @@ -1,22 +0,0 @@ -ADOL-C offers a unit-testing capability developed using the Boost.Test library. -There are more than 400 tests to verify the basic functionality of ADOL-C, including both traceless and trace-based adouble variants. - -The minimum required version of BOOST library is 1.59.0. Any older version will cause compile-time errors. -Building the ADOL-C teste requires the BOOST libraries `unit_test_framework` and `system`. -In case you are compiling BOOST on your own, be sure to add the flags `--with-test` and `--with-system` -to activate the corresponding modules. - -Instructions for compiling and running the test suite with cmake: - -1) Create the `build` directory inside the boost-test directory (it is ignored by git). - -2) In `boost-test/build` type: `cmake .. -DADOLC_BASE=[location of installed ADOL-C]` or `cmake-gui ..`. - Remember to specify `ADOLC_BASE` manually when using `cmake-gui`. - -3) Cmake will search for the system installed version of BOOST. If the minimum required version is not satisfied, please enter the path where an appropriate BOOST version is installed in `3RDPARTY_BOOST_DIR`. - -4) Notice that ADOL-C has to be compiled with the same version of BOOST defined in 3). When using a different BOOST version than the one provided by the operating system, ADOL-C can be configured with `--with-boost` flag before compiling the ADOL-C sources. - -5) After the Cmake configuration was successful, compile the test (e.g. using `make`). - -6) Run the executable `./boost-test-adolc`. diff --git a/README.md b/README.md index d01211f0..1972fdf7 100644 --- a/README.md +++ b/README.md @@ -114,12 +114,14 @@ Please refer to the file `MSMSVisualStudio/v14/Readme_VC++.txt` for building the ## Unit tests -ADOL-C provides more than 500 unit tests to verify its basic functionality. -You can build and run them as follows: +ADOL-C provides more than 500 unit tests to verify its basic functionality including both traceless and trace-based adouble variants. The tests are based on BOOST (version >= 1.59.0). Building the ADOL-C teste requires the BOOST libraries `unit_test_framework` and `system`. In case you are compiling BOOST on your own, be sure to add the flags `--with-test` and `--with-system` to activate the corresponding modules. +You can build and run them as follows: `mkdir build && cd build` `cmake -S .. -B . -DCMAKE_BUILD_TYPE=Tests` `make` `./ADOL-C/boost-test/boost-test-adolc` -Enjoy this new version! +Cmake will search for the system installed version of BOOST. If the minimum required version is not satisfied, please enter the path where an appropriate BOOST version is installed in `3RDPARTY_BOOST_DIR` in the `CMakelists.txt` inside the `boost-test` folder. Notice that ADOL-C has to be compiled with the same version of BOOST as used here. When using a different BOOST version than the one provided by the operating system, ADOL-C can be configured with `--with-boost` flag before compiling the ADOL-C sources. + +Enjoy this new version! \ No newline at end of file From 4df3d7fdcd1b8bf78a615ec8e28ac524d1987fb8 Mon Sep 17 00:00:00 2001 From: Tim Siebert Date: Tue, 19 Nov 2024 07:07:07 +0100 Subject: [PATCH 17/23] rm release flags since they are default, change test and cov build to options --- CMakeLists.txt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a08e905f..3beaf3cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,9 +6,6 @@ project(adol-c DESCRIPTION "A Package for Automatic Differentiation of Algorithms Written in C/C++" HOMEPAGE_URL "https://github.com/coin-or/ADOL-C") -set(CMAKE_C_FLAGS_RELEASE "-O3") -set(CMAKE_CXX_FLAGS_RELEASE "-O3") - add_library(adolc SHARED) add_library(adolc::adolc ALIAS adolc) @@ -77,7 +74,8 @@ endif() # build the tests # ------------------------------------ -if(CMAKE_BUILD_TYPE STREQUAL "Tests") +option(BUILD_TESTS OFF) +if(BUILD_TESTS) set(ADOLC_INCLUDE_DIR "${CMAKE_BINARY_DIR}/ADOL-C/include") add_subdirectory(ADOL-C/boost-test) @@ -88,7 +86,8 @@ endif() # build the adolc and tests with coverage # ------------------------------------ -if(CMAKE_BUILD_TYPE STREQUAL "TestsWithCov") +option(BUILD_TESTS_WITH_COV OFF) +if(BUILD_TESTS_WITH_COV) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g --coverage") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g --coverage") From ba31df9059512a09ceb3f8a7007f963ead63c2b9 Mon Sep 17 00:00:00 2001 From: Tim Siebert Date: Tue, 19 Nov 2024 07:15:24 +0100 Subject: [PATCH 18/23] combine tests and build --- .github/workflows/ci.yml | 86 ++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 47 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5d888427..847a898b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,52 +1,44 @@ -# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform. -# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml -name: Build Multi-Platform -on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] - -jobs: - build: - runs-on: ${{ matrix.os }} - strategy: - # Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable. - fail-fast: false - - # Set up a matrix to run the following 3 configurations: - # 1. - # 2. - # 3. - matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - build_type: [Release] - c_compiler: [gcc, clang] - cpp_compiler: [g++, clang++] +name: Run Tests +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] - steps: - - uses: actions/checkout@v4 +jobs: + build-and-test: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + build_type: [Release, Debug] + c_compiler: [gcc, clang] + cpp_compiler: [g++, clang++] + steps: + - uses: actions/checkout@v4 + + - name: Install Boost + shell: bash + run: | + sudo apt-get install libboost-all-dev - - name: Set reusable strings - # Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file. - id: strings - shell: bash - run: | - echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" + - name: Configure and build ADOL-C + run: | + mkdir build + cd build + cmake \ + -DCMAKE_CXX_COMPILER= ${{ matrix.cpp_compiler}} \ + -DCMAKE_C_COMPILER= ${{ matrix.c_compiler}} \ + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ + -DBUILD_TESTS=ON \ + -S .. \ + -B . + cmake --build . + + - name: Run Tests + run: ctest --test-dir build/ --output-on-failure - - name: Configure CMake - # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. - # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type - run: > - cmake -B ${{ steps.strings.outputs.build-output-dir }} - -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} - -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} - -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} - -S ${{ github.workspace }} - - name: Build - # Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). - run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} - - \ No newline at end of file + \ No newline at end of file From 02984c883e09761524028f76b1e6d332eb839d5d Mon Sep 17 00:00:00 2001 From: Tim Siebert Date: Tue, 19 Nov 2024 07:23:52 +0100 Subject: [PATCH 19/23] split test and ci again --- .github/workflows/ci.yml | 11 ++--------- .github/workflows/tests.yml | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 847a898b..d16cdbec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,5 @@ -name: Run Tests +name: Build on: push: branches: [ "master" ] @@ -7,7 +7,7 @@ on: branches: [ "master" ] jobs: - build-and-test: + build: runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -19,11 +19,6 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Install Boost - shell: bash - run: | - sudo apt-get install libboost-all-dev - - name: Configure and build ADOL-C run: | mkdir build @@ -37,8 +32,6 @@ jobs: -B . cmake --build . - - name: Run Tests - run: ctest --test-dir build/ --output-on-failure \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4f2e4370..158746cb 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,8 +7,15 @@ on: branches: [ "master" ] jobs: - run-tests: + run-tests: runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + build_type: [Release, Debug] + c_compiler: [gcc, clang] + cpp_compiler: [g++, clang++] + steps: - uses: actions/checkout@v4 @@ -22,9 +29,10 @@ jobs: mkdir build cd build cmake \ - -DCMAKE_CXX_COMPILER=g++ \ - -DCMAKE_C_COMPILER=gcc \ - -DCMAKE_BUILD_TYPE=Tests \ + -DCMAKE_CXX_COMPILER= ${{ matrix.cpp_compiler}} \ + -DCMAKE_C_COMPILER= ${{ matrix.c_compiler}} \ + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ + -DBUILD_TESTS=ON \ -S .. \ -B . cmake --build . From c68744749b31254cd64197596731ba6f32e9cbc9 Mon Sep 17 00:00:00 2001 From: Tim Siebert Date: Tue, 19 Nov 2024 07:33:13 +0100 Subject: [PATCH 20/23] change run mode and add build path --- .github/workflows/ci.yml | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d16cdbec..3d6c9fe8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,19 +19,26 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Configure and build ADOL-C + - name: Set reusable strings + # Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file. + id: strings + shell: bash run: | - mkdir build - cd build - cmake \ - -DCMAKE_CXX_COMPILER= ${{ matrix.cpp_compiler}} \ - -DCMAKE_C_COMPILER= ${{ matrix.c_compiler}} \ - -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ - -DBUILD_TESTS=ON \ - -S .. \ - -B . - cmake --build . - + echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" + + - name: Configure and build ADOL-C + run: > + cmake -B ${{ steps.strings.outputs.build-output-dir }} + -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} + -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + -S ${{ github.workspace }} + + - name: Build + # Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). + run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} + + \ No newline at end of file From d2d4ad71835f387a79b6666cba7659f143072245 Mon Sep 17 00:00:00 2001 From: Tim Siebert Date: Tue, 19 Nov 2024 07:35:48 +0100 Subject: [PATCH 21/23] add reusable strings --- .github/workflows/tests.yml | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 158746cb..4a5266d1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -24,21 +24,28 @@ jobs: run: | sudo apt-get install libboost-all-dev + - name: Set reusable strings + # Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file. + id: strings + shell: bash + run: | + echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" + - name: Configure and build ADOL-C - run: | - mkdir build - cd build - cmake \ - -DCMAKE_CXX_COMPILER= ${{ matrix.cpp_compiler}} \ - -DCMAKE_C_COMPILER= ${{ matrix.c_compiler}} \ - -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ + run: > + cmake -B ${{ steps.strings.outputs.build-output-dir }} + -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} + -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DBUILD_TESTS=ON \ - -S .. \ - -B . - cmake --build . - + -S ${{ github.workspace }} + + - name: Build + # Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). + run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} + - name: Run Tests - run: ctest --test-dir build/ --output-on-failure + run: ctest --test-dir ${{ steps.strings.outputs.build-output-dir }} --output-on-failure \ No newline at end of file From e48284760672a96c2ce0fbba65592d4fe5d081b4 Mon Sep 17 00:00:00 2001 From: Tim Siebert Date: Tue, 19 Nov 2024 07:37:35 +0100 Subject: [PATCH 22/23] change cmake args --- .github/workflows/coverage.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index e8d75228..f45de46a 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -28,7 +28,8 @@ jobs: cmake \ -DCMAKE_CXX_COMPILER=g++ \ -DCMAKE_C_COMPILER=gcc \ - -DCMAKE_BUILD_TYPE=TestsWithCov \ + -DCMAKE_BUILD_TYPE=Debug \ + -DBUILD_TESTS_WITH_COV=ON \ -S .. \ -B . cmake --build . From 0645eaed1405602554e97fb1585625e196d24cbe Mon Sep 17 00:00:00 2001 From: Tim Siebert Date: Tue, 19 Nov 2024 07:41:42 +0100 Subject: [PATCH 23/23] format --- .github/workflows/coverage.yml | 3 +- .github/workflows/tests.yml | 82 +++++++++++++++++----------------- 2 files changed, 42 insertions(+), 43 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index f45de46a..2d0f6394 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -3,8 +3,7 @@ on: ["push", "pull_request"] name: Test Coverage jobs: - - build: + run-coverage: name: Build runs-on: ubuntu-latest steps: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4a5266d1..4f455e86 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,45 +7,45 @@ on: branches: [ "master" ] jobs: - run-tests: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - build_type: [Release, Debug] - c_compiler: [gcc, clang] - cpp_compiler: [g++, clang++] - - steps: - - uses: actions/checkout@v4 + run-tests: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + build_type: [Release, Debug] + c_compiler: [gcc, clang] + cpp_compiler: [g++, clang++] + + steps: + - uses: actions/checkout@v4 + + - name: Install Boost + shell: bash + run: | + sudo apt-get install libboost-all-dev + + - name: Set reusable strings + # Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file. + id: strings + shell: bash + run: | + echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" + + - name: Configure and build ADOL-C + run: > + cmake -B ${{ steps.strings.outputs.build-output-dir }} + -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} + -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + -DBUILD_TESTS=ON \ + -S ${{ github.workspace }} + + - name: Build ADOL-C + # Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). + run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} - - name: Install Boost - shell: bash - run: | - sudo apt-get install libboost-all-dev - - - name: Set reusable strings - # Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file. - id: strings - shell: bash - run: | - echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" - - - name: Configure and build ADOL-C - run: > - cmake -B ${{ steps.strings.outputs.build-output-dir }} - -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} - -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} - -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} - -DBUILD_TESTS=ON \ - -S ${{ github.workspace }} - - - name: Build - # Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). - run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} - - - name: Run Tests - run: ctest --test-dir ${{ steps.strings.outputs.build-output-dir }} --output-on-failure - - - \ No newline at end of file + - name: Run Tests + run: ctest --test-dir ${{ steps.strings.outputs.build-output-dir }} --output-on-failure + + + \ No newline at end of file