test.yaml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. name: test
  2. on:
  3. push:
  4. pull_request:
  5. workflow_dispatch:
  6. inputs:
  7. gtest_filter:
  8. description: 'Google Test filter'
  9. test_linux:
  10. description: 'Test on Linux'
  11. type: boolean
  12. default: true
  13. test_macos:
  14. description: 'Test on MacOS'
  15. type: boolean
  16. default: true
  17. test_windows:
  18. description: 'Test on Windows'
  19. type: boolean
  20. default: true
  21. env:
  22. GTEST_FILTER: ${{ github.event.inputs.gtest_filter || '*' }}
  23. jobs:
  24. style-check:
  25. runs-on: ubuntu-latest
  26. if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
  27. continue-on-error: true
  28. steps:
  29. - name: checkout
  30. uses: actions/checkout@v4
  31. - name: run style check
  32. run: |
  33. clang-format --version
  34. cd test && make style_check
  35. ubuntu:
  36. runs-on: ubuntu-latest
  37. if: >
  38. (github.event_name == 'push') ||
  39. (github.event_name == 'pull_request' &&
  40. github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name) ||
  41. (github.event_name == 'workflow_dispatch' && github.event.inputs.test_linux == 'true')
  42. strategy:
  43. matrix:
  44. select_impl: ['select', 'poll']
  45. steps:
  46. - name: checkout
  47. uses: actions/checkout@v4
  48. - name: install libraries
  49. run: sudo apt-get update && sudo apt-get install -y libbrotli-dev libcurl4-openssl-dev
  50. - name: build and run tests
  51. env:
  52. SELECT_IMPL: ${{ matrix.select_impl }}
  53. run: cd test && make
  54. - name: run fuzz test target
  55. env:
  56. SELECT_IMPL: ${{ matrix.select_impl }}
  57. run: cd test && make fuzz_test
  58. macos:
  59. runs-on: macos-latest
  60. if: >
  61. (github.event_name == 'push') ||
  62. (github.event_name == 'pull_request' &&
  63. github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name) ||
  64. (github.event_name == 'workflow_dispatch' && github.event.inputs.test_macos == 'true')
  65. strategy:
  66. matrix:
  67. select_impl: ['select', 'poll']
  68. steps:
  69. - name: checkout
  70. uses: actions/checkout@v4
  71. - name: build and run tests
  72. env:
  73. SELECT_IMPL: ${{ matrix.select_impl }}
  74. run: cd test && make
  75. - name: run fuzz test target
  76. env:
  77. SELECT_IMPL: ${{ matrix.select_impl }}
  78. run: cd test && make fuzz_test
  79. windows:
  80. runs-on: windows-latest
  81. if: >
  82. (github.event_name == 'push') ||
  83. (github.event_name == 'pull_request' &&
  84. github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name) ||
  85. (github.event_name == 'workflow_dispatch' && github.event.inputs.test_windows == 'true')
  86. strategy:
  87. matrix:
  88. select_impl: ['select', 'poll']
  89. steps:
  90. - name: Prepare Git for Checkout on Windows
  91. run: |
  92. git config --global core.autocrlf false
  93. git config --global core.eol lf
  94. - name: Checkout
  95. uses: actions/checkout@v4
  96. - name: Export GitHub Actions cache environment variables
  97. uses: actions/github-script@v7
  98. with:
  99. script: |
  100. core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
  101. core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
  102. - name: Setup msbuild on windows
  103. uses: microsoft/setup-msbuild@v2
  104. - name: Install libraries
  105. run: |
  106. vcpkg install gtest curl zlib brotli
  107. choco install openssl
  108. - name: Configure CMake with SSL
  109. run: >
  110. cmake -B build -S .
  111. -DCMAKE_BUILD_TYPE=Release
  112. -DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake
  113. -DHTTPLIB_TEST=ON
  114. -DHTTPLIB_REQUIRE_OPENSSL=ON
  115. -DHTTPLIB_REQUIRE_ZLIB=ON
  116. -DHTTPLIB_REQUIRE_BROTLI=ON
  117. -DHTTPLIB_USE_SELECT=${{ matrix.select_impl == 'select' && 'ON' || 'OFF' }}
  118. - name: Build with with SSL
  119. run: cmake --build build --config Release -- /v:m /clp:ShowCommandLine /nologo
  120. - name: Run tests with SSL
  121. run: ctest --output-on-failure --test-dir build -C Release
  122. - name: Configure CMake without SSL
  123. run: >
  124. cmake -B build-no-ssl -S .
  125. -DCMAKE_BUILD_TYPE=Release
  126. -DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake
  127. -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
  128. -DHTTPLIB_TEST=ON
  129. -DHTTPLIB_REQUIRE_OPENSSL=OFF
  130. -DHTTPLIB_REQUIRE_ZLIB=ON
  131. -DHTTPLIB_REQUIRE_BROTLI=ON
  132. -DHTTPLIB_USE_SELECT=${{ matrix.select_impl == 'select' && 'ON' || 'OFF' }}
  133. - name: Build without SSL
  134. run: cmake --build build-no-ssl --config Release -- /v:m /clp:ShowCommandLine /nologo
  135. - name: Run tests without SSL
  136. run: ctest --output-on-failure --test-dir build-no-ssl -C Release
  137. env:
  138. VCPKG_ROOT: "C:/vcpkg"
  139. VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"