• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1name: build
2
3on: [push, pull_request]
4
5permissions: read-all
6
7env:
8  LIBBPF_VERSION: v1.2.2
9  OPENSSL1_VERSION: 1_1_1w+quic
10  OPENSSL3_VERSION: 3.1.2+quic
11  BORINGSSL_VERSION: 6ca49385b168f47a50e7172d82a590b218f55e4d
12  NGHTTP3_VERSION: v1.0.0
13  NGTCP2_VERSION: v1.0.1
14
15jobs:
16  build-cache:
17    strategy:
18      matrix:
19        os: [ubuntu-22.04, macos-12]
20
21    runs-on: ${{ matrix.os }}
22
23    steps:
24    - uses: actions/checkout@v4
25    - name: Restore libbpf cache
26      id: cache-libbpf
27      uses: actions/cache@v3
28      if: runner.os == 'Linux'
29      with:
30        path: libbpf/build
31        key: ${{ runner.os }}-libbpf-${{ env.LIBBPF_VERSION }}
32    - name: Restore OpenSSL v1.1.1 cache
33      id: cache-openssl1
34      uses: actions/cache@v3
35      with:
36        path: openssl1/build
37        key: ${{ runner.os }}-openssl-${{ env.OPENSSL1_VERSION }}
38    - name: Restore OpenSSL v3.x cache
39      id: cache-openssl3
40      uses: actions/cache@v3
41      with:
42        path: openssl3/build
43        key: ${{ runner.os }}-openssl-${{ env.OPENSSL3_VERSION }}
44    - name: Restore BoringSSL cache
45      id: cache-boringssl
46      uses: actions/cache@v3
47      with:
48        path: |
49          boringssl/build/crypto/libcrypto.a
50          boringssl/build/ssl/libssl.a
51          boringssl/include
52        key: ${{ runner.os }}-boringssl-${{ env.BORINGSSL_VERSION }}
53    - name: Restore nghttp3 cache
54      id: cache-nghttp3
55      uses: actions/cache@v3
56      with:
57        path: nghttp3/build
58        key: ${{ runner.os }}-nghttp3-${{ env.NGHTTP3_VERSION }}
59    - name: Restore ngtcp2 + quictls/openssl v1.1.1 cache
60      id: cache-ngtcp2-openssl1
61      uses: actions/cache@v3
62      with:
63        path: ngtcp2-openssl1/build
64        key: ${{ runner.os }}-ngtcp2-${{ env.NGTCP2_VERSION }}-openssl-${{ env.OPENSSL1_VERSION }}
65    - name: Restore ngtcp2 + quictls/openssl v3.x cache
66      id: cache-ngtcp2-openssl3
67      uses: actions/cache@v3
68      with:
69        path: ngtcp2-openssl3/build
70        key: ${{ runner.os }}-ngtcp2-${{ env.NGTCP2_VERSION }}-openssl-${{ env.OPENSSL3_VERSION }}
71    - id: settings
72      if: |
73        (steps.cache-libbpf.outputs.cache-hit != 'true' && runner.os == 'Linux') ||
74        steps.cache-openssl1.outputs.cache-hit != 'true' ||
75        steps.cache-openssl3.outputs.cache-hit != 'true' ||
76        steps.cache-boringssl.outputs.cache-hit != 'true' ||
77        steps.cache-nghttp3.outputs.cache-hit != 'true' ||
78        steps.cache-ngtcp2-openssl1.outputs.cache-hit != 'true' ||
79        steps.cache-ngtcp2-openssl3.outputs.cache-hit != 'true'
80      run: |
81        echo 'needs-build=true' >> $GITHUB_OUTPUT
82    - name: Linux setup
83      if: runner.os == 'Linux' && steps.settings.outputs.needs-build == 'true'
84      run: |
85        sudo apt-get install \
86          g++-12 \
87          clang-14 \
88          autoconf \
89          automake \
90          autotools-dev \
91          libtool \
92          pkg-config \
93          libelf-dev \
94          cmake \
95          cmake-data
96    - name: MacOS setup
97      if: runner.os == 'macOS' && steps.settings.outputs.needs-build == 'true'
98      run: |
99        brew install \
100          autoconf \
101          automake \
102          pkg-config \
103          libtool
104    - name: Build libbpf
105      if: steps.cache-libbpf.outputs.cache-hit != 'true' && runner.os == 'Linux'
106      run: |
107        git clone -b ${{ env.LIBBPF_VERSION }} https://github.com/libbpf/libbpf
108        cd libbpf
109        make -C src install PREFIX=$PWD/build
110    - name: Build quictls/openssl v1.1.1
111      if: steps.cache-openssl1.outputs.cache-hit != 'true'
112      run: |
113        git clone --depth 1 -b OpenSSL_${{ env.OPENSSL1_VERSION }} https://github.com/quictls/openssl openssl1
114        cd openssl1
115        ./config --prefix=$PWD/build
116        make -j"$(nproc 2> /dev/null || sysctl -n hw.ncpu)"
117        make install_sw
118    - name: Build quictls/openssl v3.x
119      if: steps.cache-openssl3.outputs.cache-hit != 'true'
120      run: |
121        git clone --depth 1 -b openssl-${{ env.OPENSSL3_VERSION }} https://github.com/quictls/openssl openssl3
122        cd openssl3
123        ./config enable-ktls --prefix=$PWD/build --libdir=$PWD/build/lib
124        make -j"$(nproc 2> /dev/null || sysctl -n hw.ncpu)"
125        make install_sw
126    - name: Build BoringSSL
127      if: steps.cache-boringssl.outputs.cache-hit != 'true'
128      run: |
129        git clone https://boringssl.googlesource.com/boringssl
130        cd boringssl
131        git checkout ${{ env.BORINGSSL_VERSION }}
132        mkdir build
133        cd build
134        cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON ..
135        make -j"$(nproc 2> /dev/null || sysctl -n hw.ncpu)"
136    - name: Build nghttp3
137      if: steps.cache-nghttp3.outputs.cache-hit != 'true'
138      run: |
139        git clone --depth 1 -b ${{ env.NGHTTP3_VERSION}} https://github.com/ngtcp2/nghttp3
140        cd nghttp3
141        autoreconf -i
142        ./configure --prefix=$PWD/build --enable-lib-only
143        make -j"$(nproc 2> /dev/null || sysctl -n hw.ncpu)" check
144        make install
145    - name: Build ngtcp2 + quictls/openssl v1.1.1
146      if: steps.cache-ngtcp2-openssl1.outputs.cache-hit != 'true'
147      run: |
148        git clone --depth 1 -b ${{ env.NGTCP2_VERSION }} https://github.com/ngtcp2/ngtcp2 ngtcp2-openssl1
149        cd ngtcp2-openssl1
150        autoreconf -i
151        ./configure --prefix=$PWD/build --enable-lib-only \
152          PKG_CONFIG_PATH="../openssl1/build/lib/pkgconfig" \
153          BORINGSSL_CFLAGS="-I$PWD/../boringssl/include/" \
154          BORINGSSL_LIBS="-L$PWD/../boringssl/build/ssl -lssl -L$PWD/../boringssl/build/crypto -lcrypto" \
155          --with-boringssl
156        make -j"$(nproc 2> /dev/null || sysctl -n hw.ncpu)" check
157        make install
158    - name: Build ngtcp2 + quictls/openssl v3.x
159      if: steps.cache-ngtcp2-openssl3.outputs.cache-hit != 'true'
160      run: |
161        git clone --depth 1 -b ${{ env.NGTCP2_VERSION }} https://github.com/ngtcp2/ngtcp2 ngtcp2-openssl3
162        cd ngtcp2-openssl3
163        autoreconf -i
164        ./configure --prefix=$PWD/build --enable-lib-only \
165          PKG_CONFIG_PATH="../openssl3/build/lib/pkgconfig" \
166          BORINGSSL_CFLAGS="-I$PWD/../boringssl/include/" \
167          BORINGSSL_LIBS="-L$PWD/../boringssl/build/ssl -lssl -L$PWD/../boringssl/build/crypto -lcrypto" \
168          --with-boringssl
169        make -j"$(nproc 2> /dev/null || sysctl -n hw.ncpu)" check
170        make install
171
172  build:
173    needs:
174    - build-cache
175
176    strategy:
177      matrix:
178        os: [ubuntu-22.04, macos-12]
179        compiler: [gcc, clang]
180        buildtool: [autotools, cmake]
181        http3: [http3, no-http3]
182        openssl: [openssl1, openssl3, boringssl]
183        exclude:
184        - os: macos-12
185          openssl: openssl3
186        - http3: no-http3
187          openssl: openssl3
188        - os: macos-12
189          compiler: gcc
190        - # disable macos cmake because of include path issue
191          os: macos-12
192          buildtool: cmake
193        - os: macos-12
194          openssl: boringssl
195        - openssl: boringssl
196          buildtool: cmake
197        - openssl: boringssl
198          compiler: gcc
199
200    runs-on: ${{ matrix.os }}
201
202    steps:
203    - uses: actions/checkout@v4
204    - name: Linux setup
205      if: runner.os == 'Linux'
206      run: |
207        sudo apt-get install \
208          g++-12 \
209          clang-14 \
210          autoconf \
211          automake \
212          autotools-dev \
213          libtool \
214          pkg-config \
215          zlib1g-dev \
216          libcunit1-dev \
217          libssl-dev \
218          libxml2-dev \
219          libev-dev \
220          libevent-dev \
221          libjansson-dev \
222          libjemalloc-dev \
223          libc-ares-dev \
224          libelf-dev \
225          cmake \
226          cmake-data
227        echo 'CPPFLAGS=-fsanitize=address,undefined -fno-sanitize-recover=undefined -g' >> $GITHUB_ENV
228        echo 'LDFLAGS=-fsanitize=address,undefined -fno-sanitize-recover=undefined' >> $GITHUB_ENV
229    - name: MacOS setup
230      if: runner.os == 'macOS'
231      run: |
232        brew install \
233          libev \
234          libevent \
235          c-ares \
236          cunit \
237          libressl \
238          autoconf \
239          automake \
240          pkg-config \
241          libtool
242        echo 'PKG_CONFIG_PATH=/usr/local/opt/libressl/lib/pkgconfig:/usr/local/opt/libxml2/lib/pkgconfig' >> $GITHUB_ENV
243    - name: Setup clang (Linux)
244      if: runner.os == 'Linux' && matrix.compiler == 'clang'
245      run: |
246        echo 'CC=clang-14' >> $GITHUB_ENV
247        echo 'CXX=clang++-14' >> $GITHUB_ENV
248    - name: Setup clang (MacOS)
249      if: runner.os == 'macOS' && matrix.compiler == 'clang'
250      run: |
251        echo 'CC=clang' >> $GITHUB_ENV
252        echo 'CXX=clang++' >> $GITHUB_ENV
253    - name: Setup gcc (Linux)
254      if: runner.os == 'Linux' && matrix.compiler == 'gcc'
255      run: |
256        echo 'CC=gcc-12' >> $GITHUB_ENV
257        echo 'CXX=g++-12' >> $GITHUB_ENV
258    - name: Setup gcc (MacOS)
259      if: runner.os == 'macOS' && matrix.compiler == 'gcc'
260      run: |
261        echo 'CC=gcc' >> $GITHUB_ENV
262        echo 'CXX=g++' >> $GITHUB_ENV
263    - name: Restore libbpf cache
264      uses: actions/cache/restore@v3
265      if: matrix.http3 == 'http3' && matrix.compiler == 'clang' && runner.os == 'Linux'
266      with:
267        path: libbpf/build
268        key: ${{ runner.os }}-libbpf-${{ env.LIBBPF_VERSION }}
269        fail-on-cache-miss: true
270    - name: Set libbpf variables
271      if: matrix.http3 == 'http3' && matrix.compiler == 'clang' && runner.os == 'Linux'
272      run: |
273        cd libbpf
274
275        EXTRA_AUTOTOOLS_OPTS="--with-libbpf"
276        EXTRA_CMAKE_OPTS="-DWITH_LIBBPF=1"
277
278        echo 'EXTRA_AUTOTOOLS_OPTS='"$EXTRA_AUTOTOOLS_OPTS" >> $GITHUB_ENV
279        echo 'EXTRA_CMAKE_OPTS='"$EXTRA_CMAKE_OPTS" >> $GITHUB_ENV
280    - name: Restore quictls/openssl v1.1.1 cache
281      uses: actions/cache/restore@v3
282      if: matrix.http3 == 'http3' && matrix.openssl == 'openssl1'
283      with:
284        path: openssl1/build
285        key: ${{ runner.os }}-openssl-${{ env.OPENSSL1_VERSION }}
286        fail-on-cache-miss: true
287    - name: Restore quictls/openssl v3.x cache
288      uses: actions/cache/restore@v3
289      if: matrix.http3 == 'http3' && matrix.openssl == 'openssl3'
290      with:
291        path: openssl3/build
292        key: ${{ runner.os }}-openssl-${{ env.OPENSSL3_VERSION }}
293        fail-on-cache-miss: true
294    - name: Restore BoringSSL cache
295      uses: actions/cache/restore@v3
296      if: matrix.openssl == 'boringssl'
297      with:
298        path: |
299          boringssl/build/crypto/libcrypto.a
300          boringssl/build/ssl/libssl.a
301          boringssl/include
302        key: ${{ runner.os }}-boringssl-${{ env.BORINGSSL_VERSION }}
303        fail-on-cache-miss: true
304    - name: Set BoringSSL variables
305      if: matrix.openssl == 'boringssl'
306      run: |
307        cd boringssl
308
309        OPENSSL_CFLAGS="-I$PWD/include/"
310        OPENSSL_LIBS="-L$PWD/build/ssl -lssl -L$PWD/build/crypto -lcrypto -pthread"
311        EXTRA_AUTOTOOLS_OPTS="$EXTRA_AUTOTOOLS_OPTS --without-neverbleed --without-jemalloc"
312
313        echo 'OPENSSL_CFLAGS='"$OPENSSL_CFLAGS" >> $GITHUB_ENV
314        echo 'OPENSSL_LIBS='"$OPENSSL_LIBS" >> $GITHUB_ENV
315        echo 'BORINGSSL_CFLAGS='"$OPENSSL_CFLAGS" >> $GITHUB_ENV
316        echo 'BORINGSSL_LIBS='"$OPENSSL_LIBS" >> $GITHUB_ENV
317        echo 'EXTRA_AUTOTOOLS_OPTS='"$EXTRA_AUTOTOOLS_OPTS" >> $GITHUB_ENV
318    - name: Restore nghttp3 cache
319      uses: actions/cache/restore@v3
320      if: matrix.http3 == 'http3'
321      with:
322        path: nghttp3/build
323        key: ${{ runner.os }}-nghttp3-${{ env.NGHTTP3_VERSION }}
324        fail-on-cache-miss: true
325    - name: Restore ngtcp2 + quictls/openssl v1.1.1 cache
326      uses: actions/cache/restore@v3
327      if: matrix.http3 == 'http3' && (matrix.openssl == 'openssl1' || matrix.openssl == 'boringssl')
328      with:
329        path: ngtcp2-openssl1/build
330        key: ${{ runner.os }}-ngtcp2-${{ env.NGTCP2_VERSION }}-openssl-${{ env.OPENSSL1_VERSION }}
331        fail-on-cache-miss: true
332    - name: Restore ngtcp2 + quictls/openssl v3.x cache
333      uses: actions/cache/restore@v3
334      if: matrix.http3 == 'http3' && matrix.openssl == 'openssl3'
335      with:
336        path: ngtcp2-openssl3/build
337        key: ${{ runner.os }}-ngtcp2-${{ env.NGTCP2_VERSION }}-openssl-${{ env.OPENSSL3_VERSION }}
338        fail-on-cache-miss: true
339    - name: Setup extra environment variables for HTTP/3
340      if: matrix.http3 == 'http3'
341      run: |
342        PKG_CONFIG_PATH="$PWD/openssl1/build/lib/pkgconfig:$PWD/openssl3/build/lib/pkgconfig:$PWD/nghttp3/build/lib/pkgconfig:$PWD/ngtcp2-openssl1/build/lib/pkgconfig:$PWD/ngtcp2-openssl3/build/lib/pkgconfig:$PWD/libbpf/build/lib64/pkgconfig:$PKG_CONFIG_PATH"
343        LDFLAGS="$LDFLAGS -Wl,-rpath,$PWD/openssl1/build/lib -Wl,-rpath,$PWD/openssl3/build/lib -Wl,-rpath,$PWD/libbpf/build/lib64"
344        EXTRA_AUTOTOOLS_OPTS="--enable-http3 $EXTRA_AUTOTOOLS_OPTS"
345        EXTRA_CMAKE_OPTS="-DENABLE_HTTP3=1 $EXTRA_CMAKE_OPTS"
346
347        echo 'PKG_CONFIG_PATH='"$PKG_CONFIG_PATH" >> $GITHUB_ENV
348        echo 'LDFLAGS='"$LDFLAGS" >> $GITHUB_ENV
349        echo 'EXTRA_AUTOTOOLS_OPTS='"$EXTRA_AUTOTOOLS_OPTS" >> $GITHUB_ENV
350        echo 'EXTRA_CMAKE_OPTS='"$EXTRA_CMAKE_OPTS" >> $GITHUB_ENV
351    - name: Setup git submodules
352      run: |
353        git submodule update --init
354    - name: Configure autotools
355      run: |
356        autoreconf -i
357        ./configure
358    - name: Configure cmake (Linux)
359      if: matrix.buildtool == 'cmake' && runner.os == 'Linux'
360      run: |
361        make dist
362        VERSION=$(grep PACKAGE_VERSION config.h | cut -d' ' -f3 | tr -d '"')
363        tar xf nghttp2-$VERSION.tar.gz
364        cd nghttp2-$VERSION
365        echo 'NGHTTP2_CMAKE_DIR='"$PWD" >> $GITHUB_ENV
366
367        cmake -DENABLE_WERROR=1 -DWITH_MRUBY=1 -DWITH_NEVERBLEED=1 -DENABLE_APP=1 $EXTRA_CMAKE_OPTS -DCPPFLAGS="$CPPFLAGS" -DLDFLAGS="$LDFLAGS" .
368    - name: Configure cmake (MacOS)
369      if: matrix.buildtool == 'cmake' && runner.os == 'macOS'
370      run: |
371        make dist
372        VERSION=$(grep PACKAGE_VERSION config.h | cut -d' ' -f3 | tr -d '"')
373        tar xf nghttp2-$VERSION.tar.gz
374        cd nghttp2-$VERSION
375        echo 'NGHTTP2_CMAKE_DIR='"$PWD" >> $GITHUB_ENV
376
377        # This fixes infamous 'stdio.h not found' error.
378        echo 'SDKROOT='"$(xcrun --sdk macosx --show-sdk-path)" >> $GITHUB_ENV
379
380        cmake -DENABLE_WERROR=1 -DWITH_MRUBY=1 -DENABLE_APP=1 $EXTRA_CMAKE_OPTS -DCPPFLAGS="$CPPFLAGS" -DLDFLAGS="$LDFLAGS" .
381    - name: Build nghttp2 with autotools (Linux)
382      if: matrix.buildtool == 'autotools' && runner.os == 'Linux'
383      run: |
384        make -j"$(nproc)" distcheck \
385          DISTCHECK_CONFIGURE_FLAGS="--with-mruby --with-neverbleed --with-libev --enable-werror $EXTRA_AUTOTOOLS_OPTS CPPFLAGS=\"$CPPFLAGS\" LDFLAGS=\"$LDFLAGS\""
386    - name: Build nghttp2 with autotools (MacOS)
387      if: matrix.buildtool == 'autotools' && runner.os == 'macOS'
388      run: |
389        make -j"$(sysctl -n hw.ncpu)" distcheck \
390          DISTCHECK_CONFIGURE_FLAGS="--with-mruby --with-libev --enable-werror $EXTRA_AUTOTOOLS_OPTS CPPFLAGS=\"$CPPFLAGS\" LDFLAGS=\"$LDFLAGS\""
391    - name: Build nghttp2 with cmake
392      if: matrix.buildtool == 'cmake'
393      run: |
394        cd $NGHTTP2_CMAKE_DIR
395        make -j"$(nproc 2> /dev/null || sysctl -n hw.ncpu)"
396        make -j"$(nproc 2> /dev/null || sysctl -n hw.ncpu)" check
397    - uses: actions/setup-go@v4
398      if: matrix.buildtool == 'cmake'
399      with:
400        go-version-file: go.mod
401    - name: Integration test
402      # Integration tests for nghttpx; autotools erases build
403      # artifacts.
404      if: matrix.buildtool == 'cmake'
405      run: |
406        cd $NGHTTP2_CMAKE_DIR/integration-tests
407        make itprep it
408
409  build-cross:
410    strategy:
411      matrix:
412        host: [x86_64-w64-mingw32, i686-w64-mingw32]
413
414    runs-on: ubuntu-22.04
415
416    env:
417      HOST: ${{ matrix.host }}
418
419    steps:
420    - uses: actions/checkout@v4
421    - name: Linux setup
422      run: |
423        sudo dpkg --add-architecture i386
424        sudo apt-get update
425        sudo apt-get install \
426          gcc-mingw-w64 \
427          autoconf \
428          automake \
429          autotools-dev \
430          libtool \
431          pkg-config \
432          wine
433    - name: Build CUnit
434      run: |
435        curl -LO https://jaist.dl.sourceforge.net/project/cunit/CUnit/2.1-3/CUnit-2.1-3.tar.bz2
436        tar xf CUnit-2.1-3.tar.bz2
437        cd CUnit-2.1-3
438        ./bootstrap
439        ./configure --disable-shared --host="$HOST" --prefix="$PWD/build"
440        make -j$(nproc) install
441    - name: Configure autotools
442      run: |
443        autoreconf -i && \
444        ./configure --enable-werror --enable-lib-only --with-cunit \
445          --host="$HOST" PKG_CONFIG_PATH="$PWD/CUnit-2.1-3/build/lib/pkgconfig" \
446          CFLAGS="-g -O2 -D_WIN32_WINNT=0x0600"
447    - name: Build nghttp2
448      run: |
449        make -j$(nproc)
450        make -j$(nproc) check TESTS=""
451    - name: Run tests
452      if: matrix.host == 'x86_64-w64-mingw32'
453      run: |
454        cd tests
455        wine main.exe
456
457  build-windows:
458    strategy:
459      matrix:
460        arch: [x86, x64]
461        include:
462        - arch: x86
463          platform: Win32
464        - arch: x64
465          platform: x64
466
467    runs-on: windows-latest
468
469    steps:
470    - uses: actions/checkout@v4
471    - uses: microsoft/setup-msbuild@v1
472    - run: |
473        vcpkg --triplet=${{ matrix.arch }}-windows install cunit
474    - name: Configure cmake
475      run: |
476        mkdir build
477        cd build
478        cmake -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_GENERATOR_PLATFORM=${{ matrix.platform }} -DVCPKG_TARGET_TRIPLET=${{ matrix.arch}}-windows ..
479    - name: Build nghttp2
480      run: |
481        cmake --build build
482        cmake --build build --target check
483