|
| 1 | +name: test-stream |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + pull_request: |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + gtest_filter: |
| 9 | + description: 'Google Test filter' |
| 10 | + test_linux: |
| 11 | + description: 'Test on Linux' |
| 12 | + type: boolean |
| 13 | + default: true |
| 14 | + test_macos: |
| 15 | + description: 'Test on MacOS' |
| 16 | + type: boolean |
| 17 | + default: true |
| 18 | + test_windows: |
| 19 | + description: 'Test on Windows' |
| 20 | + type: boolean |
| 21 | + default: true |
| 22 | + |
| 23 | +concurrency: |
| 24 | + group: ${{ github.workflow }}-${{ github.ref || github.run_id }} |
| 25 | + cancel-in-progress: true |
| 26 | + |
| 27 | +env: |
| 28 | + GTEST_FILTER: ${{ github.event.inputs.gtest_filter || '*' }} |
| 29 | + |
| 30 | +jobs: |
| 31 | + ubuntu: |
| 32 | + runs-on: ubuntu-24.04 |
| 33 | + if: > |
| 34 | + (github.event_name == 'push') || |
| 35 | + (github.event_name == 'pull_request' && |
| 36 | + github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name) || |
| 37 | + (github.event_name == 'workflow_dispatch' && github.event.inputs.test_linux == 'true') |
| 38 | + steps: |
| 39 | + - name: checkout |
| 40 | + uses: actions/checkout@v4 |
| 41 | + - name: install libraries |
| 42 | + run: | |
| 43 | + sudo apt-get update |
| 44 | + sudo apt-get install -y libssl-dev libcurl4-openssl-dev \ |
| 45 | + zlib1g-dev libbrotli-dev libzstd-dev |
| 46 | + - name: build and run C++20 streaming tests |
| 47 | + run: cd test && make test-stream && ./test-stream --gtest_filter="${GTEST_FILTER}" |
| 48 | + |
| 49 | + macos: |
| 50 | + runs-on: macos-latest |
| 51 | + if: > |
| 52 | + (github.event_name == 'push') || |
| 53 | + (github.event_name == 'pull_request' && |
| 54 | + github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name) || |
| 55 | + (github.event_name == 'workflow_dispatch' && github.event.inputs.test_macos == 'true') |
| 56 | + steps: |
| 57 | + - name: checkout |
| 58 | + uses: actions/checkout@v4 |
| 59 | + - name: build and run C++20 streaming tests |
| 60 | + run: cd test && make test-stream && ./test-stream --gtest_filter="${GTEST_FILTER}" |
| 61 | + |
| 62 | + windows: |
| 63 | + runs-on: windows-latest |
| 64 | + if: > |
| 65 | + (github.event_name == 'push') || |
| 66 | + (github.event_name == 'pull_request' && |
| 67 | + github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name) || |
| 68 | + (github.event_name == 'workflow_dispatch' && github.event.inputs.test_windows == 'true') |
| 69 | + strategy: |
| 70 | + matrix: |
| 71 | + config: |
| 72 | + - with_ssl: false |
| 73 | + name: without SSL |
| 74 | + - with_ssl: true |
| 75 | + name: with SSL |
| 76 | + name: windows ${{ matrix.config.name }} |
| 77 | + steps: |
| 78 | + - name: Prepare Git for Checkout on Windows |
| 79 | + run: | |
| 80 | + git config --global core.autocrlf false |
| 81 | + git config --global core.eol lf |
| 82 | + - name: Checkout |
| 83 | + uses: actions/checkout@v4 |
| 84 | + - name: Export GitHub Actions cache environment variables |
| 85 | + uses: actions/github-script@v7 |
| 86 | + with: |
| 87 | + script: | |
| 88 | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); |
| 89 | + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); |
| 90 | + - name: Setup msbuild on windows |
| 91 | + uses: microsoft/setup-msbuild@v2 |
| 92 | + - name: Install vcpkg dependencies |
| 93 | + run: vcpkg install gtest curl zlib brotli zstd |
| 94 | + - name: Install OpenSSL |
| 95 | + if: ${{ matrix.config.with_ssl }} |
| 96 | + run: choco install openssl |
| 97 | + - name: Configure CMake ${{ matrix.config.name }} |
| 98 | + run: > |
| 99 | + cmake -B build -S . |
| 100 | + -DCMAKE_BUILD_TYPE=Release |
| 101 | + -DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake |
| 102 | + -DHTTPLIB_TEST=ON |
| 103 | + -DHTTPLIB_REQUIRE_ZLIB=ON |
| 104 | + -DHTTPLIB_REQUIRE_BROTLI=ON |
| 105 | + -DHTTPLIB_REQUIRE_ZSTD=ON |
| 106 | + -DHTTPLIB_REQUIRE_OPENSSL=${{ matrix.config.with_ssl && 'ON' || 'OFF' }} |
| 107 | + - name: Build ${{ matrix.config.name }} |
| 108 | + run: cmake --build build --config Release --target httplib-test-stream |
| 109 | + - name: Run C++20 streaming tests ${{ matrix.config.name }} |
| 110 | + working-directory: build/test |
| 111 | + run: Release\httplib-test-stream.exe |
| 112 | + |
| 113 | + env: |
| 114 | + VCPKG_ROOT: "C:/vcpkg" |
| 115 | + VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" |
0 commit comments