Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Gitlab - Creating C++ applications with Gitlab CI

3,890 views

Published on

Gitlab is a complete tool that integrates everything from project management to product construction. In this talk I will present how a C ++ project can be analyzed, built, tested and deployed using Gitlab.

Published in: Software
  • Could you please help to share the .gitlab-ci.yml file
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Gitlab - Creating C++ applications with Gitlab CI

  1. 1. Gitlab Creating C++ applications with Gitlab CI Navigate : Space / Arrow Keys | - Menu | - Fullscreen | - Overview | - Blackout | - Speaker | - HelpM F O B S ?  1 / 45
  2. 2. Hello! Uilian Ries C++ and Python Developer Work at @khomp @uilianries    @uilianries  2 / 45
  3. 3. @uilianries  3 / 45
  4. 4. RISE OF THE FOX @uilianries  4 / 45
  5. 5. @uilianries  5 / 45
  6. 6. GITLAB GitLab is a web-based Git-repository manager with wiki, issue-tracking and CI/CD pipeline features. @uilianries  6 / 45
  7. 7. GITLAB CI @uilianries  7 / 45
  8. 8. ARCHITECTURE GitLab CI/CD manages projects/builds GitLab Runner is an application which processes builds You need at least one GitLab instance and one GitLab Runner. @uilianries  8 / 45
  9. 9. ARCHITECTURE @uilianries  9 / 45
  10. 10. GITLAB RUNNER GitLab Runner preforms the actual build It can run on any platform It can test any programming language Support Docker, including auto scaling and multiple jobs concurrently @uilianries  10 / 45
  11. 11. PIPELINE @uilianries  11 / 45
  12. 12. CONFIGURATION FILE .gitlab-ci.yml YAML format Add le to the root directory of your repository Con gure a Runner @uilianries  12 / 45
  13. 13. Cppcheck Clang Tidy Doxygen Unit Test (Catch2) Generate .DEB package Let's start a new C++ project! What does it need? @uilianries  13 / 45
  14. 14. ├── CMakeLists.txt ├── conanfile.txt ├── docs │ ├── Doxyfile ├── include │ └── hello │ └── hello.hpp ├── lib │ └── hello.cpp └── test ├── CMakeLists.txt └── test_message.cpp @uilianries  14 / 45
  15. 15. CPPCHECK A static code analysis tool for the C and C++ $ cppcheck *.cpp --enable=all --language=c++ @uilianries  15 / 45
  16. 16. CPPCHECK .gitlab-ci.yml cppcheck: image: ubuntu:bionic before_script: - apt update - apt install -y --no-install-recommends cppcheck=1.82-1 - cppcheck --version script: - cppcheck lib/*.cpp --verbose --enable=all --inconclusive -- @uilianries  16 / 45
  17. 17. Video Disabled @uilianries  17 / 45
  18. 18. CLANG TIDY A clang-based C++ “linter” tool $ clang-tidy test.cpp -checks=-*,clang-analyz @uilianries  18 / 45
  19. 19. CLANG TIDY .gitlab-ci.yml clang-tidy: image: base/archlinux:2018.09.01 variables: CC: clang CXX: clang++ before_script: - pacman -Syu --needed --noconfirm clang-tools-extra=6.0.1-2 - clang-tidy --version script: - clang-tidy -warnings-as-errors="*" -checks="-*,clang-analyz @uilianries  19 / 45
  20. 20. Video Disabled @uilianries  20 / 45
  21. 21. DOXYGEN A documentation generator, a tool for writing software reference documentation $ doxygen docs/Doxyfile @uilianries  21 / 45
  22. 22. DOXYGEN .gitlab-ci.yml doxygen: image: alpine:3.7 before_script: - apk update - apk add --no-cache -t .required_apks doxygen=1.8.13-r1 gra - mkdir -p build/docs script: - doxygen docs/Doxyfile artifacts: paths: - build/docs/html/ @uilianries  22 / 45
  23. 23. Video Disabled @uilianries  23 / 45
  24. 24. DOXYGEN @uilianries  24 / 45
  25. 25. STAGES [x] Analysis [ ] Testing [ ] Deployment @uilianries  25 / 45
  26. 26. BUILDING CMake Conan Gcc Clang @uilianries  26 / 45
  27. 27. TESTING Catch2 Valgrind gcovr @uilianries  27 / 45
  28. 28. CMake + Conan + Catch2 A application for managing the build process of software A C and C++ Package Manager for Developers A modern header-only, test framework for unit- tests @uilianries  28 / 45
  29. 29. HOW TO BUILD $ mkdir build && cd build $ cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=OFF $ cmake --build . @uilianries  29 / 45
  30. 30. ADDING TESTS $ mkdir build && cd build $ conan install .. $ cmake .. -DCMAKE_BUILD_TYPE=Debug $ cmake --build . --target test $ cmake --build . --target memcheck $ cmake --build . --target coverage @uilianries  30 / 45
  31. 31. build-gcc7: image: lasote/conangcc7 before_script: - sudo apt update - sudo apt install gcovr script: - mkdir -p build && cd build - conan install .. - cmake .. - cmake --build . - cmake --build . --target test - cmake --build . --target memcheck - cmake --build . --target coverage @uilianries  31 / 45
  32. 32. Video Disabled @uilianries  32 / 45
  33. 33. CODE COVERAGE Add code coverage result for Download @uilianries  33 / 45
  34. 34. build-gcc7: image: lasote/conangcc7 before_script: - sudo apt update - sudo apt install gcovr script: - mkdir -p build && cd build - conan install .. - cmake .. - cmake --build . - cmake --build . --target test - cmake --build . --target memcheck - cmake --build . --target coverage artifacts: paths: build/coverage/ @uilianries  34 / 45
  35. 35. COVERAGE @uilianries  35 / 45
  36. 36. STAGES [X] Analysis [X] Testing [ ] Deployment @uilianries  36 / 45
  37. 37. DEPLOYING Download the project as a package Use CPack to generate .DEB package Upload package to Bintray @uilianries  37 / 45
  38. 38. Bintray o ers native support for all major package formats @uilianries  38 / 45
  39. 39. deploy-bintray: image: lasote/conangcc7 before_script: - sudo apt update - sudo apt install -y --no-install-recommends curl script: - cd build - cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=OFF - cmake --build . - cpack -G DEB . after_script: - curl -T build/hello-0.1.0.deb -uuilianries:${BINTRAY_API_ artifacts: paths: - build/*.deb @uilianries  39 / 45
  40. 40. Video Disabled @uilianries  40 / 45
  41. 41. @uilianries  41 / 45
  42. 42. DEMO @uilianries  42 / 45
  43. 43. CONCLUSION C and C++ is not just about language standard There are a lot of FOSS tools Gitlab is a good opportunity to standardize your environment @uilianries  43 / 45
  44. 44. REFERENCES https://gitlab.com/uilianries/native- oripa https://bintray.com/uilianries/dpkg/hello https://github.com/conan-io/conan https://github.com/bincrafters/conan-catch2 https://docs.gitlab.com/ee/ci/yaml @uilianries  44 / 45
  45. 45. THANK YOU! Questions ? You can nd me on: @uilianries - twitter, github cpplang.slack.com - channel #conan or #bincrafters uilianries@gmail.com https://conan.io @uilianries  45 / 45

×