test_benchmark.yaml 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. name: benchmark
  2. on:
  3. push:
  4. pull_request:
  5. workflow_dispatch:
  6. concurrency:
  7. group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
  8. cancel-in-progress: true
  9. jobs:
  10. ubuntu:
  11. runs-on: ubuntu-latest
  12. if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
  13. steps:
  14. - name: checkout
  15. uses: actions/checkout@v4
  16. - name: build and run
  17. run: cd test && make test_benchmark && ./test_benchmark
  18. macos:
  19. runs-on: macos-latest
  20. if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
  21. steps:
  22. - name: checkout
  23. uses: actions/checkout@v4
  24. - name: build and run
  25. run: cd test && make test_benchmark && ./test_benchmark
  26. windows:
  27. runs-on: windows-latest
  28. if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
  29. steps:
  30. - name: Prepare Git for Checkout on Windows
  31. run: |
  32. git config --global core.autocrlf false
  33. git config --global core.eol lf
  34. - name: checkout
  35. uses: actions/checkout@v4
  36. - name: Export GitHub Actions cache environment variables
  37. uses: actions/github-script@v7
  38. with:
  39. script: |
  40. core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
  41. core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
  42. - name: Cache vcpkg packages
  43. id: vcpkg-cache
  44. uses: actions/cache@v4
  45. with:
  46. path: C:/vcpkg/installed
  47. key: vcpkg-installed-windows-gtest
  48. - name: Install vcpkg dependencies
  49. if: steps.vcpkg-cache.outputs.cache-hit != 'true'
  50. run: vcpkg install gtest
  51. - name: Configure and build
  52. shell: pwsh
  53. run: |
  54. $cmake_content = @"
  55. cmake_minimum_required(VERSION 3.14)
  56. project(httplib-benchmark CXX)
  57. find_package(GTest REQUIRED)
  58. add_executable(httplib-benchmark test/test_benchmark.cc)
  59. target_include_directories(httplib-benchmark PRIVATE .)
  60. target_link_libraries(httplib-benchmark PRIVATE GTest::gtest_main)
  61. target_compile_options(httplib-benchmark PRIVATE "$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
  62. "@
  63. New-Item -ItemType Directory -Force -Path build_bench/test | Out-Null
  64. Set-Content -Path build_bench/CMakeLists.txt -Value $cmake_content
  65. Copy-Item -Path httplib.h -Destination build_bench/
  66. Copy-Item -Path test/test_benchmark.cc -Destination build_bench/test/
  67. cmake -B build_bench/build -S build_bench `
  68. -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake"
  69. cmake --build build_bench/build --config Release
  70. - name: Run with retry
  71. run: ctest --output-on-failure --test-dir build_bench/build -C Release --repeat until-pass:5
  72. env:
  73. VCPKG_ROOT: "C:/vcpkg"
  74. VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"