.gitlab-ci.yml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. stages:
  2. - build
  3. - deploy
  4. variables:
  5. VCS_FILE: build_depends.repos
  6. AUTOWARE_CROSS_TARGET_PLATFORM: generic-aarch64
  7. .build: &build_common
  8. before_script:
  9. - mkdir -p src_tmp/$CI_PROJECT_NAME && mv `find -maxdepth 1 -not -name . -not -name src_tmp -not -name $VCS_FILE` src_tmp/$CI_PROJECT_NAME && mv src_tmp/ src/
  10. - sudo apt-get update
  11. - sudo apt-get install -y libarmadillo-dev libglew-dev libssh2-1-dev python-flask python-requests wget lcov
  12. - sudo apt-get install -y python3-pip python3-setuptools python3-colcon-common-extensions python3-vcstool
  13. # Update setuptools from PyPI because the version Ubuntu ships with is too old
  14. - pip3 install -U setuptools
  15. - vcs validate < $VCS_FILE
  16. - vcs import src/ < $VCS_FILE
  17. - rosdep update
  18. - rosdep install -y --from-paths src --ignore-src --rosdistro $ROS_DISTRO
  19. script:
  20. # We first build the entire workspace normally
  21. - source /opt/ros/${ROS_DISTRO}/setup.bash
  22. - colcon build --cmake-args -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage" -DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage" -DCMAKE_BUILD_TYPE=Debug
  23. # And then build the tests target. catkin (ROS1) packages add their tests to the tests target
  24. # which is not the standard target for CMake projects. We need to trigger the tests target so that
  25. # tests are built and any fixtures are set up.
  26. - colcon build --cmake-target tests --cmake-args -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage" -DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage" -DCMAKE_BUILD_TYPE=Debug
  27. - lcov --initial --directory build --capture --output-file lcov.base
  28. - colcon test
  29. - colcon test-result --verbose
  30. - lcov --directory build --capture --output-file lcov.test
  31. - lcov -a lcov.base -a lcov.test -o lcov.total
  32. - lcov -r lcov.total '*/tests/*' '*/test/*' '*/build/*' '*/devel/*' '*/install/*' '*/log/*' '/usr/*' '/opt/*' '/tmp/*' '*/CMakeCCompilerId.c' '*/CMakeCXXCompilerId.cpp' -o lcov.total.filtered
  33. # BRANCH_NAME: gets branch name from CI_COMMIT_REF_NAME variable substituting / with _ (feature/test_this_lib becomes feature_test_this_lib)
  34. # CI_COMMIT_REF_NAME: (from https://docs.gitlab.com/ee/ci/variables/) The branch or tag name for which project is built
  35. - BRANCH_NAME="$(echo $CI_COMMIT_REF_NAME | sed 's/\//_/g')"
  36. - COVERAGE_FOLDER_NAME="coverage_$BRANCH_NAME"
  37. - genhtml -p "$PWD" --legend --demangle-cpp lcov.total.filtered -o $COVERAGE_FOLDER_NAME
  38. - tar -czvf coverage.tar.gz $COVERAGE_FOLDER_NAME
  39. artifacts:
  40. paths:
  41. - $CI_PROJECT_DIR/coverage.tar.gz
  42. expire_in: 48 hrs
  43. coverage: /\s*lines.*:\s(\d+\.\d+\%\s\(\d+\sof\s\d+.*\))/
  44. .build_cuda: &build_cuda
  45. before_script:
  46. - mkdir -p src_tmp/$CI_PROJECT_NAME && mv `find -maxdepth 1 -not -name . -not -name src_tmp -not -name $VCS_FILE` src_tmp/$CI_PROJECT_NAME && mv src_tmp/ src/
  47. - sudo apt-get update
  48. - sudo apt-get install -y libarmadillo-dev libglew-dev libssh2-1-dev python-flask python-requests wget
  49. - sudo apt-get install -y python3-pip python3-setuptools python3-colcon-common-extensions python3-vcstool
  50. # Update setuptools from PyPI because the version Ubuntu ships with is too old
  51. - pip3 install -U setuptools
  52. - vcs validate < $VCS_FILE
  53. - vcs import src/ < $VCS_FILE
  54. - rosdep update
  55. - rosdep install -y --from-paths src --ignore-src --rosdistro $ROS_DISTRO
  56. script:
  57. # We first build the entire workspace normally
  58. - source /opt/ros/${ROS_DISTRO}/setup.bash
  59. - colcon build --cmake-args -DCMAKE_BUILD_TYPE=Debug
  60. # And then build the tests target. catkin (ROS1) packages add their tests to the tests target
  61. # which is not the standard target for CMake projects. We need to trigger the tests target so that
  62. # tests are built and any fixtures are set up.
  63. - colcon build --cmake-target tests --cmake-args -DCMAKE_BUILD_TYPE=Debug
  64. - colcon test
  65. - colcon test-result --verbose
  66. .build_cross_vars: &build_cross_vars
  67. AUTOWARE_TARGET_ARCH: aarch64
  68. AUTOWARE_TOOLCHAIN_FILE_PATH: $CI_PROJECT_DIR/cross_toolchain.cmake
  69. AUTOWARE_SYSROOT: /sysroot/${AUTOWARE_CROSS_TARGET_PLATFORM}
  70. .build_cross: &build_cross_common
  71. script:
  72. - mkdir -p src_tmp/$CI_PROJECT_NAME && mv `find -maxdepth 1 -not -name . -not -name src_tmp -not -name $VCS_FILE` src_tmp/$CI_PROJECT_NAME && mv src_tmp/ src/
  73. - apt update -qq && apt install -y python3-vcstool git wget
  74. - wget https://gitlab.com/autowarefoundation/autoware.ai/docker/raw/master/crossbuild/cross_toolchain.cmake
  75. - source ${AUTOWARE_SYSROOT}/opt/ros/${ROS_DISTRO}/setup.bash
  76. - vcs validate < $VCS_FILE
  77. - vcs import src/ < $VCS_FILE
  78. - colcon build
  79. --merge-install
  80. --cmake-args
  81. -DCMAKE_TOOLCHAIN_FILE=${AUTOWARE_TOOLCHAIN_FILE_PATH}
  82. -DCMAKE_SYSTEM_PROCESSOR=${AUTOWARE_TARGET_ARCH}
  83. -DCMAKE_PREFIX_PATH="${CI_PROJECT_DIR}/install;${AUTOWARE_SYSROOT}/opt/ros/${ROS_DISTRO}"
  84. -DCMAKE_FIND_ROOT_PATH=${CI_PROJECT_DIR}/install
  85. only:
  86. - merge_requests
  87. - master
  88. build_melodic:
  89. stage: build
  90. image: autoware/autoware:bleedingedge-melodic-base
  91. <<: *build_common
  92. only:
  93. - merge_requests
  94. - master
  95. build_melodic_cuda:
  96. stage: build
  97. image: autoware/autoware:bleedingedge-melodic-base-cuda
  98. <<: *build_cuda
  99. only:
  100. - merge_requests
  101. - master
  102. build_melodic_arm64:
  103. tags:
  104. - arm64
  105. stage: build
  106. image: autoware/arm64v8:bleedingedge-melodic-base
  107. <<: *build_common
  108. only:
  109. - branches@autowarefoundation/autoware.ai/common
  110. build_melodic_cross:
  111. stage: build
  112. image: autoware/build:${AUTOWARE_CROSS_TARGET_PLATFORM}-melodic-bleedingedge
  113. variables:
  114. ROS_DISTRO: melodic
  115. <<: *build_cross_vars
  116. <<: *build_cross_common
  117. only:
  118. - merge_requests
  119. - master
  120. pages:
  121. stage: deploy
  122. image: alpine
  123. dependencies:
  124. - build_melodic
  125. script:
  126. - BRANCH_NAME="$(echo $CI_COMMIT_REF_NAME | sed 's/\//_/g')"
  127. - COVERAGE_FOLDER_NAME="coverage_$BRANCH_NAME"
  128. - tar -xzvf coverage.tar.gz
  129. - mv $COVERAGE_FOLDER_NAME public
  130. artifacts:
  131. paths:
  132. - public
  133. only:
  134. - master