Skip to content

Commit c98c546

Browse files
committed
Refactor GitHub Actions workflow to separate OpenSSL and MbedTLS jobs for Ubuntu and macOS, and add benchmark testing for Windows
1 parent 9a63a86 commit c98c546

File tree

3 files changed

+236
-53
lines changed

3 files changed

+236
-53
lines changed

.github/workflows/test.yaml

Lines changed: 224 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,15 @@ jobs:
6868
run: cd test && make test EXTRA_CXXFLAGS="${{ matrix.config.arch_flags }}"
6969
continue-on-error: true
7070

71-
ubuntu:
71+
72+
ubuntu_openssl:
7273
runs-on: ubuntu-latest
7374
if: >
7475
(github.event_name == 'push') ||
7576
(github.event_name == 'pull_request' &&
7677
github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name) ||
7778
(github.event_name == 'workflow_dispatch' && github.event.inputs.test_linux == 'true')
78-
strategy:
79-
matrix:
80-
tls_backend: [openssl, mbedtls]
81-
name: ubuntu (${{ matrix.tls_backend }})
79+
name: ubuntu (openssl)
8280
steps:
8381
- name: checkout
8482
uses: actions/checkout@v4
@@ -87,71 +85,156 @@ jobs:
8785
sudo apt-get update
8886
sudo apt-get install -y libcurl4-openssl-dev zlib1g-dev libbrotli-dev libzstd-dev
8987
- name: install OpenSSL
90-
if: matrix.tls_backend == 'openssl'
9188
run: sudo apt-get install -y libssl-dev
92-
- name: install Mbed TLS
93-
if: matrix.tls_backend == 'mbedtls'
94-
run: sudo apt-get install -y libmbedtls-dev
9589
- name: build and run tests (OpenSSL)
96-
if: matrix.tls_backend == 'openssl'
9790
run: cd test && make
91+
- name: run fuzz test target
92+
run: cd test && make fuzz_test
93+
94+
ubuntu_mbedtls:
95+
runs-on: ubuntu-latest
96+
needs: ubuntu_openssl
97+
if: >
98+
(github.event_name == 'push') ||
99+
(github.event_name == 'pull_request' &&
100+
github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name) ||
101+
(github.event_name == 'workflow_dispatch' && github.event.inputs.test_linux == 'true')
102+
name: ubuntu (mbedtls)
103+
steps:
104+
- name: checkout
105+
uses: actions/checkout@v4
106+
- name: install common libraries
107+
run: |
108+
sudo apt-get update
109+
sudo apt-get install -y libcurl4-openssl-dev zlib1g-dev libbrotli-dev libzstd-dev
110+
- name: install Mbed TLS
111+
run: sudo apt-get install -y libmbedtls-dev
98112
- name: build and run tests (Mbed TLS)
99-
if: matrix.tls_backend == 'mbedtls'
100113
run: cd test && make test_split_mbedtls && make test_mbedtls && ./test_mbedtls
114+
115+
ubuntu_no_tls:
116+
runs-on: ubuntu-latest
117+
if: >
118+
(github.event_name == 'push') ||
119+
(github.event_name == 'pull_request' &&
120+
github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name) ||
121+
(github.event_name == 'workflow_dispatch' && github.event.inputs.test_linux == 'true')
122+
name: ubuntu (no TLS)
123+
steps:
124+
- name: checkout
125+
uses: actions/checkout@v4
126+
- name: install common libraries
127+
run: |
128+
sudo apt-get update
129+
sudo apt-get install -y libcurl4-openssl-dev zlib1g-dev libbrotli-dev libzstd-dev
130+
- name: build and run tests (no TLS)
131+
run: cd test && make test_no_tls && make test_split_no_tls && ./test_no_tls
132+
133+
134+
macos_openssl:
135+
runs-on: macos-latest
136+
if: >
137+
(github.event_name == 'push') ||
138+
(github.event_name == 'pull_request' &&
139+
github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name) ||
140+
(github.event_name == 'workflow_dispatch' && github.event.inputs.test_macos == 'true')
141+
name: macos (openssl)
142+
steps:
143+
- name: checkout
144+
uses: actions/checkout@v4
145+
- name: build and run tests (OpenSSL)
146+
run: cd test && make
101147
- name: run fuzz test target
102-
if: matrix.tls_backend == 'openssl'
103148
run: cd test && make fuzz_test
104149

105-
macos:
150+
macos_mbedtls:
106151
runs-on: macos-latest
152+
needs: macos_openssl
107153
if: >
108154
(github.event_name == 'push') ||
109155
(github.event_name == 'pull_request' &&
110156
github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name) ||
111157
(github.event_name == 'workflow_dispatch' && github.event.inputs.test_macos == 'true')
112-
strategy:
113-
matrix:
114-
tls_backend: [openssl, mbedtls]
115-
name: macos (${{ matrix.tls_backend }})
158+
name: macos (mbedtls)
116159
steps:
117160
- name: checkout
118161
uses: actions/checkout@v4
119162
- name: install Mbed TLS
120-
if: matrix.tls_backend == 'mbedtls'
121163
run: brew install mbedtls@3
122-
- name: build and run tests (OpenSSL)
123-
if: matrix.tls_backend == 'openssl'
124-
run: cd test && make
125164
- name: build and run tests (Mbed TLS)
126-
if: matrix.tls_backend == 'mbedtls'
127165
run: cd test && make test_split_mbedtls && make test_mbedtls && ./test_mbedtls
128-
- name: run fuzz test target
129-
if: matrix.tls_backend == 'openssl'
130-
run: cd test && make fuzz_test
131166

132-
windows:
167+
macos_no_tls:
168+
runs-on: macos-latest
169+
needs: macos_openssl
170+
if: >
171+
(github.event_name == 'push') ||
172+
(github.event_name == 'pull_request' &&
173+
github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name) ||
174+
(github.event_name == 'workflow_dispatch' && github.event.inputs.test_macos == 'true')
175+
name: macos (no TLS)
176+
steps:
177+
- name: checkout
178+
uses: actions/checkout@v4
179+
- name: build and run tests (no TLS)
180+
run: cd test && make test_split_no_tls && make test_no_tls && ./test_no_tls
181+
182+
183+
windows_without_ssl:
133184
runs-on: windows-latest
134185
if: >
135186
(github.event_name == 'push') ||
136187
(github.event_name == 'pull_request' &&
137188
github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name) ||
138189
(github.event_name == 'workflow_dispatch' && github.event.inputs.test_windows == 'true')
139-
strategy:
140-
matrix:
141-
config:
142-
- with_ssl: false
143-
compiled: false
144-
run_tests: true
145-
name: without SSL
146-
- with_ssl: true
147-
compiled: false
148-
run_tests: true
149-
name: with SSL
150-
- with_ssl: false
151-
compiled: true
152-
run_tests: false
153-
name: compiled
154-
name: windows ${{ matrix.config.name }}
190+
name: windows (without SSL)
191+
steps:
192+
- name: Prepare Git for Checkout on Windows
193+
run: |
194+
git config --global core.autocrlf false
195+
git config --global core.eol lf
196+
- name: Checkout
197+
uses: actions/checkout@v4
198+
- name: Export GitHub Actions cache environment variables
199+
uses: actions/github-script@v7
200+
with:
201+
script: |
202+
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
203+
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
204+
- name: Setup msbuild on windows
205+
uses: microsoft/setup-msbuild@v2
206+
- name: Install vcpkg dependencies
207+
run: vcpkg install gtest curl zlib brotli zstd
208+
- name: Configure CMake without SSL
209+
run: >
210+
cmake -B build -S .
211+
-DCMAKE_BUILD_TYPE=Release
212+
-DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake
213+
-DHTTPLIB_TEST=ON
214+
-DHTTPLIB_COMPILE=OFF
215+
-DHTTPLIB_USE_OPENSSL_IF_AVAILABLE=OFF
216+
-DHTTPLIB_REQUIRE_ZLIB=ON
217+
-DHTTPLIB_REQUIRE_BROTLI=ON
218+
-DHTTPLIB_REQUIRE_ZSTD=ON
219+
-DHTTPLIB_REQUIRE_OPENSSL=OFF
220+
- name: Build without SSL
221+
run: cmake --build build --config Release -- /v:m /clp:ShowCommandLine
222+
- name: Run tests without SSL
223+
run: ctest --output-on-failure --test-dir build -C Release -E "BenchmarkTest"
224+
225+
env:
226+
VCPKG_ROOT: "C:/vcpkg"
227+
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
228+
229+
windows_with_ssl:
230+
runs-on: windows-latest
231+
needs: windows_without_ssl
232+
if: >
233+
(github.event_name == 'push') ||
234+
(github.event_name == 'pull_request' &&
235+
github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name) ||
236+
(github.event_name == 'workflow_dispatch' && github.event.inputs.test_windows == 'true')
237+
name: windows (with SSL)
155238
steps:
156239
- name: Prepare Git for Checkout on Windows
157240
run: |
@@ -170,27 +253,116 @@ jobs:
170253
- name: Install vcpkg dependencies
171254
run: vcpkg install gtest curl zlib brotli zstd
172255
- name: Install OpenSSL
173-
if: ${{ matrix.config.with_ssl }}
174256
run: choco install openssl
175-
- name: Configure CMake ${{ matrix.config.name }}
257+
- name: Configure CMake with SSL
176258
run: >
177259
cmake -B build -S .
178260
-DCMAKE_BUILD_TYPE=Release
179261
-DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake
180262
-DHTTPLIB_TEST=ON
181-
-DHTTPLIB_COMPILE=${{ matrix.config.compiled && 'ON' || 'OFF' }}
182-
-DHTTPLIB_USE_OPENSSL_IF_AVAILABLE=${{ matrix.config.with_ssl && 'ON' || 'OFF' }}
263+
-DHTTPLIB_COMPILE=OFF
264+
-DHTTPLIB_USE_OPENSSL_IF_AVAILABLE=ON
183265
-DHTTPLIB_REQUIRE_ZLIB=ON
184266
-DHTTPLIB_REQUIRE_BROTLI=ON
185267
-DHTTPLIB_REQUIRE_ZSTD=ON
186-
-DHTTPLIB_REQUIRE_OPENSSL=${{ matrix.config.with_ssl && 'ON' || 'OFF' }}
187-
- name: Build ${{ matrix.config.name }}
268+
-DHTTPLIB_REQUIRE_OPENSSL=ON
269+
- name: Build with SSL
188270
run: cmake --build build --config Release -- /v:m /clp:ShowCommandLine
189-
- name: Run tests ${{ matrix.config.name }}
190-
if: ${{ matrix.config.run_tests }}
271+
- name: Run tests with SSL
191272
run: ctest --output-on-failure --test-dir build -C Release -E "BenchmarkTest"
192-
- name: Run benchmark tests with retry ${{ matrix.config.name }}
193-
if: ${{ matrix.config.run_tests }}
273+
274+
env:
275+
VCPKG_ROOT: "C:/vcpkg"
276+
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
277+
278+
windows_compiled:
279+
runs-on: windows-latest
280+
needs: windows_with_ssl
281+
if: >
282+
(github.event_name == 'push') ||
283+
(github.event_name == 'pull_request' &&
284+
github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name) ||
285+
(github.event_name == 'workflow_dispatch' && github.event.inputs.test_windows == 'true')
286+
name: windows (compiled)
287+
steps:
288+
- name: Prepare Git for Checkout on Windows
289+
run: |
290+
git config --global core.autocrlf false
291+
git config --global core.eol lf
292+
- name: Checkout
293+
uses: actions/checkout@v4
294+
- name: Export GitHub Actions cache environment variables
295+
uses: actions/github-script@v7
296+
with:
297+
script: |
298+
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
299+
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
300+
- name: Setup msbuild on windows
301+
uses: microsoft/setup-msbuild@v2
302+
- name: Install vcpkg dependencies
303+
run: vcpkg install gtest curl zlib brotli zstd
304+
- name: Configure CMake compiled
305+
run: >
306+
cmake -B build -S .
307+
-DCMAKE_BUILD_TYPE=Release
308+
-DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake
309+
-DHTTPLIB_TEST=ON
310+
-DHTTPLIB_COMPILE=ON
311+
-DHTTPLIB_USE_OPENSSL_IF_AVAILABLE=OFF
312+
-DHTTPLIB_REQUIRE_ZLIB=ON
313+
-DHTTPLIB_REQUIRE_BROTLI=ON
314+
-DHTTPLIB_REQUIRE_ZSTD=ON
315+
-DHTTPLIB_REQUIRE_OPENSSL=OFF
316+
- name: Build compiled
317+
run: cmake --build build --config Release -- /v:m /clp:ShowCommandLine
318+
319+
env:
320+
VCPKG_ROOT: "C:/vcpkg"
321+
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
322+
323+
windows_benchmark:
324+
runs-on: windows-latest
325+
needs: windows_compiled
326+
if: >
327+
(github.event_name == 'push') ||
328+
(github.event_name == 'pull_request' &&
329+
github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name) ||
330+
(github.event_name == 'workflow_dispatch' && github.event.inputs.test_windows == 'true')
331+
name: windows (BenchmarkTest)
332+
steps:
333+
- name: Prepare Git for Checkout on Windows
334+
run: |
335+
git config --global core.autocrlf false
336+
git config --global core.eol lf
337+
- name: Checkout
338+
uses: actions/checkout@v4
339+
- name: Export GitHub Actions cache environment variables
340+
uses: actions/github-script@v7
341+
with:
342+
script: |
343+
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
344+
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
345+
- name: Setup msbuild on windows
346+
uses: microsoft/setup-msbuild@v2
347+
- name: Install vcpkg dependencies
348+
run: vcpkg install gtest curl zlib brotli zstd
349+
- name: Install OpenSSL
350+
run: choco install openssl
351+
- name: Configure CMake BenchmarkTest
352+
run: >
353+
cmake -B build -S .
354+
-DCMAKE_BUILD_TYPE=Release
355+
-DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake
356+
-DHTTPLIB_TEST=ON
357+
-DHTTPLIB_COMPILE=OFF
358+
-DHTTPLIB_USE_OPENSSL_IF_AVAILABLE=ON
359+
-DHTTPLIB_REQUIRE_ZLIB=ON
360+
-DHTTPLIB_REQUIRE_BROTLI=ON
361+
-DHTTPLIB_REQUIRE_ZSTD=ON
362+
-DHTTPLIB_REQUIRE_OPENSSL=ON
363+
- name: Build BenchmarkTest
364+
run: cmake --build build --config Release -- /v:m /clp:ShowCommandLine
365+
- name: Run benchmark tests with retry
194366
run: ctest --output-on-failure --test-dir build -C Release -R "BenchmarkTest" --repeat until-pass:5
195367

196368
env:

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ test/httplib.cc
3434
test/httplib.h
3535
test/test
3636
test/test_mbedtls
37+
test/test_no_tls
3738
test/server_fuzzer
3839
test/test_proxy
3940
test/test_proxy_mbedtls
4041
test/test_split
4142
test/test_split_mbedtls
43+
test/test_split_no_tls
4244
test/test.xcodeproj/xcuser*
4345
test/test.xcodeproj/*/xcuser*
4446
test/*.o

test/Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ endif
3838

3939
TEST_ARGS = gtest/src/gtest-all.cc gtest/src/gtest_main.cc -Igtest -Igtest/include $(OPENSSL_SUPPORT) $(ZLIB_SUPPORT) $(BROTLI_SUPPORT) $(ZSTD_SUPPORT) $(LIBS)
4040
TEST_ARGS_MBEDTLS = gtest/src/gtest-all.cc gtest/src/gtest_main.cc -Igtest -Igtest/include $(MBEDTLS_SUPPORT) $(ZLIB_SUPPORT) $(BROTLI_SUPPORT) $(ZSTD_SUPPORT) $(LIBS)
41+
TEST_ARGS_NO_TLS = gtest/src/gtest-all.cc gtest/src/gtest_main.cc -Igtest -Igtest/include $(ZLIB_SUPPORT) $(BROTLI_SUPPORT) $(ZSTD_SUPPORT) $(LIBS)
4142

4243
# By default, use standalone_fuzz_target_runner.
4344
# This runner does no fuzzing, but simply executes the inputs
@@ -110,6 +111,14 @@ test_mbedtls : test.cc include_httplib.cc ../httplib.h Makefile cert.pem
110111
test_split_mbedtls : test.cc ../httplib.h httplib.cc Makefile cert.pem
111112
$(CXX) -o $@ $(CXXFLAGS) test.cc httplib.cc $(TEST_ARGS_MBEDTLS)
112113

114+
# No TLS
115+
test_no_tls : test.cc include_httplib.cc ../httplib.h Makefile
116+
$(CXX) -o $@ -I.. $(CXXFLAGS) test.cc include_httplib.cc $(TEST_ARGS_NO_TLS)
117+
@file $@
118+
119+
test_split_no_tls : test.cc ../httplib.h httplib.cc Makefile
120+
$(CXX) -o $@ $(CXXFLAGS) test.cc httplib.cc $(TEST_ARGS_NO_TLS)
121+
113122
check_abi:
114123
@./check-shared-library-abi-compatibility.sh
115124

@@ -163,5 +172,5 @@ cert.pem:
163172
./gen-certs.sh
164173

165174
clean:
166-
rm -rf test test_split test_mbedtls test_split_mbedtls test_proxy test_proxy_mbedtls server_fuzzer *.pem *.0 *.o *.1 *.srl httplib.h httplib.cc _build* *.dSYM
175+
rm -rf test test_split test_mbedtls test_split_mbedtls test_no_tls, test_split_no_tls test_proxy test_proxy_mbedtls server_fuzzer *.pem *.0 *.o *.1 *.srl httplib.h httplib.cc _build* *.dSYM
167176

0 commit comments

Comments
 (0)