You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

138 lines
4.1 KiB

2 months ago
  1. name: Github PR
  2. on:
  3. push:
  4. branches: [ master ]
  5. pull_request:
  6. branches: [ master ]
  7. workflow_dispatch:
  8. permissions: read-all
  9. defaults:
  10. run:
  11. shell: bash
  12. jobs:
  13. cmake-build:
  14. strategy:
  15. fail-fast: false
  16. matrix:
  17. os: [ubuntu-latest, windows-latest, macos-latest]
  18. cxx_standard: [11, 17, 20]
  19. build: [static, shared]
  20. googletest: [build, system]
  21. generator: ["Default Generator", "MinGW Makefiles"]
  22. exclude:
  23. - os: macos-latest
  24. build: shared
  25. - os: macos-latest
  26. generator: "MinGW Makefiles"
  27. - os: ubuntu-latest
  28. generator: "MinGW Makefiles"
  29. - os: macos-latest
  30. googletest: system
  31. - os: windows-latest
  32. googletest: system
  33. env:
  34. YAML_BUILD_SHARED_LIBS: ${{ matrix.build == 'shared' && 'ON' || 'OFF' }}
  35. YAML_USE_SYSTEM_GTEST: ${{ matrix.googletest == 'system' && 'ON' || 'OFF' }}
  36. CMAKE_GENERATOR: >-
  37. ${{format(matrix.generator != 'Default Generator' && '-G "{0}"' || '', matrix.generator)}}
  38. CMAKE_INSTALL_PREFIX: "${{ github.workspace }}/install-prefix"
  39. CMAKE_BUILD_TYPE: Debug
  40. CMAKE_CXX_FLAGS_DEBUG: ${{ matrix.googletest == 'build' && '-g -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC' || '-g' }}
  41. runs-on: ${{ matrix.os }}
  42. steps:
  43. - uses: awalsh128/cache-apt-pkgs-action@latest
  44. if: matrix.os == 'ubuntu-latest'
  45. with:
  46. packages: googletest libgmock-dev libgtest-dev
  47. version: 1.0
  48. - uses: actions/checkout@v4
  49. - name: Configure
  50. run: |
  51. cmake \
  52. ${{ env.CMAKE_GENERATOR }} \
  53. -S "${{ github.workspace }}" \
  54. -B build \
  55. -D CMAKE_CXX_STANDARD=${{ matrix.cxx_standard }} \
  56. -D CMAKE_INSTALL_PREFIX="${{ env.CMAKE_INSTALL_PREFIX }}" \
  57. -D CMAKE_BUILD_TYPE=${{ env.CMAKE_BUILD_TYPE }} \
  58. -D CMAKE_CXX_FLAGS_DEBUG="${{ env.CMAKE_CXX_FLAGS_DEBUG }}" \
  59. -D YAML_BUILD_SHARED_LIBS=${{ env.YAML_BUILD_SHARED_LIBS }} \
  60. -D YAML_USE_SYSTEM_GTEST=${{ env.YAML_USE_SYSTEM_GTEST }} \
  61. -D YAML_CPP_BUILD_TESTS=ON
  62. - name: Build
  63. run: |
  64. cmake \
  65. --build build \
  66. --config ${{ env.CMAKE_BUILD_TYPE }} \
  67. --verbose \
  68. --parallel
  69. - name: Run Tests
  70. shell: bash
  71. run: |
  72. ctest \
  73. --test-dir build \
  74. --build-config ${{ env.CMAKE_BUILD_TYPE }} \
  75. --output-on-failure \
  76. --verbose
  77. - name: Install
  78. run: cmake --install build --config ${{ env.CMAKE_BUILD_TYPE }}
  79. - name: Configure CMake package test
  80. run: |
  81. cmake \
  82. ${{ env.CMAKE_GENERATOR }} \
  83. -S "${{ github.workspace }}/test/cmake" \
  84. -B consumer-build \
  85. -D CMAKE_BUILD_TYPE=${{ env.CMAKE_BUILD_TYPE }} \
  86. -D CMAKE_PREFIX_PATH="${{ env.CMAKE_INSTALL_PREFIX }}"
  87. - name: Build CMake package test
  88. run: |
  89. cmake \
  90. --build consumer-build \
  91. --config ${{ env.CMAKE_BUILD_TYPE }} \
  92. --verbose
  93. bazel-build:
  94. strategy:
  95. matrix:
  96. os: [ubuntu-latest, windows-latest, macos-latest]
  97. runs-on: ${{ matrix.os }}
  98. steps:
  99. - uses: actions/checkout@v4
  100. - name: Build
  101. run: |
  102. cd "${{ github.workspace }}"
  103. bazel build :all
  104. - name: Test
  105. run: |
  106. cd "${{ github.workspace }}"
  107. bazel test test
  108. bzlmod-build:
  109. strategy:
  110. matrix:
  111. os: [ubuntu-latest, windows-latest, macos-latest]
  112. runs-on: ${{ matrix.os }}
  113. steps:
  114. - uses: actions/checkout@v4
  115. - name: Build
  116. shell: bash
  117. run: |
  118. cd "${{ github.workspace }}"
  119. bazel build --enable_bzlmod :all
  120. - name: Test
  121. shell: bash
  122. run: |
  123. cd "${{ github.workspace }}"
  124. bazel test --enable_bzlmod test