test.yaml 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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. strategy:
  73. matrix:
  74. tls_backend: [openssl, mbedtls]
  75. name: ubuntu (${{ matrix.tls_backend }})
  76. steps:
  77. - name: checkout
  78. uses: actions/checkout@v4
  79. - name: install common libraries
  80. run: |
  81. sudo apt-get update
  82. sudo apt-get install -y libcurl4-openssl-dev zlib1g-dev libbrotli-dev libzstd-dev
  83. - name: install OpenSSL
  84. if: matrix.tls_backend == 'openssl'
  85. run: sudo apt-get install -y libssl-dev
  86. - name: install Mbed TLS
  87. if: matrix.tls_backend == 'mbedtls'
  88. run: sudo apt-get install -y libmbedtls-dev
  89. - name: build and run tests (OpenSSL)
  90. if: matrix.tls_backend == 'openssl'
  91. run: cd test && make
  92. - name: build and run tests (Mbed TLS)
  93. if: matrix.tls_backend == 'mbedtls'
  94. run: cd test && make test_split_mbedtls && make test_mbedtls && ./test_mbedtls
  95. - name: run fuzz test target
  96. if: matrix.tls_backend == 'openssl'
  97. run: cd test && make fuzz_test
  98. macos:
  99. runs-on: macos-latest
  100. if: >
  101. (github.event_name == 'push') ||
  102. (github.event_name == 'pull_request' &&
  103. github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name) ||
  104. (github.event_name == 'workflow_dispatch' && github.event.inputs.test_macos == 'true')
  105. strategy:
  106. matrix:
  107. tls_backend: [openssl, mbedtls]
  108. name: macos (${{ matrix.tls_backend }})
  109. steps:
  110. - name: checkout
  111. uses: actions/checkout@v4
  112. - name: install Mbed TLS
  113. if: matrix.tls_backend == 'mbedtls'
  114. run: brew install mbedtls@3
  115. - name: build and run tests (OpenSSL)
  116. if: matrix.tls_backend == 'openssl'
  117. run: cd test && make
  118. - name: build and run tests (Mbed TLS)
  119. if: matrix.tls_backend == 'mbedtls'
  120. run: cd test && make test_split_mbedtls && make test_mbedtls && ./test_mbedtls
  121. - name: run fuzz test target
  122. if: matrix.tls_backend == 'openssl'
  123. run: cd test && make fuzz_test
  124. windows:
  125. runs-on: windows-latest
  126. if: >
  127. (github.event_name == 'push') ||
  128. (github.event_name == 'pull_request' &&
  129. github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name) ||
  130. (github.event_name == 'workflow_dispatch' && github.event.inputs.test_windows == 'true')
  131. strategy:
  132. matrix:
  133. config:
  134. - with_ssl: false
  135. compiled: false
  136. run_tests: true
  137. name: without SSL
  138. - with_ssl: true
  139. compiled: false
  140. run_tests: true
  141. name: with SSL
  142. - with_ssl: false
  143. compiled: true
  144. run_tests: false
  145. name: compiled
  146. name: windows ${{ matrix.config.name }}
  147. steps:
  148. - name: Prepare Git for Checkout on Windows
  149. run: |
  150. git config --global core.autocrlf false
  151. git config --global core.eol lf
  152. - name: Checkout
  153. uses: actions/checkout@v4
  154. - name: Export GitHub Actions cache environment variables
  155. uses: actions/github-script@v7
  156. with:
  157. script: |
  158. core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
  159. core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
  160. - name: Setup msbuild on windows
  161. uses: microsoft/setup-msbuild@v2
  162. - name: Install vcpkg dependencies
  163. run: vcpkg install gtest curl zlib brotli zstd
  164. - name: Install OpenSSL
  165. if: ${{ matrix.config.with_ssl }}
  166. run: choco install openssl
  167. - name: Configure CMake ${{ matrix.config.name }}
  168. run: >
  169. cmake -B build -S .
  170. -DCMAKE_BUILD_TYPE=Release
  171. -DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake
  172. -DHTTPLIB_TEST=ON
  173. -DHTTPLIB_COMPILE=${{ matrix.config.compiled && 'ON' || 'OFF' }}
  174. -DHTTPLIB_USE_OPENSSL_IF_AVAILABLE=${{ matrix.config.with_ssl && 'ON' || 'OFF' }}
  175. -DHTTPLIB_REQUIRE_ZLIB=ON
  176. -DHTTPLIB_REQUIRE_BROTLI=ON
  177. -DHTTPLIB_REQUIRE_ZSTD=ON
  178. -DHTTPLIB_REQUIRE_OPENSSL=${{ matrix.config.with_ssl && 'ON' || 'OFF' }}
  179. - name: Build ${{ matrix.config.name }}
  180. run: cmake --build build --config Release -- /v:m /clp:ShowCommandLine
  181. - name: Run tests ${{ matrix.config.name }}
  182. if: ${{ matrix.config.run_tests }}
  183. run: ctest --output-on-failure --test-dir build -C Release -E "BenchmarkTest"
  184. - name: Run benchmark tests with retry ${{ matrix.config.name }}
  185. if: ${{ matrix.config.run_tests }}
  186. run: ctest --output-on-failure --test-dir build -C Release -R "BenchmarkTest" --repeat until-pass:5
  187. env:
  188. VCPKG_ROOT: "C:/vcpkg"
  189. VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"