Skip to content

Commit

Permalink
Migrate regular CircleCI builds to CTest (#687)
Browse files Browse the repository at this point in the history
Migrate regular CircleCI builds to CTest
  • Loading branch information
kylef authored May 7, 2019
2 parents 23a7e5d + 4a1caf6 commit d2fd66b
Show file tree
Hide file tree
Showing 12 changed files with 205 additions and 170 deletions.
189 changes: 131 additions & 58 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
version: 2

aliases:
- &test-base
- &test-base-legacy
working_directory: /tmp/drafter
environment:
CXXFLAGS: '-Werror -Wno-error=unused-function'

steps:
- checkout
- run: git submodule update --init --recursive
Expand All @@ -18,43 +17,74 @@ aliases:
name: Test
command: make test -j4

- &test-clang-base
<<: *test-base
environment:
CXXFLAGS: '-Werror -Wno-error=unused-function -Wno-error=missing-braces'
- &test-base
working_directory: /tmp/drafter

- &tag-filter
filters:
tags:
only: /^v.*/

- &clang-debug
run:
name: Build drafter/debug with clang
command: |
ctest -VV -j4 -S cmake/unix.cmake -DCTEST_BUILD_TYPE=Debug -DCTEST_BUILD_NAME="clang $(c++ -dumpversion)"
- &clang-release
run:
name: Build drafter/release with clang
command: |
ctest -VV -j4 -S cmake/unix.cmake -DCTEST_BUILD_TYPE=Release -DCTEST_BUILD_NAME="clang $(c++ -dumpversion)"
- &gcc-debug
run:
name: Build drafter/debug with gcc
command: |
ctest -VV -j4 -S cmake/unix.cmake -DCTEST_BUILD_TYPE=Debug -DCTEST_BUILD_NAME="gcc $(c++ -dumpversion)"
- &gcc-release
run:
name: Build drafter/release with gcc
command: |
ctest -VV -j4 -S cmake/unix.cmake -DCTEST_BUILD_TYPE=Release -DCTEST_BUILD_NAME="gcc $(c++ -dumpversion)"
- &update-submodules
run:
name: Update submodules
command: 'git submodule update --init --recursive'

workflows:
version: 2

drafter:
jobs:
- lint
- test-gcc5.4: *tag-filter
- test-gcc6: *tag-filter
- test-gcc7: *tag-filter
#- test-gcc8: *tag-filter
- test-clang4: *tag-filter
- test-clang5: *tag-filter
- test-clang6: *tag-filter
- test-xcode9: *tag-filter
- test-integration: *tag-filter
- test-gcc-49-debug: *tag-filter
- test-gcc-49-release: *tag-filter
- test-gcc-latest-debug: *tag-filter
- test-gcc-latest-release: *tag-filter
- test-clang-4-debug: *tag-filter
- test-clang-4-release: *tag-filter
- test-clang-latest-debug: *tag-filter
- test-clang-latest-release: *tag-filter
- test-osx-release: *tag-filter
- test-osx-debug: *tag-filter
- test-gyp: *tag-filter
- test-valgrind: *tag-filter
- release:
requires:
- test-gcc5.4
- test-gcc6
- test-gcc7
#- test-gcc8
- test-clang4
- test-clang5
- test-clang6
- test-xcode9
- test-integration
- test-gcc-49-debug
- test-gcc-49-release
- test-gcc-latest-debug
- test-gcc-latest-release
- test-clang-4-debug
- test-clang-4-release
- test-clang-latest-debug
- test-clang-latest-release
- test-osx-release
- test-osx-debug
- test-gyp
- test-valgrind
filters:
tags:
Expand All @@ -72,65 +102,107 @@ jobs:
- run: git submodule update --init --recursive
- run: ./tools/clang-format-check.sh

test-gcc5.4:
<<: *test-base
test-gyp:
<<: *test-base-legacy
docker:
- image: gcc:5.4

test-gcc6:
test-gcc-49-debug:
<<: *test-base
steps:
- checkout
- <<: *update-submodules
- <<: *gcc-debug
docker:
- image: gcc:6
- image: apiaryio/drafter-ci:gcc-4.9

test-gcc7:
test-gcc-49-release:
<<: *test-base
steps:
- checkout
- <<: *update-submodules
- <<: *gcc-release
docker:
- image: gcc:7
- image: apiaryio/drafter-ci:gcc-4.9

test-gcc8:
test-gcc-latest-debug:
<<: *test-base
steps:
- checkout
- <<: *update-submodules
- <<: *gcc-debug
docker:
- image: gcc:8
- image: apiaryio/drafter-ci:gcc-latest

test-clang4:
<<: *test-clang-base
test-gcc-latest-release:
<<: *test-base
steps:
- checkout
- <<: *update-submodules
- <<: *gcc-release
docker:
- image: apiaryio/clang:4
- image: apiaryio/drafter-ci:gcc-latest

test-clang5:
<<: *test-clang-base
test-clang-4-debug:
<<: *test-base
steps:
- checkout
- <<: *update-submodules
- <<: *clang-debug
docker:
- image: apiaryio/clang:5
- image: apiaryio/drafter-ci:clang-4.0

test-clang6:
<<: *test-clang-base
test-clang-4-release:
<<: *test-base
steps:
- checkout
- <<: *update-submodules
- <<: *clang-release
docker:
- image: apiaryio/clang:6

test-xcode9:
<<: *test-clang-base
macos:
xcode: "9.4.0"
- image: apiaryio/drafter-ci:clang-4.0

test-integration:
test-clang-latest-debug:
<<: *test-base
steps:
- checkout
- <<: *update-submodules
- <<: *clang-debug
docker:
- image: circleci/ruby:2.5.1
working_directory: /tmp/drafter
- image: apiaryio/drafter-ci:clang-latest

test-clang-latest-release:
<<: *test-base
steps:
- checkout
- run: git submodule update --init --recursive
- <<: *update-submodules
- <<: *clang-release
docker:
- image: apiaryio/drafter-ci:clang-latest

- run:
name: Build
command: ./configure && make -j4
test-osx-debug:
<<: *test-base
steps:
- checkout
- <<: *update-submodules
- run: sudo bundle install
- run: brew install cmake
- <<: *clang-debug
macos:
xcode: "9.4.0"

- run:
name: Integration Test
command: bundle install && bundle exec cucumber
test-osx-release:
<<: *test-base
steps:
- checkout
- <<: *update-submodules
- run: sudo bundle install
- run: brew install cmake
- <<: *clang-release
macos:
xcode: "9.4.0"

test-valgrind:
<<: *test-base
<<: *test-base-legacy
docker:
- image: gcc:7

Expand Down Expand Up @@ -163,5 +235,6 @@ jobs:

steps:
- checkout
- run: git submodule update --init --recursive
- <<: *update-submodules
- run: ./tools/release.sh

6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.4 FATAL_ERROR)
cmake_minimum_required(VERSION 3.6 FATAL_ERROR)

message(STATUS "Testing dependencies ${BUILD_TESTING_DEPENDENCIES}.")

Expand Down Expand Up @@ -28,12 +28,12 @@ add_subdirectory(ext/boost_1_66_0 EXCLUDE_FROM_ALL)
add_subdirectory(ext/variant EXCLUDE_FROM_ALL)

message(STATUS "Setting up tests for production...")
set(BUILD_TESTING ON)
add_subdirectory(test/vendor/Catch EXCLUDE_FROM_ALL)
add_subdirectory(test/vendor/dtl EXCLUDE_FROM_ALL)

enable_testing()
include(CTest)
include(test/vendor/Catch/contrib/Catch.cmake)
enable_testing()

# targets developed in this super project
add_subdirectory(ext/snowcrash/ext/markdown-parser EXCLUDE_FROM_ALL)
Expand Down
12 changes: 12 additions & 0 deletions CTestConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## This file should be placed in the root directory of your project.
## Then modify the CMakeLists.txt file in the root directory of your
## project to incorporate the testing dashboard.
##

set(CTEST_PROJECT_NAME "Drafter")
set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC")

set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_SITE "my.cdash.org")
set(CTEST_DROP_LOCATION "/submit.php?project=Drafter")
set(CTEST_DROP_SITE_CDASH TRUE)
43 changes: 43 additions & 0 deletions cmake/unix.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
cmake_minimum_required(VERSION 3.6)

if("${CTEST_BUILD_NAME}" STREQUAL "")
set(CTEST_BUILD_NAME "${CTEST_BUILD_TYPE}")
else()
set(CTEST_BUILD_NAME "${CTEST_BUILD_TYPE}/${CTEST_BUILD_NAME}")
endif()

set(CTEST_SOURCE_DIRECTORY ".")
set(CTEST_BINARY_DIRECTORY "build")

set(CTEST_CMAKE_GENERATOR "Unix Makefiles")

set(CTEST_USE_LAUNCHERS 1)
set(CTEST_MODEL "Continuous")

ctest_read_custom_files(${CTEST_BINARY_DIRECTORY})

ctest_start(${CTEST_MODEL} TRACK ${CTEST_MODEL})
ctest_configure(BUILD ${CTEST_BINARY_DIRECTORY} OPTIONS -DINTEGRATION_TESTS=ON RETURN_VALUE ret_con)
ctest_build(BUILD ${CTEST_BINARY_DIRECTORY} RETURN_VALUE ret_bld)

if(ret_bld EQUAL 0)
ctest_test(BUILD ${CTEST_BINARY_DIRECTORY} RETURN_VALUE ret_tst)
endif()

ctest_submit(RETURN_VALUE ret_sub)

if(NOT ret_con EQUAL 0)
message(FATAL_ERROR "CI failing on config")
endif()

if(NOT ret_bld EQUAL 0)
message(FATAL_ERROR "CI failing on build")
endif()

if(NOT ret_tst EQUAL 0)
message(FATAL_ERROR "CI failing on tests")
endif()

if(NOT ret_sub EQUAL 0)
message(WARNING "Unable to submit results to CDash")
endif()
28 changes: 2 additions & 26 deletions ext/snowcrash/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,39 +25,18 @@ else()
endif()

add_library(snowcrash SHARED ${snowcrash_SOURCES})
add_library(snowcrash-static STATIC ${snowcrash_SOURCES})
add_library(snowcrash-pic STATIC ${snowcrash_SOURCES})
set_property(TARGET snowcrash-pic PROPERTY POSITION_INDEPENDENT_CODE 1)

if(UNIX)
set_target_properties(snowcrash-static PROPERTIES OUTPUT_NAME snowcrash)
endif()

find_package(markdown-parser 1.0 REQUIRED)

target_link_libraries(snowcrash PUBLIC markdown-parser::markdown-parser-pic)
target_link_libraries(snowcrash-static PUBLIC markdown-parser::markdown-parser-static)
target_link_libraries(snowcrash-pic PUBLIC markdown-parser::markdown-parser-pic)
target_link_libraries(snowcrash PUBLIC markdown-parser::markdown-parser)

target_include_directories(snowcrash PUBLIC
$<BUILD_INTERFACE:${snowcrash_BINARY_DIR}/src>
$<BUILD_INTERFACE:${snowcrash_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:src>
)

target_include_directories(snowcrash-static PUBLIC
$<BUILD_INTERFACE:${snowcrash_BINARY_DIR}/src>
$<BUILD_INTERFACE:${snowcrash_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:src>
)

target_include_directories(snowcrash-pic PUBLIC
$<BUILD_INTERFACE:${snowcrash_BINARY_DIR}/src>
$<BUILD_INTERFACE:${snowcrash_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:src>
)

install(TARGETS snowcrash snowcrash-static snowcrash-pic EXPORT snowcrash-targets
install(TARGETS snowcrash EXPORT snowcrash-targets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
Expand All @@ -84,9 +63,6 @@ install(
)

add_library(snowcrash::snowcrash ALIAS snowcrash)
add_library(snowcrash::snowcrash-static ALIAS snowcrash-static)
add_library(snowcrash::snowcrash-pic ALIAS snowcrash-pic)


if(BUILD_TESTING)
include(snowcrash-tests.cmake)
Expand Down
Loading

0 comments on commit d2fd66b

Please sign in to comment.