test.yaml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. steps:
  43. - name: checkout
  44. uses: actions/checkout@v4
  45. - name: install libraries
  46. run: sudo apt-get update && sudo apt-get install -y libbrotli-dev libcurl4-openssl-dev
  47. - name: build and run tests
  48. run: cd test && make
  49. - name: run fuzz test target
  50. run: cd test && make fuzz_test
  51. macos:
  52. runs-on: macos-latest
  53. if: >
  54. (github.event_name == 'push') ||
  55. (github.event_name == 'pull_request' &&
  56. github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name) ||
  57. (github.event_name == 'workflow_dispatch' && github.event.inputs.test_macos == 'true')
  58. steps:
  59. - name: checkout
  60. uses: actions/checkout@v4
  61. - name: build and run tests
  62. run: cd test && make
  63. - name: run fuzz test target
  64. run: cd test && make fuzz_test
  65. windows:
  66. runs-on: windows-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_windows == 'true')
  72. steps:
  73. - name: Prepare Git for Checkout on Windows
  74. run: |
  75. git config --global core.autocrlf false
  76. git config --global core.eol lf
  77. - name: Checkout
  78. uses: actions/checkout@v4
  79. - name: Export GitHub Actions cache environment variables
  80. uses: actions/github-script@v7
  81. with:
  82. script: |
  83. core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
  84. core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
  85. - name: Setup msbuild on windows
  86. uses: microsoft/setup-msbuild@v2
  87. - name: Install libraries
  88. run: |
  89. vcpkg install gtest curl zlib brotli
  90. choco install openssl
  91. - name: Configure CMake with SSL
  92. run: cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake -DHTTPLIB_TEST=ON -DHTTPLIB_REQUIRE_OPENSSL=ON -DHTTPLIB_REQUIRE_ZLIB=ON -DHTTPLIB_REQUIRE_BROTLI=ON
  93. - name: Build with with SSL
  94. run: cmake --build build --config Release
  95. - name: Run tests with SSL
  96. run: ctest --output-on-failure --test-dir build -C Release
  97. - name: Configure CMake without SSL
  98. run: cmake -B build-no-ssl -S . -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake -DHTTPLIB_TEST=ON -DHTTPLIB_REQUIRE_OPENSSL=OFF -DHTTPLIB_REQUIRE_ZLIB=ON -DHTTPLIB_REQUIRE_BROTLI=ON
  99. - name: Build without SSL
  100. run: cmake --build build-no-ssl --config Release
  101. - name: Run tests without SSL
  102. run: ctest --output-on-failure --test-dir build-no-ssl -C Release
  103. env:
  104. VCPKG_ROOT: "C:/vcpkg"
  105. VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"