diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5148ca33c15932abaa2d9824763cef26499ff17d..db6320eca36c3ca8151e0b5a1c6d8d67a2863085 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,7 +11,8 @@ variables: stages: - config - quality - - build_test + - build + - test - optional # job/stage to just prepare cmake @@ -42,7 +43,6 @@ config-clang-8: variables: CORSIKA_DATA: "${CI_BUILDS_DIR}/AirShowerPhysics/corsika/corsika-data/" script: - - git clone https://gitlab.ikp.kit.edu/AirShowerPhysics/corsika-data.git - mkdir build - cd build - cmake .. -DCMAKE_BUILD_TYPE=Debug -DWITH_PYTHIA=ON @@ -50,7 +50,6 @@ config-clang-8: expire_in: 1 day paths: - build - - corsika-data check-copyrights: image: corsika/devel:u-18.04 @@ -71,11 +70,11 @@ check-clang-format: - ./do-clang-format.py --all # normal pipeline for each commit -build-test-u-18_04: +build-u-18_04: image: corsika/devel:u-18.04 dependencies: - config-u-18_04 - stage: build_test + stage: build tags: - corsika variables: @@ -83,6 +82,43 @@ build-test-u-18_04: script: - cd build - cmake --build . -- -j4 + artifacts: + expire_in: 1 hour + paths: + - build + +# normal pipeline for each commit +build-clang-8: + image: corsika/devel:clang-8 + dependencies: + - config-clang-8 + stage: build + tags: + - corsika + variables: + CORSIKA_DATA: "${CI_PROJECT_DIR}/corsika-data/" + script: + - cd build + - cmake --build . -- -j4 + artifacts: + expire_in: 1 hour + reports: + paths: + - build + +# normal pipeline for each commit +test-u-18_04: + image: corsika/devel:u-18.04 + dependencies: + - build-u-18_04 + stage: test + tags: + - corsika + variables: + CORSIKA_DATA: "${CI_PROJECT_DIR}/corsika-data/" + script: + - git clone https://gitlab.ikp.kit.edu/AirShowerPhysics/corsika-data.git + - cd build - set -o pipefail - ctest -VV | gzip -v -9 > test.log.gz artifacts: @@ -95,18 +131,18 @@ build-test-u-18_04: - build/test.log.gz # normal pipeline for each commit -build-test-clang-8: +test-clang-8: image: corsika/devel:clang-8 dependencies: - - config-clang-8 - stage: build_test + - build-clang-8 + stage: test tags: - corsika variables: CORSIKA_DATA: "${CI_PROJECT_DIR}/corsika-data/" script: + - git clone https://gitlab.ikp.kit.edu/AirShowerPhysics/corsika-data.git - cd build - - cmake --build . -- -j4 - set -o pipefail - ctest -VV | gzip -v -9 > test.log.gz artifacts: @@ -117,9 +153,57 @@ build-test-clang-8: - build/test_outputs/junit*.xml paths: - build/test.log.gz - + +# normal pipeline for each commit +example-u-18_04: + image: corsika/devel:u-18.04 + dependencies: + - build-u-18_04 + stage: example + tags: + - corsika + variables: + CORSIKA_DATA: "${CI_PROJECT_DIR}/corsika-data/" + script: + - git clone https://gitlab.ikp.kit.edu/AirShowerPhysics/corsika-data.git + - cd build + - set -o pipefail + - make run_examples + artifacts: + when: always + expire_in: 1 week + reports: + junit: + - build/example_outputs/junit*.xml + paths: + - build/example.log.gz + +# normal pipeline for each commit +example-clang-8: + image: corsika/devel:clang-8 + dependencies: + - build-clang-8 + stage: example + tags: + - corsika + variables: + CORSIKA_DATA: "${CI_PROJECT_DIR}/corsika-data/" + script: + - git clone https://gitlab.ikp.kit.edu/AirShowerPhysics/corsika-data.git + - cd build + - set -o pipefail + - make run_examples + artifacts: + when: always + expire_in: 1 week + reports: + junit: + - build/example_outputs/junit*.xml + paths: + - build/example.log.gz + # optional release pipeline for each commit -release-u-18_04: +release-full-u-18_04: image: corsika/devel:u-18.04 dependencies: - config-u-18_04 @@ -129,11 +213,13 @@ release-u-18_04: variables: CORSIKA_DATA: "${CI_PROJECT_DIR}/corsika-data/" script: + - git clone https://gitlab.ikp.kit.edu/AirShowerPhysics/corsika-data.git - cd build - cmake .. -DCMAKE_BUILD_TYPE=Release - cmake --build . -- -j4 - set -o pipefail - ctest -VV | gzip -v -9 > test.log.gz + - make run_examples artifacts: when: always expire_in: 1 week @@ -145,7 +231,7 @@ release-u-18_04: when: manual # optional release pipeline for each commit -release-clang-8: +release-full-clang-8: image: corsika/devel:clang-8 dependencies: - config-clang-8 @@ -155,11 +241,13 @@ release-clang-8: variables: CORSIKA_DATA: "${CI_PROJECT_DIR}/corsika-data/" script: + - git clone https://gitlab.ikp.kit.edu/AirShowerPhysics/corsika-data.git - cd build - cmake .. -DCMAKE_BUILD_TYPE=Release - cmake --build . -- -j4 - set -o pipefail - - ctest -VV | gzip -v -9 > test.log.gz + - ctest -VV | gzip -v -9 > test.log.gz + - make run_examples artifacts: when: always expire_in: 1 week diff --git a/CMakeModules/CorsikaUtilities.cmake b/CMakeModules/CorsikaUtilities.cmake index 090e26065dc987d602d28b246412574566e18ea2..52521e9cfea91c21149ffa1e6b9681c332b5f20c 100644 --- a/CMakeModules/CorsikaUtilities.cmake +++ b/CMakeModules/CorsikaUtilities.cmake @@ -31,7 +31,8 @@ endfunction (CORSIKA_PREPEND_PATH) # # if needed, create symbolic links from the source files to this build-directory location # -# any path information from input filenames is stripped, IF path was specified it is used for the link destination, if NOT the link is relative to the CMAKE_CURRENT_SOURCE_DIR +# any path information from input filenames is stripped, IF path was specified it is used for the link destination, +# if NOT the link is relative to the CMAKE_CURRENT_SOURCE_DIR # function (CORSIKA_COPY_HEADERS_TO_NAMESPACE for_library in_namespace) set (HEADERS_BUILD "") @@ -153,3 +154,56 @@ function (CORSIKA_ADD_TEST) endif () add_test (NAME ${name} COMMAND ${name} -o ${PROJECT_BINARY_DIR}/test_outputs/junit-${name}.xml -s -r junit) endfunction (CORSIKA_ADD_TEST) + + +################################################# +# +# central macro to register an exmaple in cmake +# +# Examples can be globally executed by 'make run_examples' +# +# 1) Simple use: +# Pass the name of the test.cc file as the first +# argument, without the ".cc" extention. +# +# Example: CORSIKA_ADD_EXAMPLE (testSomething) +# +# This generates target testSomething from file testSomething.cc. +# +# 2) Customize sources: +# If 1) doesn't work, use the SOURCES keyword to explicitly +# specify the sources. +# +# Example: CORSIKA_ADD_EXAMPLE (testSomething +# SOURCES source1.cc source2.cc someheader.h) +# +# In all cases, you can further customize the target with +# target_link_libraries(testSomething ...) and so on. +# +function (CORSIKA_ADD_EXAMPLE) + cmake_parse_arguments (PARSE_ARGV 1 _ "" "" "SOURCES") + + set (name ${ARGV0}) + + if (NOT __SOURCES) + set (sources ${name}.cc) + else () + set (sources ${__SOURCES}) + endif () + + add_executable (${name} ${sources}) + target_compile_options (${name} PRIVATE -g) # do not skip asserts + target_include_directories (${name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) + file (MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/example_outputs/) + if (TARGET run_examples) + else () + add_custom_target (run_examples) + endif () + add_custom_command (TARGET run_examples + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E echo "" + COMMAND ${CMAKE_COMMAND} -E echo "***************************************" + COMMAND ${CMAKE_COMMAND} -E echo "***** running example: ${name}" + COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${name} + WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/example_outputs) +endfunction (CORSIKA_ADD_EXAMPLE) diff --git a/Documentation/Examples/CMakeLists.txt b/Documentation/Examples/CMakeLists.txt index 474bbe4224b075a3b7e8f759414322e5f481d812..86707de468c113c00e7678a29bd9cfd05c844ad8 100644 --- a/Documentation/Examples/CMakeLists.txt +++ b/Documentation/Examples/CMakeLists.txt @@ -1,25 +1,26 @@ -CORSIKA_ADD_TEST (helix_example) + +CORSIKA_ADD_EXAMPLE (helix_example) target_link_libraries (helix_example CORSIKAgeometry CORSIKAunits) install (TARGETS helix_example DESTINATION share/examples) -CORSIKA_ADD_TEST (particle_list_example) +CORSIKA_ADD_EXAMPLE (particle_list_example) target_link_libraries (particle_list_example CORSIKAparticles CORSIKAunits CORSIKAprocesses ProcessSibyll ProcessQGSJetII) install (TARGETS particle_list_example DESTINATION share/examples) -CORSIKA_ADD_TEST (geometry_example) +CORSIKA_ADD_EXAMPLE (geometry_example) target_link_libraries (geometry_example CORSIKAgeometry CORSIKAunits) install (TARGETS geometry_example DESTINATION share/examples) -CORSIKA_ADD_TEST (logger_example) +CORSIKA_ADD_EXAMPLE (logger_example) target_link_libraries (logger_example CORSIKAunits CORSIKAlogging) install (TARGETS logger_example DESTINATION share/examples) -CORSIKA_ADD_TEST (stack_example) +CORSIKA_ADD_EXAMPLE (stack_example stack_example.cc) target_link_libraries (stack_example SuperStupidStack CORSIKAunits CORSIKAlogging) # address sanitizer is making this example too slow, so we only do "undefined" -CORSIKA_ADD_TEST (cascade_example SANITIZE "undefined") +CORSIKA_ADD_EXAMPLE (cascade_example cascade_example.cc) target_link_libraries (cascade_example SuperStupidStack CORSIKAunits @@ -41,7 +42,7 @@ target_link_libraries (cascade_example ) install (TARGETS cascade_example DESTINATION share/examples) -CORSIKA_ADD_TEST (boundary_example) +CORSIKA_ADD_EXAMPLE (boundary_example boundary_example.cc) target_link_libraries (boundary_example SuperStupidStack CORSIKAunits @@ -61,7 +62,7 @@ target_link_libraries (boundary_example install (TARGETS boundary_example DESTINATION share/examples) if (Pythia8_FOUND) - CORSIKA_ADD_TEST (cascade_proton_example) + CORSIKA_ADD_EXAMPLE (cascade_proton_example cascade_proton_example.cc) target_link_libraries (cascade_proton_example SuperStupidStack CORSIKAunits @@ -86,7 +87,11 @@ if (Pythia8_FOUND) ) install (TARGETS cascade_proton_example DESTINATION share/examples) +<<<<<<< Updated upstream add_executable(vertical_EAS vertical_EAS.cc) +======= + CORSIKA_ADD_EXAMPLE (vertical_EAS vertical_EAS.cc) +>>>>>>> Stashed changes target_link_libraries (vertical_EAS SuperStupidStack CORSIKAunits @@ -99,10 +104,17 @@ if (Pythia8_FOUND) CORSIKAcascade ProcessEnergyLoss ProcessObservationPlane +<<<<<<< Updated upstream ProcessTrackingLine ProcessParticleCut ProcessStackInspector ProcessInteractionCounter +======= + ProcessTrackWriter + ProcessTrackingLine + ProcessParticleCut + ProcessStackInspector +>>>>>>> Stashed changes CORSIKAprocesses CORSIKAcascade CORSIKAparticles @@ -111,10 +123,13 @@ if (Pythia8_FOUND) CORSIKAprocesssequence ) install (TARGETS vertical_EAS DESTINATION share/examples) +<<<<<<< Updated upstream +======= +>>>>>>> Stashed changes endif() -CORSIKA_ADD_TEST(stopping_power) +CORSIKA_ADD_EXAMPLE (stopping_power stopping_power.cc) target_link_libraries (stopping_power SuperStupidStack CORSIKAunits @@ -123,8 +138,13 @@ target_link_libraries (stopping_power CORSIKAgeometry CORSIKAenvironment ) +install (TARGETS stopping_power DESTINATION share/examples) +<<<<<<< Updated upstream CORSIKA_ADD_TEST (staticsequence_example) +======= +CORSIKA_ADD_EXAMPLE (staticsequence_example staticsequence_example.cc) +>>>>>>> Stashed changes target_link_libraries (staticsequence_example CORSIKAprocesssequence CORSIKAunits