1
0

test.yaml 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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. concurrency:
  22. group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
  23. cancel-in-progress: true
  24. env:
  25. GTEST_FILTER: ${{ github.event.inputs.gtest_filter || '*' }}
  26. jobs:
  27. style-check:
  28. runs-on: ubuntu-latest
  29. if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
  30. continue-on-error: true
  31. steps:
  32. - name: checkout
  33. uses: actions/checkout@v4
  34. - name: run style check
  35. run: |
  36. clang-format --version
  37. cd test && make style_check
  38. build-error-check-on-32bit:
  39. runs-on: ubuntu-latest
  40. if: >
  41. (github.event_name == 'push') ||
  42. (github.event_name == 'pull_request' &&
  43. github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name) ||
  44. (github.event_name == 'workflow_dispatch' && github.event.inputs.test_linux == 'true')
  45. strategy:
  46. matrix:
  47. config:
  48. - arch_flags: -m32
  49. arch_suffix: :i386
  50. name: (32-bit)
  51. steps:
  52. - name: checkout
  53. uses: actions/checkout@v4
  54. - name: install libraries
  55. run: |
  56. sudo dpkg --add-architecture i386
  57. sudo apt-get update
  58. sudo apt-get install -y libc6-dev${{ matrix.config.arch_suffix }} libstdc++-13-dev${{ matrix.config.arch_suffix }} \
  59. libssl-dev${{ matrix.config.arch_suffix }} libcurl4-openssl-dev${{ matrix.config.arch_suffix }} \
  60. zlib1g-dev${{ matrix.config.arch_suffix }} libbrotli-dev${{ matrix.config.arch_suffix }} \
  61. libzstd-dev${{ matrix.config.arch_suffix }}
  62. - name: build and run tests (expect failure)
  63. run: cd test && make test EXTRA_CXXFLAGS="${{ matrix.config.arch_flags }}"
  64. continue-on-error: true
  65. ubuntu:
  66. runs-on: ubuntu-latest
  67. if: >
  68. (github.event_name == 'push') ||
  69. (github.event_name == 'pull_request' &&
  70. github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name) ||
  71. (github.event_name == 'workflow_dispatch' && github.event.inputs.test_linux == 'true')
  72. steps:
  73. - name: checkout
  74. uses: actions/checkout@v4
  75. - name: install libraries
  76. run: |
  77. sudo dpkg --add-architecture i386
  78. sudo apt-get update
  79. sudo apt-get install -y libc6-dev${{ matrix.config.arch_suffix }} libstdc++-13-dev${{ matrix.config.arch_suffix }} \
  80. libssl-dev${{ matrix.config.arch_suffix }} libcurl4-openssl-dev${{ matrix.config.arch_suffix }} \
  81. zlib1g-dev${{ matrix.config.arch_suffix }} libbrotli-dev${{ matrix.config.arch_suffix }} \
  82. libzstd-dev${{ matrix.config.arch_suffix }}
  83. - name: build and run tests
  84. run: cd test && make EXTRA_CXXFLAGS="${{ matrix.config.arch_flags }}"
  85. - name: run fuzz test target
  86. run: cd test && make EXTRA_CXXFLAGS="${{ matrix.config.arch_flags }}" fuzz_test
  87. macos:
  88. runs-on: macos-latest
  89. if: >
  90. (github.event_name == 'push') ||
  91. (github.event_name == 'pull_request' &&
  92. github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name) ||
  93. (github.event_name == 'workflow_dispatch' && github.event.inputs.test_macos == 'true')
  94. steps:
  95. - name: checkout
  96. uses: actions/checkout@v4
  97. - name: build and run tests
  98. run: cd test && make
  99. - name: run fuzz test target
  100. run: cd test && make fuzz_test
  101. windows:
  102. runs-on: windows-latest
  103. if: >
  104. (github.event_name == 'push') ||
  105. (github.event_name == 'pull_request' &&
  106. github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name) ||
  107. (github.event_name == 'workflow_dispatch' && github.event.inputs.test_windows == 'true')
  108. strategy:
  109. matrix:
  110. config:
  111. - with_ssl: false
  112. compiled: false
  113. run_tests: true
  114. name: without SSL
  115. - with_ssl: true
  116. compiled: false
  117. run_tests: true
  118. name: with SSL
  119. - with_ssl: false
  120. compiled: true
  121. run_tests: false
  122. name: compiled
  123. name: windows ${{ matrix.config.name }}
  124. steps:
  125. - name: Prepare Git for Checkout on Windows
  126. run: |
  127. git config --global core.autocrlf false
  128. git config --global core.eol lf
  129. - name: Checkout
  130. uses: actions/checkout@v4
  131. - name: Export GitHub Actions cache environment variables
  132. uses: actions/github-script@v7
  133. with:
  134. script: |
  135. core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
  136. core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
  137. - name: Setup msbuild on windows
  138. uses: microsoft/setup-msbuild@v2
  139. - name: Install vcpkg dependencies
  140. run: vcpkg install gtest curl zlib brotli zstd
  141. - name: Install OpenSSL
  142. if: ${{ matrix.config.with_ssl }}
  143. run: choco install openssl
  144. - name: Configure CMake ${{ matrix.config.name }}
  145. run: >
  146. cmake -B build -S .
  147. -DCMAKE_BUILD_TYPE=Release
  148. -DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake
  149. -DHTTPLIB_TEST=ON
  150. -DHTTPLIB_COMPILE=${{ matrix.config.compiled && 'ON' || 'OFF' }}
  151. -DHTTPLIB_USE_OPENSSL_IF_AVAILABLE=${{ matrix.config.with_ssl && 'ON' || 'OFF' }}
  152. -DHTTPLIB_REQUIRE_ZLIB=ON
  153. -DHTTPLIB_REQUIRE_BROTLI=ON
  154. -DHTTPLIB_REQUIRE_ZSTD=ON
  155. -DHTTPLIB_REQUIRE_OPENSSL=${{ matrix.config.with_ssl && 'ON' || 'OFF' }}
  156. - name: Build ${{ matrix.config.name }}
  157. run: cmake --build build --config Release -- /v:m /clp:ShowCommandLine
  158. - name: Run tests ${{ matrix.config.name }}
  159. if: ${{ matrix.config.run_tests }}
  160. run: ctest --output-on-failure --test-dir build -C Release -E "BenchmarkTest"
  161. - name: Run benchmark tests with retry ${{ matrix.config.name }}
  162. if: ${{ matrix.config.run_tests }}
  163. run: ctest --output-on-failure --test-dir build -C Release -R "BenchmarkTest" --repeat until-pass:5
  164. env:
  165. VCPKG_ROOT: "C:/vcpkg"
  166. VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"