name: build on: [push, pull_request] permissions: read-all env: LIBBPF_VERSION: v1.2.0 OPENSSL1_VERSION: 1_1_1u+quic OPENSSL3_VERSION: 3.1.0+quic BORINGSSL_VERSION: 80dcb67d4481fb1194b9669917e35580c32dc388 NGHTTP3_VERSION: v0.13.0 NGTCP2_VERSION: v0.17.0 jobs: build-cache: strategy: matrix: os: [ubuntu-22.04, macos-12] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 - name: Restore libbpf cache id: cache-libbpf uses: actions/cache@v3 if: runner.os == 'Linux' with: path: libbpf/build key: ${{ runner.os }}-libbpf-${{ env.LIBBPF_VERSION }} - name: Restore OpenSSL v1.1.1 cache id: cache-openssl1 uses: actions/cache@v3 with: path: openssl1/build key: ${{ runner.os }}-openssl-${{ env.OPENSSL1_VERSION }} - name: Restore OpenSSL v3.x cache id: cache-openssl3 uses: actions/cache@v3 with: path: openssl3/build key: ${{ runner.os }}-openssl-${{ env.OPENSSL3_VERSION }} - name: Restore BoringSSL cache id: cache-boringssl uses: actions/cache@v3 with: path: | boringssl/build/crypto/libcrypto.a boringssl/build/ssl/libssl.a boringssl/include key: ${{ runner.os }}-boringssl-${{ env.BORINGSSL_VERSION }} - name: Restore nghttp3 cache id: cache-nghttp3 uses: actions/cache@v3 with: path: nghttp3/build key: ${{ runner.os }}-nghttp3-${{ env.NGHTTP3_VERSION }} - name: Restore ngtcp2 + quictls/openssl v1.1.1 cache id: cache-ngtcp2-openssl1 uses: actions/cache@v3 with: path: ngtcp2-openssl1/build key: ${{ runner.os }}-ngtcp2-${{ env.NGTCP2_VERSION }}-openssl-${{ env.OPENSSL1_VERSION }} - name: Restore ngtcp2 + quictls/openssl v3.x cache id: cache-ngtcp2-openssl3 uses: actions/cache@v3 with: path: ngtcp2-openssl3/build key: ${{ runner.os }}-ngtcp2-${{ env.NGTCP2_VERSION }}-openssl-${{ env.OPENSSL3_VERSION }} - id: settings if: | (steps.cache-libbpf.outputs.cache-hit != 'true' && runner.os == 'Linux') || steps.cache-openssl1.outputs.cache-hit != 'true' || steps.cache-openssl3.outputs.cache-hit != 'true' || steps.cache-boringssl.outputs.cache-hit != 'true' || steps.cache-nghttp3.outputs.cache-hit != 'true' || steps.cache-ngtcp2-openssl1.outputs.cache-hit != 'true' || steps.cache-ngtcp2-openssl3.outputs.cache-hit != 'true' run: | echo 'needs-build=true' >> $GITHUB_OUTPUT - name: Linux setup if: runner.os == 'Linux' && steps.settings.outputs.needs-build == 'true' run: | sudo apt-get install \ g++-12 \ clang-14 \ autoconf \ automake \ autotools-dev \ libtool \ pkg-config \ libelf-dev \ cmake \ cmake-data - name: MacOS setup if: runner.os == 'macOS' && steps.settings.outputs.needs-build == 'true' run: | brew install \ autoconf \ automake \ pkg-config \ libtool - name: Build libbpf if: steps.cache-libbpf.outputs.cache-hit != 'true' && runner.os == 'Linux' run: | git clone -b ${{ env.LIBBPF_VERSION }} https://github.com/libbpf/libbpf cd libbpf make -C src install PREFIX=$PWD/build - name: Build quictls/openssl v1.1.1 if: steps.cache-openssl1.outputs.cache-hit != 'true' run: | git clone --depth 1 -b OpenSSL_${{ env.OPENSSL1_VERSION }} https://github.com/quictls/openssl openssl1 cd openssl1 ./config --prefix=$PWD/build make -j"$(nproc 2> /dev/null || sysctl -n hw.ncpu)" make install_sw - name: Build quictls/openssl v3.x if: steps.cache-openssl3.outputs.cache-hit != 'true' run: | git clone --depth 1 -b openssl-${{ env.OPENSSL3_VERSION }} https://github.com/quictls/openssl openssl3 cd openssl3 ./config enable-ktls --prefix=$PWD/build --libdir=$PWD/build/lib make -j"$(nproc 2> /dev/null || sysctl -n hw.ncpu)" make install_sw - name: Build BoringSSL if: steps.cache-boringssl.outputs.cache-hit != 'true' run: | git clone https://boringssl.googlesource.com/boringssl cd boringssl git checkout ${{ env.BORINGSSL_VERSION }} mkdir build cd build cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON .. make -j"$(nproc 2> /dev/null || sysctl -n hw.ncpu)" - name: Build nghttp3 if: steps.cache-nghttp3.outputs.cache-hit != 'true' run: | git clone --depth 1 -b ${{ env.NGHTTP3_VERSION}} https://github.com/ngtcp2/nghttp3 cd nghttp3 autoreconf -i ./configure --prefix=$PWD/build --enable-lib-only make -j"$(nproc 2> /dev/null || sysctl -n hw.ncpu)" check make install - name: Build ngtcp2 + quictls/openssl v1.1.1 if: steps.cache-ngtcp2-openssl1.outputs.cache-hit != 'true' run: | git clone --depth 1 -b ${{ env.NGTCP2_VERSION }} https://github.com/ngtcp2/ngtcp2 ngtcp2-openssl1 cd ngtcp2-openssl1 autoreconf -i ./configure --prefix=$PWD/build --enable-lib-only \ PKG_CONFIG_PATH="../openssl1/build/lib/pkgconfig" \ BORINGSSL_CFLAGS="-I$PWD/../boringssl/include/" \ BORINGSSL_LIBS="-L$PWD/../boringssl/build/ssl -lssl -L$PWD/../boringssl/build/crypto -lcrypto" \ --with-boringssl make -j"$(nproc 2> /dev/null || sysctl -n hw.ncpu)" check make install - name: Build ngtcp2 + quictls/openssl v3.x if: steps.cache-ngtcp2-openssl3.outputs.cache-hit != 'true' run: | git clone --depth 1 -b ${{ env.NGTCP2_VERSION }} https://github.com/ngtcp2/ngtcp2 ngtcp2-openssl3 cd ngtcp2-openssl3 autoreconf -i ./configure --prefix=$PWD/build --enable-lib-only \ PKG_CONFIG_PATH="../openssl3/build/lib/pkgconfig" \ BORINGSSL_CFLAGS="-I$PWD/../boringssl/include/" \ BORINGSSL_LIBS="-L$PWD/../boringssl/build/ssl -lssl -L$PWD/../boringssl/build/crypto -lcrypto" \ --with-boringssl make -j"$(nproc 2> /dev/null || sysctl -n hw.ncpu)" check make install build: needs: - build-cache strategy: matrix: os: [ubuntu-22.04, macos-12] compiler: [gcc, clang] buildtool: [autotools, cmake] http3: [http3, no-http3] openssl: [openssl1, openssl3, boringssl] exclude: - os: macos-12 openssl: openssl3 - http3: no-http3 openssl: openssl3 - os: macos-12 compiler: gcc - # disable macos cmake because of include path issue os: macos-12 buildtool: cmake - os: macos-12 openssl: boringssl - openssl: boringssl buildtool: cmake - openssl: boringssl compiler: gcc runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 - name: Linux setup if: runner.os == 'Linux' run: | sudo apt-get install \ g++-12 \ clang-14 \ autoconf \ automake \ autotools-dev \ libtool \ pkg-config \ zlib1g-dev \ libcunit1-dev \ libssl-dev \ libxml2-dev \ libev-dev \ libevent-dev \ libjansson-dev \ libjemalloc-dev \ libc-ares-dev \ libelf-dev \ cmake \ cmake-data echo 'CPPFLAGS=-fsanitize=address,undefined -fno-sanitize-recover=undefined -g' >> $GITHUB_ENV echo 'LDFLAGS=-fsanitize=address,undefined -fno-sanitize-recover=undefined' >> $GITHUB_ENV - name: MacOS setup if: runner.os == 'macOS' run: | brew install \ libev \ libevent \ c-ares \ cunit \ libressl \ autoconf \ automake \ pkg-config \ libtool echo 'PKG_CONFIG_PATH=/usr/local/opt/libressl/lib/pkgconfig:/usr/local/opt/libxml2/lib/pkgconfig' >> $GITHUB_ENV - name: Setup clang (Linux) if: runner.os == 'Linux' && matrix.compiler == 'clang' run: | echo 'CC=clang-14' >> $GITHUB_ENV echo 'CXX=clang++-14' >> $GITHUB_ENV - name: Setup clang (MacOS) if: runner.os == 'macOS' && matrix.compiler == 'clang' run: | echo 'CC=clang' >> $GITHUB_ENV echo 'CXX=clang++' >> $GITHUB_ENV - name: Setup gcc (Linux) if: runner.os == 'Linux' && matrix.compiler == 'gcc' run: | echo 'CC=gcc-12' >> $GITHUB_ENV echo 'CXX=g++-12' >> $GITHUB_ENV - name: Setup gcc (MacOS) if: runner.os == 'macOS' && matrix.compiler == 'gcc' run: | echo 'CC=gcc' >> $GITHUB_ENV echo 'CXX=g++' >> $GITHUB_ENV - name: Restore libbpf cache uses: actions/cache/restore@v3 if: matrix.http3 == 'http3' && matrix.compiler == 'clang' && runner.os == 'Linux' with: path: libbpf/build key: ${{ runner.os }}-libbpf-${{ env.LIBBPF_VERSION }} fail-on-cache-miss: true - name: Set libbpf variables if: matrix.http3 == 'http3' && matrix.compiler == 'clang' && runner.os == 'Linux' run: | cd libbpf EXTRA_AUTOTOOLS_OPTS="--with-libbpf" EXTRA_CMAKE_OPTS="-DWITH_LIBBPF=1" echo 'EXTRA_AUTOTOOLS_OPTS='"$EXTRA_AUTOTOOLS_OPTS" >> $GITHUB_ENV echo 'EXTRA_CMAKE_OPTS='"$EXTRA_CMAKE_OPTS" >> $GITHUB_ENV - name: Restore quictls/openssl v1.1.1 cache uses: actions/cache/restore@v3 if: matrix.http3 == 'http3' && matrix.openssl == 'openssl1' with: path: openssl1/build key: ${{ runner.os }}-openssl-${{ env.OPENSSL1_VERSION }} fail-on-cache-miss: true - name: Restore quictls/openssl v3.x cache uses: actions/cache/restore@v3 if: matrix.http3 == 'http3' && matrix.openssl == 'openssl3' with: path: openssl3/build key: ${{ runner.os }}-openssl-${{ env.OPENSSL3_VERSION }} fail-on-cache-miss: true - name: Restore BoringSSL cache uses: actions/cache/restore@v3 if: matrix.openssl == 'boringssl' with: path: | boringssl/build/crypto/libcrypto.a boringssl/build/ssl/libssl.a boringssl/include key: ${{ runner.os }}-boringssl-${{ env.BORINGSSL_VERSION }} fail-on-cache-miss: true - name: Set BoringSSL variables if: matrix.openssl == 'boringssl' run: | cd boringssl OPENSSL_CFLAGS="-I$PWD/include/" OPENSSL_LIBS="-L$PWD/build/ssl -lssl -L$PWD/build/crypto -lcrypto -pthread" EXTRA_AUTOTOOLS_OPTS="$EXTRA_AUTOTOOLS_OPTS --without-neverbleed --without-jemalloc" echo 'OPENSSL_CFLAGS='"$OPENSSL_CFLAGS" >> $GITHUB_ENV echo 'OPENSSL_LIBS='"$OPENSSL_LIBS" >> $GITHUB_ENV echo 'BORINGSSL_CFLAGS='"$OPENSSL_CFLAGS" >> $GITHUB_ENV echo 'BORINGSSL_LIBS='"$OPENSSL_LIBS" >> $GITHUB_ENV echo 'EXTRA_AUTOTOOLS_OPTS='"$EXTRA_AUTOTOOLS_OPTS" >> $GITHUB_ENV - name: Restore nghttp3 cache uses: actions/cache/restore@v3 if: matrix.http3 == 'http3' with: path: nghttp3/build key: ${{ runner.os }}-nghttp3-${{ env.NGHTTP3_VERSION }} fail-on-cache-miss: true - name: Restore ngtcp2 + quictls/openssl v1.1.1 cache uses: actions/cache/restore@v3 if: matrix.http3 == 'http3' && (matrix.openssl == 'openssl1' || matrix.openssl == 'boringssl') with: path: ngtcp2-openssl1/build key: ${{ runner.os }}-ngtcp2-${{ env.NGTCP2_VERSION }}-openssl-${{ env.OPENSSL1_VERSION }} fail-on-cache-miss: true - name: Restore ngtcp2 + quictls/openssl v3.x cache uses: actions/cache/restore@v3 if: matrix.http3 == 'http3' && matrix.openssl == 'openssl3' with: path: ngtcp2-openssl3/build key: ${{ runner.os }}-ngtcp2-${{ env.NGTCP2_VERSION }}-openssl-${{ env.OPENSSL3_VERSION }} fail-on-cache-miss: true - name: Setup extra environment variables for HTTP/3 if: matrix.http3 == 'http3' run: | 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" LDFLAGS="$LDFLAGS -Wl,-rpath,$PWD/openssl1/build/lib -Wl,-rpath,$PWD/openssl3/build/lib -Wl,-rpath,$PWD/libbpf/build/lib64" EXTRA_AUTOTOOLS_OPTS="--enable-http3 $EXTRA_AUTOTOOLS_OPTS" EXTRA_CMAKE_OPTS="-DENABLE_HTTP3=1 $EXTRA_CMAKE_OPTS" echo 'PKG_CONFIG_PATH='"$PKG_CONFIG_PATH" >> $GITHUB_ENV echo 'LDFLAGS='"$LDFLAGS" >> $GITHUB_ENV echo 'EXTRA_AUTOTOOLS_OPTS='"$EXTRA_AUTOTOOLS_OPTS" >> $GITHUB_ENV echo 'EXTRA_CMAKE_OPTS='"$EXTRA_CMAKE_OPTS" >> $GITHUB_ENV - name: Setup git submodules run: | git submodule update --init - name: Configure autotools run: | autoreconf -i ./configure - name: Configure cmake (Linux) if: matrix.buildtool == 'cmake' && runner.os == 'Linux' run: | make dist VERSION=$(grep PACKAGE_VERSION config.h | cut -d' ' -f3 | tr -d '"') tar xf nghttp2-$VERSION.tar.gz cd nghttp2-$VERSION echo 'NGHTTP2_CMAKE_DIR='"$PWD" >> $GITHUB_ENV cmake -DENABLE_WERROR=1 -DWITH_MRUBY=1 -DWITH_NEVERBLEED=1 -DENABLE_APP=1 $EXTRA_CMAKE_OPTS -DCPPFLAGS="$CPPFLAGS" -DLDFLAGS="$LDFLAGS" . - name: Configure cmake (MacOS) if: matrix.buildtool == 'cmake' && runner.os == 'macOS' run: | make dist VERSION=$(grep PACKAGE_VERSION config.h | cut -d' ' -f3 | tr -d '"') tar xf nghttp2-$VERSION.tar.gz cd nghttp2-$VERSION echo 'NGHTTP2_CMAKE_DIR='"$PWD" >> $GITHUB_ENV # This fixes infamous 'stdio.h not found' error. echo 'SDKROOT='"$(xcrun --sdk macosx --show-sdk-path)" >> $GITHUB_ENV cmake -DENABLE_WERROR=1 -DWITH_MRUBY=1 -DENABLE_APP=1 $EXTRA_CMAKE_OPTS -DCPPFLAGS="$CPPFLAGS" -DLDFLAGS="$LDFLAGS" . - name: Build nghttp2 with autotools (Linux) if: matrix.buildtool == 'autotools' && runner.os == 'Linux' run: | make -j"$(nproc)" distcheck \ DISTCHECK_CONFIGURE_FLAGS="--with-mruby --with-neverbleed --with-libev --enable-werror $EXTRA_AUTOTOOLS_OPTS CPPFLAGS=\"$CPPFLAGS\" LDFLAGS=\"$LDFLAGS\"" - name: Build nghttp2 with autotools (MacOS) if: matrix.buildtool == 'autotools' && runner.os == 'macOS' run: | make -j"$(sysctl -n hw.ncpu)" distcheck \ DISTCHECK_CONFIGURE_FLAGS="--with-mruby --with-libev --enable-werror $EXTRA_AUTOTOOLS_OPTS CPPFLAGS=\"$CPPFLAGS\" LDFLAGS=\"$LDFLAGS\"" - name: Build nghttp2 with cmake if: matrix.buildtool == 'cmake' run: | cd $NGHTTP2_CMAKE_DIR make -j"$(nproc 2> /dev/null || sysctl -n hw.ncpu)" make -j"$(nproc 2> /dev/null || sysctl -n hw.ncpu)" check - uses: actions/setup-go@v3 if: matrix.buildtool == 'cmake' with: go-version-file: go.mod - name: Integration test # Integration tests for nghttpx; autotools erases build # artifacts. if: matrix.buildtool == 'cmake' run: | cd $NGHTTP2_CMAKE_DIR/integration-tests make itprep it build-cross: strategy: matrix: host: [x86_64-w64-mingw32, i686-w64-mingw32] runs-on: ubuntu-22.04 env: HOST: ${{ matrix.host }} steps: - uses: actions/checkout@v3 - name: Linux setup run: | sudo dpkg --add-architecture i386 sudo apt-get update sudo apt-get install \ gcc-mingw-w64 \ autoconf \ automake \ autotools-dev \ libtool \ pkg-config \ wine - name: Build CUnit run: | curl -LO https://jaist.dl.sourceforge.net/project/cunit/CUnit/2.1-3/CUnit-2.1-3.tar.bz2 tar xf CUnit-2.1-3.tar.bz2 cd CUnit-2.1-3 ./bootstrap ./configure --disable-shared --host="$HOST" --prefix="$PWD/build" make -j$(nproc) install - name: Configure autotools run: | autoreconf -i && \ ./configure --enable-werror --enable-lib-only --with-cunit \ --host="$HOST" PKG_CONFIG_PATH="$PWD/CUnit-2.1-3/build/lib/pkgconfig" \ CFLAGS="-g -O2 -D_WIN32_WINNT=0x0600" - name: Build nghttp2 run: | make -j$(nproc) make -j$(nproc) check TESTS="" - name: Run tests if: matrix.host == 'x86_64-w64-mingw32' run: | cd tests wine main.exe build-windows: strategy: matrix: arch: [x86, x64] include: - arch: x86 platform: Win32 - arch: x64 platform: x64 runs-on: windows-latest steps: - uses: actions/checkout@v3 - uses: microsoft/setup-msbuild@v1 - run: | vcpkg --triplet=${{ matrix.arch }}-windows install cunit - name: Configure cmake run: | mkdir build cd build cmake -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_GENERATOR_PLATFORM=${{ matrix.platform }} -DVCPKG_TARGET_TRIPLET=${{ matrix.arch}}-windows .. - name: Build nghttp2 run: | cmake --build build cmake --build build --target check