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.

114 lines
3.3 KiB

2 months ago
  1. name: build-and-test
  2. on:
  3. push:
  4. branches: [ main ]
  5. pull_request:
  6. branches: [ main ]
  7. jobs:
  8. # TODO: add 32-bit builds (g++ and clang++) for ubuntu
  9. # (requires g++-multilib and libc6:i386)
  10. # TODO: add coverage build (requires lcov)
  11. # TODO: add clang + libc++ builds for ubuntu
  12. job:
  13. name: ${{ matrix.os }}.${{ matrix.build_type }}.${{ matrix.lib }}.${{ matrix.compiler }}
  14. runs-on: ${{ matrix.os }}
  15. strategy:
  16. fail-fast: false
  17. matrix:
  18. os: [ubuntu-22.04, ubuntu-20.04, macos-latest]
  19. build_type: ['Release', 'Debug']
  20. compiler: ['g++', 'clang++']
  21. lib: ['shared', 'static']
  22. steps:
  23. - uses: actions/checkout@v3
  24. - uses: lukka/get-cmake@latest
  25. - name: create build environment
  26. run: cmake -E make_directory ${{ runner.workspace }}/_build
  27. - name: setup cmake initial cache
  28. run: touch compiler-cache.cmake
  29. - name: configure cmake
  30. env:
  31. CXX: ${{ matrix.compiler }}
  32. shell: bash
  33. working-directory: ${{ runner.workspace }}/_build
  34. run: >
  35. cmake -C ${{ github.workspace }}/compiler-cache.cmake
  36. $GITHUB_WORKSPACE
  37. -DBENCHMARK_DOWNLOAD_DEPENDENCIES=ON
  38. -DBUILD_SHARED_LIBS=${{ matrix.lib == 'shared' }}
  39. -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
  40. -DCMAKE_CXX_COMPILER=${{ env.CXX }}
  41. -DCMAKE_CXX_VISIBILITY_PRESET=hidden
  42. -DCMAKE_VISIBILITY_INLINES_HIDDEN=ON
  43. - name: build
  44. shell: bash
  45. working-directory: ${{ runner.workspace }}/_build
  46. run: cmake --build . --config ${{ matrix.build_type }}
  47. - name: test
  48. shell: bash
  49. working-directory: ${{ runner.workspace }}/_build
  50. run: ctest -C ${{ matrix.build_type }} -VV
  51. msvc:
  52. name: ${{ matrix.os }}.${{ matrix.build_type }}.${{ matrix.lib }}.${{ matrix.msvc }}
  53. runs-on: ${{ matrix.os }}
  54. defaults:
  55. run:
  56. shell: powershell
  57. strategy:
  58. fail-fast: false
  59. matrix:
  60. msvc:
  61. - VS-16-2019
  62. - VS-17-2022
  63. arch:
  64. - x64
  65. build_type:
  66. - Debug
  67. - Release
  68. lib:
  69. - shared
  70. - static
  71. include:
  72. - msvc: VS-16-2019
  73. os: windows-2019
  74. generator: 'Visual Studio 16 2019'
  75. - msvc: VS-17-2022
  76. os: windows-2022
  77. generator: 'Visual Studio 17 2022'
  78. steps:
  79. - uses: actions/checkout@v2
  80. - uses: lukka/get-cmake@latest
  81. - name: configure cmake
  82. run: >
  83. cmake -S . -B _build/
  84. -A ${{ matrix.arch }}
  85. -G "${{ matrix.generator }}"
  86. -DBENCHMARK_DOWNLOAD_DEPENDENCIES=ON
  87. -DBUILD_SHARED_LIBS=${{ matrix.lib == 'shared' }}
  88. - name: build
  89. run: cmake --build _build/ --config ${{ matrix.build_type }}
  90. - name: setup test environment
  91. # Make sure gmock and benchmark DLLs can be found
  92. run: >
  93. echo "$((Get-Item .).FullName)/_build/bin/${{ matrix.build_type }}" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append;
  94. echo "$((Get-Item .).FullName)/_build/src/${{ matrix.build_type }}" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append;
  95. - name: test
  96. run: ctest --test-dir _build/ -C ${{ matrix.build_type }} -VV