12c593315Sopenharmony_ciname: build
22c593315Sopenharmony_ci
32c593315Sopenharmony_cion: [push, pull_request]
42c593315Sopenharmony_ci
52c593315Sopenharmony_cipermissions: read-all
62c593315Sopenharmony_ci
72c593315Sopenharmony_cienv:
82c593315Sopenharmony_ci  LIBBPF_VERSION: v1.2.2
92c593315Sopenharmony_ci  OPENSSL1_VERSION: 1_1_1w+quic
102c593315Sopenharmony_ci  OPENSSL3_VERSION: 3.1.2+quic
112c593315Sopenharmony_ci  BORINGSSL_VERSION: 6ca49385b168f47a50e7172d82a590b218f55e4d
122c593315Sopenharmony_ci  NGHTTP3_VERSION: v1.0.0
132c593315Sopenharmony_ci  NGTCP2_VERSION: v1.0.1
142c593315Sopenharmony_ci
152c593315Sopenharmony_cijobs:
162c593315Sopenharmony_ci  build-cache:
172c593315Sopenharmony_ci    strategy:
182c593315Sopenharmony_ci      matrix:
192c593315Sopenharmony_ci        os: [ubuntu-22.04, macos-12]
202c593315Sopenharmony_ci
212c593315Sopenharmony_ci    runs-on: ${{ matrix.os }}
222c593315Sopenharmony_ci
232c593315Sopenharmony_ci    steps:
242c593315Sopenharmony_ci    - uses: actions/checkout@v4
252c593315Sopenharmony_ci    - name: Restore libbpf cache
262c593315Sopenharmony_ci      id: cache-libbpf
272c593315Sopenharmony_ci      uses: actions/cache@v3
282c593315Sopenharmony_ci      if: runner.os == 'Linux'
292c593315Sopenharmony_ci      with:
302c593315Sopenharmony_ci        path: libbpf/build
312c593315Sopenharmony_ci        key: ${{ runner.os }}-libbpf-${{ env.LIBBPF_VERSION }}
322c593315Sopenharmony_ci    - name: Restore OpenSSL v1.1.1 cache
332c593315Sopenharmony_ci      id: cache-openssl1
342c593315Sopenharmony_ci      uses: actions/cache@v3
352c593315Sopenharmony_ci      with:
362c593315Sopenharmony_ci        path: openssl1/build
372c593315Sopenharmony_ci        key: ${{ runner.os }}-openssl-${{ env.OPENSSL1_VERSION }}
382c593315Sopenharmony_ci    - name: Restore OpenSSL v3.x cache
392c593315Sopenharmony_ci      id: cache-openssl3
402c593315Sopenharmony_ci      uses: actions/cache@v3
412c593315Sopenharmony_ci      with:
422c593315Sopenharmony_ci        path: openssl3/build
432c593315Sopenharmony_ci        key: ${{ runner.os }}-openssl-${{ env.OPENSSL3_VERSION }}
442c593315Sopenharmony_ci    - name: Restore BoringSSL cache
452c593315Sopenharmony_ci      id: cache-boringssl
462c593315Sopenharmony_ci      uses: actions/cache@v3
472c593315Sopenharmony_ci      with:
482c593315Sopenharmony_ci        path: |
492c593315Sopenharmony_ci          boringssl/build/crypto/libcrypto.a
502c593315Sopenharmony_ci          boringssl/build/ssl/libssl.a
512c593315Sopenharmony_ci          boringssl/include
522c593315Sopenharmony_ci        key: ${{ runner.os }}-boringssl-${{ env.BORINGSSL_VERSION }}
532c593315Sopenharmony_ci    - name: Restore nghttp3 cache
542c593315Sopenharmony_ci      id: cache-nghttp3
552c593315Sopenharmony_ci      uses: actions/cache@v3
562c593315Sopenharmony_ci      with:
572c593315Sopenharmony_ci        path: nghttp3/build
582c593315Sopenharmony_ci        key: ${{ runner.os }}-nghttp3-${{ env.NGHTTP3_VERSION }}
592c593315Sopenharmony_ci    - name: Restore ngtcp2 + quictls/openssl v1.1.1 cache
602c593315Sopenharmony_ci      id: cache-ngtcp2-openssl1
612c593315Sopenharmony_ci      uses: actions/cache@v3
622c593315Sopenharmony_ci      with:
632c593315Sopenharmony_ci        path: ngtcp2-openssl1/build
642c593315Sopenharmony_ci        key: ${{ runner.os }}-ngtcp2-${{ env.NGTCP2_VERSION }}-openssl-${{ env.OPENSSL1_VERSION }}
652c593315Sopenharmony_ci    - name: Restore ngtcp2 + quictls/openssl v3.x cache
662c593315Sopenharmony_ci      id: cache-ngtcp2-openssl3
672c593315Sopenharmony_ci      uses: actions/cache@v3
682c593315Sopenharmony_ci      with:
692c593315Sopenharmony_ci        path: ngtcp2-openssl3/build
702c593315Sopenharmony_ci        key: ${{ runner.os }}-ngtcp2-${{ env.NGTCP2_VERSION }}-openssl-${{ env.OPENSSL3_VERSION }}
712c593315Sopenharmony_ci    - id: settings
722c593315Sopenharmony_ci      if: |
732c593315Sopenharmony_ci        (steps.cache-libbpf.outputs.cache-hit != 'true' && runner.os == 'Linux') ||
742c593315Sopenharmony_ci        steps.cache-openssl1.outputs.cache-hit != 'true' ||
752c593315Sopenharmony_ci        steps.cache-openssl3.outputs.cache-hit != 'true' ||
762c593315Sopenharmony_ci        steps.cache-boringssl.outputs.cache-hit != 'true' ||
772c593315Sopenharmony_ci        steps.cache-nghttp3.outputs.cache-hit != 'true' ||
782c593315Sopenharmony_ci        steps.cache-ngtcp2-openssl1.outputs.cache-hit != 'true' ||
792c593315Sopenharmony_ci        steps.cache-ngtcp2-openssl3.outputs.cache-hit != 'true'
802c593315Sopenharmony_ci      run: |
812c593315Sopenharmony_ci        echo 'needs-build=true' >> $GITHUB_OUTPUT
822c593315Sopenharmony_ci    - name: Linux setup
832c593315Sopenharmony_ci      if: runner.os == 'Linux' && steps.settings.outputs.needs-build == 'true'
842c593315Sopenharmony_ci      run: |
852c593315Sopenharmony_ci        sudo apt-get install \
862c593315Sopenharmony_ci          g++-12 \
872c593315Sopenharmony_ci          clang-14 \
882c593315Sopenharmony_ci          autoconf \
892c593315Sopenharmony_ci          automake \
902c593315Sopenharmony_ci          autotools-dev \
912c593315Sopenharmony_ci          libtool \
922c593315Sopenharmony_ci          pkg-config \
932c593315Sopenharmony_ci          libelf-dev \
942c593315Sopenharmony_ci          cmake \
952c593315Sopenharmony_ci          cmake-data
962c593315Sopenharmony_ci    - name: MacOS setup
972c593315Sopenharmony_ci      if: runner.os == 'macOS' && steps.settings.outputs.needs-build == 'true'
982c593315Sopenharmony_ci      run: |
992c593315Sopenharmony_ci        brew install \
1002c593315Sopenharmony_ci          autoconf \
1012c593315Sopenharmony_ci          automake \
1022c593315Sopenharmony_ci          pkg-config \
1032c593315Sopenharmony_ci          libtool
1042c593315Sopenharmony_ci    - name: Build libbpf
1052c593315Sopenharmony_ci      if: steps.cache-libbpf.outputs.cache-hit != 'true' && runner.os == 'Linux'
1062c593315Sopenharmony_ci      run: |
1072c593315Sopenharmony_ci        git clone -b ${{ env.LIBBPF_VERSION }} https://github.com/libbpf/libbpf
1082c593315Sopenharmony_ci        cd libbpf
1092c593315Sopenharmony_ci        make -C src install PREFIX=$PWD/build
1102c593315Sopenharmony_ci    - name: Build quictls/openssl v1.1.1
1112c593315Sopenharmony_ci      if: steps.cache-openssl1.outputs.cache-hit != 'true'
1122c593315Sopenharmony_ci      run: |
1132c593315Sopenharmony_ci        git clone --depth 1 -b OpenSSL_${{ env.OPENSSL1_VERSION }} https://github.com/quictls/openssl openssl1
1142c593315Sopenharmony_ci        cd openssl1
1152c593315Sopenharmony_ci        ./config --prefix=$PWD/build
1162c593315Sopenharmony_ci        make -j"$(nproc 2> /dev/null || sysctl -n hw.ncpu)"
1172c593315Sopenharmony_ci        make install_sw
1182c593315Sopenharmony_ci    - name: Build quictls/openssl v3.x
1192c593315Sopenharmony_ci      if: steps.cache-openssl3.outputs.cache-hit != 'true'
1202c593315Sopenharmony_ci      run: |
1212c593315Sopenharmony_ci        git clone --depth 1 -b openssl-${{ env.OPENSSL3_VERSION }} https://github.com/quictls/openssl openssl3
1222c593315Sopenharmony_ci        cd openssl3
1232c593315Sopenharmony_ci        ./config enable-ktls --prefix=$PWD/build --libdir=$PWD/build/lib
1242c593315Sopenharmony_ci        make -j"$(nproc 2> /dev/null || sysctl -n hw.ncpu)"
1252c593315Sopenharmony_ci        make install_sw
1262c593315Sopenharmony_ci    - name: Build BoringSSL
1272c593315Sopenharmony_ci      if: steps.cache-boringssl.outputs.cache-hit != 'true'
1282c593315Sopenharmony_ci      run: |
1292c593315Sopenharmony_ci        git clone https://boringssl.googlesource.com/boringssl
1302c593315Sopenharmony_ci        cd boringssl
1312c593315Sopenharmony_ci        git checkout ${{ env.BORINGSSL_VERSION }}
1322c593315Sopenharmony_ci        mkdir build
1332c593315Sopenharmony_ci        cd build
1342c593315Sopenharmony_ci        cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON ..
1352c593315Sopenharmony_ci        make -j"$(nproc 2> /dev/null || sysctl -n hw.ncpu)"
1362c593315Sopenharmony_ci    - name: Build nghttp3
1372c593315Sopenharmony_ci      if: steps.cache-nghttp3.outputs.cache-hit != 'true'
1382c593315Sopenharmony_ci      run: |
1392c593315Sopenharmony_ci        git clone --depth 1 -b ${{ env.NGHTTP3_VERSION}} https://github.com/ngtcp2/nghttp3
1402c593315Sopenharmony_ci        cd nghttp3
1412c593315Sopenharmony_ci        autoreconf -i
1422c593315Sopenharmony_ci        ./configure --prefix=$PWD/build --enable-lib-only
1432c593315Sopenharmony_ci        make -j"$(nproc 2> /dev/null || sysctl -n hw.ncpu)" check
1442c593315Sopenharmony_ci        make install
1452c593315Sopenharmony_ci    - name: Build ngtcp2 + quictls/openssl v1.1.1
1462c593315Sopenharmony_ci      if: steps.cache-ngtcp2-openssl1.outputs.cache-hit != 'true'
1472c593315Sopenharmony_ci      run: |
1482c593315Sopenharmony_ci        git clone --depth 1 -b ${{ env.NGTCP2_VERSION }} https://github.com/ngtcp2/ngtcp2 ngtcp2-openssl1
1492c593315Sopenharmony_ci        cd ngtcp2-openssl1
1502c593315Sopenharmony_ci        autoreconf -i
1512c593315Sopenharmony_ci        ./configure --prefix=$PWD/build --enable-lib-only \
1522c593315Sopenharmony_ci          PKG_CONFIG_PATH="../openssl1/build/lib/pkgconfig" \
1532c593315Sopenharmony_ci          BORINGSSL_CFLAGS="-I$PWD/../boringssl/include/" \
1542c593315Sopenharmony_ci          BORINGSSL_LIBS="-L$PWD/../boringssl/build/ssl -lssl -L$PWD/../boringssl/build/crypto -lcrypto" \
1552c593315Sopenharmony_ci          --with-boringssl
1562c593315Sopenharmony_ci        make -j"$(nproc 2> /dev/null || sysctl -n hw.ncpu)" check
1572c593315Sopenharmony_ci        make install
1582c593315Sopenharmony_ci    - name: Build ngtcp2 + quictls/openssl v3.x
1592c593315Sopenharmony_ci      if: steps.cache-ngtcp2-openssl3.outputs.cache-hit != 'true'
1602c593315Sopenharmony_ci      run: |
1612c593315Sopenharmony_ci        git clone --depth 1 -b ${{ env.NGTCP2_VERSION }} https://github.com/ngtcp2/ngtcp2 ngtcp2-openssl3
1622c593315Sopenharmony_ci        cd ngtcp2-openssl3
1632c593315Sopenharmony_ci        autoreconf -i
1642c593315Sopenharmony_ci        ./configure --prefix=$PWD/build --enable-lib-only \
1652c593315Sopenharmony_ci          PKG_CONFIG_PATH="../openssl3/build/lib/pkgconfig" \
1662c593315Sopenharmony_ci          BORINGSSL_CFLAGS="-I$PWD/../boringssl/include/" \
1672c593315Sopenharmony_ci          BORINGSSL_LIBS="-L$PWD/../boringssl/build/ssl -lssl -L$PWD/../boringssl/build/crypto -lcrypto" \
1682c593315Sopenharmony_ci          --with-boringssl
1692c593315Sopenharmony_ci        make -j"$(nproc 2> /dev/null || sysctl -n hw.ncpu)" check
1702c593315Sopenharmony_ci        make install
1712c593315Sopenharmony_ci
1722c593315Sopenharmony_ci  build:
1732c593315Sopenharmony_ci    needs:
1742c593315Sopenharmony_ci    - build-cache
1752c593315Sopenharmony_ci
1762c593315Sopenharmony_ci    strategy:
1772c593315Sopenharmony_ci      matrix:
1782c593315Sopenharmony_ci        os: [ubuntu-22.04, macos-12]
1792c593315Sopenharmony_ci        compiler: [gcc, clang]
1802c593315Sopenharmony_ci        buildtool: [autotools, cmake]
1812c593315Sopenharmony_ci        http3: [http3, no-http3]
1822c593315Sopenharmony_ci        openssl: [openssl1, openssl3, boringssl]
1832c593315Sopenharmony_ci        exclude:
1842c593315Sopenharmony_ci        - os: macos-12
1852c593315Sopenharmony_ci          openssl: openssl3
1862c593315Sopenharmony_ci        - http3: no-http3
1872c593315Sopenharmony_ci          openssl: openssl3
1882c593315Sopenharmony_ci        - os: macos-12
1892c593315Sopenharmony_ci          compiler: gcc
1902c593315Sopenharmony_ci        - # disable macos cmake because of include path issue
1912c593315Sopenharmony_ci          os: macos-12
1922c593315Sopenharmony_ci          buildtool: cmake
1932c593315Sopenharmony_ci        - os: macos-12
1942c593315Sopenharmony_ci          openssl: boringssl
1952c593315Sopenharmony_ci        - openssl: boringssl
1962c593315Sopenharmony_ci          buildtool: cmake
1972c593315Sopenharmony_ci        - openssl: boringssl
1982c593315Sopenharmony_ci          compiler: gcc
1992c593315Sopenharmony_ci
2002c593315Sopenharmony_ci    runs-on: ${{ matrix.os }}
2012c593315Sopenharmony_ci
2022c593315Sopenharmony_ci    steps:
2032c593315Sopenharmony_ci    - uses: actions/checkout@v4
2042c593315Sopenharmony_ci    - name: Linux setup
2052c593315Sopenharmony_ci      if: runner.os == 'Linux'
2062c593315Sopenharmony_ci      run: |
2072c593315Sopenharmony_ci        sudo apt-get install \
2082c593315Sopenharmony_ci          g++-12 \
2092c593315Sopenharmony_ci          clang-14 \
2102c593315Sopenharmony_ci          autoconf \
2112c593315Sopenharmony_ci          automake \
2122c593315Sopenharmony_ci          autotools-dev \
2132c593315Sopenharmony_ci          libtool \
2142c593315Sopenharmony_ci          pkg-config \
2152c593315Sopenharmony_ci          zlib1g-dev \
2162c593315Sopenharmony_ci          libcunit1-dev \
2172c593315Sopenharmony_ci          libssl-dev \
2182c593315Sopenharmony_ci          libxml2-dev \
2192c593315Sopenharmony_ci          libev-dev \
2202c593315Sopenharmony_ci          libevent-dev \
2212c593315Sopenharmony_ci          libjansson-dev \
2222c593315Sopenharmony_ci          libjemalloc-dev \
2232c593315Sopenharmony_ci          libc-ares-dev \
2242c593315Sopenharmony_ci          libelf-dev \
2252c593315Sopenharmony_ci          cmake \
2262c593315Sopenharmony_ci          cmake-data
2272c593315Sopenharmony_ci        echo 'CPPFLAGS=-fsanitize=address,undefined -fno-sanitize-recover=undefined -g' >> $GITHUB_ENV
2282c593315Sopenharmony_ci        echo 'LDFLAGS=-fsanitize=address,undefined -fno-sanitize-recover=undefined' >> $GITHUB_ENV
2292c593315Sopenharmony_ci    - name: MacOS setup
2302c593315Sopenharmony_ci      if: runner.os == 'macOS'
2312c593315Sopenharmony_ci      run: |
2322c593315Sopenharmony_ci        brew install \
2332c593315Sopenharmony_ci          libev \
2342c593315Sopenharmony_ci          libevent \
2352c593315Sopenharmony_ci          c-ares \
2362c593315Sopenharmony_ci          cunit \
2372c593315Sopenharmony_ci          libressl \
2382c593315Sopenharmony_ci          autoconf \
2392c593315Sopenharmony_ci          automake \
2402c593315Sopenharmony_ci          pkg-config \
2412c593315Sopenharmony_ci          libtool
2422c593315Sopenharmony_ci        echo 'PKG_CONFIG_PATH=/usr/local/opt/libressl/lib/pkgconfig:/usr/local/opt/libxml2/lib/pkgconfig' >> $GITHUB_ENV
2432c593315Sopenharmony_ci    - name: Setup clang (Linux)
2442c593315Sopenharmony_ci      if: runner.os == 'Linux' && matrix.compiler == 'clang'
2452c593315Sopenharmony_ci      run: |
2462c593315Sopenharmony_ci        echo 'CC=clang-14' >> $GITHUB_ENV
2472c593315Sopenharmony_ci        echo 'CXX=clang++-14' >> $GITHUB_ENV
2482c593315Sopenharmony_ci    - name: Setup clang (MacOS)
2492c593315Sopenharmony_ci      if: runner.os == 'macOS' && matrix.compiler == 'clang'
2502c593315Sopenharmony_ci      run: |
2512c593315Sopenharmony_ci        echo 'CC=clang' >> $GITHUB_ENV
2522c593315Sopenharmony_ci        echo 'CXX=clang++' >> $GITHUB_ENV
2532c593315Sopenharmony_ci    - name: Setup gcc (Linux)
2542c593315Sopenharmony_ci      if: runner.os == 'Linux' && matrix.compiler == 'gcc'
2552c593315Sopenharmony_ci      run: |
2562c593315Sopenharmony_ci        echo 'CC=gcc-12' >> $GITHUB_ENV
2572c593315Sopenharmony_ci        echo 'CXX=g++-12' >> $GITHUB_ENV
2582c593315Sopenharmony_ci    - name: Setup gcc (MacOS)
2592c593315Sopenharmony_ci      if: runner.os == 'macOS' && matrix.compiler == 'gcc'
2602c593315Sopenharmony_ci      run: |
2612c593315Sopenharmony_ci        echo 'CC=gcc' >> $GITHUB_ENV
2622c593315Sopenharmony_ci        echo 'CXX=g++' >> $GITHUB_ENV
2632c593315Sopenharmony_ci    - name: Restore libbpf cache
2642c593315Sopenharmony_ci      uses: actions/cache/restore@v3
2652c593315Sopenharmony_ci      if: matrix.http3 == 'http3' && matrix.compiler == 'clang' && runner.os == 'Linux'
2662c593315Sopenharmony_ci      with:
2672c593315Sopenharmony_ci        path: libbpf/build
2682c593315Sopenharmony_ci        key: ${{ runner.os }}-libbpf-${{ env.LIBBPF_VERSION }}
2692c593315Sopenharmony_ci        fail-on-cache-miss: true
2702c593315Sopenharmony_ci    - name: Set libbpf variables
2712c593315Sopenharmony_ci      if: matrix.http3 == 'http3' && matrix.compiler == 'clang' && runner.os == 'Linux'
2722c593315Sopenharmony_ci      run: |
2732c593315Sopenharmony_ci        cd libbpf
2742c593315Sopenharmony_ci
2752c593315Sopenharmony_ci        EXTRA_AUTOTOOLS_OPTS="--with-libbpf"
2762c593315Sopenharmony_ci        EXTRA_CMAKE_OPTS="-DWITH_LIBBPF=1"
2772c593315Sopenharmony_ci
2782c593315Sopenharmony_ci        echo 'EXTRA_AUTOTOOLS_OPTS='"$EXTRA_AUTOTOOLS_OPTS" >> $GITHUB_ENV
2792c593315Sopenharmony_ci        echo 'EXTRA_CMAKE_OPTS='"$EXTRA_CMAKE_OPTS" >> $GITHUB_ENV
2802c593315Sopenharmony_ci    - name: Restore quictls/openssl v1.1.1 cache
2812c593315Sopenharmony_ci      uses: actions/cache/restore@v3
2822c593315Sopenharmony_ci      if: matrix.http3 == 'http3' && matrix.openssl == 'openssl1'
2832c593315Sopenharmony_ci      with:
2842c593315Sopenharmony_ci        path: openssl1/build
2852c593315Sopenharmony_ci        key: ${{ runner.os }}-openssl-${{ env.OPENSSL1_VERSION }}
2862c593315Sopenharmony_ci        fail-on-cache-miss: true
2872c593315Sopenharmony_ci    - name: Restore quictls/openssl v3.x cache
2882c593315Sopenharmony_ci      uses: actions/cache/restore@v3
2892c593315Sopenharmony_ci      if: matrix.http3 == 'http3' && matrix.openssl == 'openssl3'
2902c593315Sopenharmony_ci      with:
2912c593315Sopenharmony_ci        path: openssl3/build
2922c593315Sopenharmony_ci        key: ${{ runner.os }}-openssl-${{ env.OPENSSL3_VERSION }}
2932c593315Sopenharmony_ci        fail-on-cache-miss: true
2942c593315Sopenharmony_ci    - name: Restore BoringSSL cache
2952c593315Sopenharmony_ci      uses: actions/cache/restore@v3
2962c593315Sopenharmony_ci      if: matrix.openssl == 'boringssl'
2972c593315Sopenharmony_ci      with:
2982c593315Sopenharmony_ci        path: |
2992c593315Sopenharmony_ci          boringssl/build/crypto/libcrypto.a
3002c593315Sopenharmony_ci          boringssl/build/ssl/libssl.a
3012c593315Sopenharmony_ci          boringssl/include
3022c593315Sopenharmony_ci        key: ${{ runner.os }}-boringssl-${{ env.BORINGSSL_VERSION }}
3032c593315Sopenharmony_ci        fail-on-cache-miss: true
3042c593315Sopenharmony_ci    - name: Set BoringSSL variables
3052c593315Sopenharmony_ci      if: matrix.openssl == 'boringssl'
3062c593315Sopenharmony_ci      run: |
3072c593315Sopenharmony_ci        cd boringssl
3082c593315Sopenharmony_ci
3092c593315Sopenharmony_ci        OPENSSL_CFLAGS="-I$PWD/include/"
3102c593315Sopenharmony_ci        OPENSSL_LIBS="-L$PWD/build/ssl -lssl -L$PWD/build/crypto -lcrypto -pthread"
3112c593315Sopenharmony_ci        EXTRA_AUTOTOOLS_OPTS="$EXTRA_AUTOTOOLS_OPTS --without-neverbleed --without-jemalloc"
3122c593315Sopenharmony_ci
3132c593315Sopenharmony_ci        echo 'OPENSSL_CFLAGS='"$OPENSSL_CFLAGS" >> $GITHUB_ENV
3142c593315Sopenharmony_ci        echo 'OPENSSL_LIBS='"$OPENSSL_LIBS" >> $GITHUB_ENV
3152c593315Sopenharmony_ci        echo 'BORINGSSL_CFLAGS='"$OPENSSL_CFLAGS" >> $GITHUB_ENV
3162c593315Sopenharmony_ci        echo 'BORINGSSL_LIBS='"$OPENSSL_LIBS" >> $GITHUB_ENV
3172c593315Sopenharmony_ci        echo 'EXTRA_AUTOTOOLS_OPTS='"$EXTRA_AUTOTOOLS_OPTS" >> $GITHUB_ENV
3182c593315Sopenharmony_ci    - name: Restore nghttp3 cache
3192c593315Sopenharmony_ci      uses: actions/cache/restore@v3
3202c593315Sopenharmony_ci      if: matrix.http3 == 'http3'
3212c593315Sopenharmony_ci      with:
3222c593315Sopenharmony_ci        path: nghttp3/build
3232c593315Sopenharmony_ci        key: ${{ runner.os }}-nghttp3-${{ env.NGHTTP3_VERSION }}
3242c593315Sopenharmony_ci        fail-on-cache-miss: true
3252c593315Sopenharmony_ci    - name: Restore ngtcp2 + quictls/openssl v1.1.1 cache
3262c593315Sopenharmony_ci      uses: actions/cache/restore@v3
3272c593315Sopenharmony_ci      if: matrix.http3 == 'http3' && (matrix.openssl == 'openssl1' || matrix.openssl == 'boringssl')
3282c593315Sopenharmony_ci      with:
3292c593315Sopenharmony_ci        path: ngtcp2-openssl1/build
3302c593315Sopenharmony_ci        key: ${{ runner.os }}-ngtcp2-${{ env.NGTCP2_VERSION }}-openssl-${{ env.OPENSSL1_VERSION }}
3312c593315Sopenharmony_ci        fail-on-cache-miss: true
3322c593315Sopenharmony_ci    - name: Restore ngtcp2 + quictls/openssl v3.x cache
3332c593315Sopenharmony_ci      uses: actions/cache/restore@v3
3342c593315Sopenharmony_ci      if: matrix.http3 == 'http3' && matrix.openssl == 'openssl3'
3352c593315Sopenharmony_ci      with:
3362c593315Sopenharmony_ci        path: ngtcp2-openssl3/build
3372c593315Sopenharmony_ci        key: ${{ runner.os }}-ngtcp2-${{ env.NGTCP2_VERSION }}-openssl-${{ env.OPENSSL3_VERSION }}
3382c593315Sopenharmony_ci        fail-on-cache-miss: true
3392c593315Sopenharmony_ci    - name: Setup extra environment variables for HTTP/3
3402c593315Sopenharmony_ci      if: matrix.http3 == 'http3'
3412c593315Sopenharmony_ci      run: |
3422c593315Sopenharmony_ci        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"
3432c593315Sopenharmony_ci        LDFLAGS="$LDFLAGS -Wl,-rpath,$PWD/openssl1/build/lib -Wl,-rpath,$PWD/openssl3/build/lib -Wl,-rpath,$PWD/libbpf/build/lib64"
3442c593315Sopenharmony_ci        EXTRA_AUTOTOOLS_OPTS="--enable-http3 $EXTRA_AUTOTOOLS_OPTS"
3452c593315Sopenharmony_ci        EXTRA_CMAKE_OPTS="-DENABLE_HTTP3=1 $EXTRA_CMAKE_OPTS"
3462c593315Sopenharmony_ci
3472c593315Sopenharmony_ci        echo 'PKG_CONFIG_PATH='"$PKG_CONFIG_PATH" >> $GITHUB_ENV
3482c593315Sopenharmony_ci        echo 'LDFLAGS='"$LDFLAGS" >> $GITHUB_ENV
3492c593315Sopenharmony_ci        echo 'EXTRA_AUTOTOOLS_OPTS='"$EXTRA_AUTOTOOLS_OPTS" >> $GITHUB_ENV
3502c593315Sopenharmony_ci        echo 'EXTRA_CMAKE_OPTS='"$EXTRA_CMAKE_OPTS" >> $GITHUB_ENV
3512c593315Sopenharmony_ci    - name: Setup git submodules
3522c593315Sopenharmony_ci      run: |
3532c593315Sopenharmony_ci        git submodule update --init
3542c593315Sopenharmony_ci    - name: Configure autotools
3552c593315Sopenharmony_ci      run: |
3562c593315Sopenharmony_ci        autoreconf -i
3572c593315Sopenharmony_ci        ./configure
3582c593315Sopenharmony_ci    - name: Configure cmake (Linux)
3592c593315Sopenharmony_ci      if: matrix.buildtool == 'cmake' && runner.os == 'Linux'
3602c593315Sopenharmony_ci      run: |
3612c593315Sopenharmony_ci        make dist
3622c593315Sopenharmony_ci        VERSION=$(grep PACKAGE_VERSION config.h | cut -d' ' -f3 | tr -d '"')
3632c593315Sopenharmony_ci        tar xf nghttp2-$VERSION.tar.gz
3642c593315Sopenharmony_ci        cd nghttp2-$VERSION
3652c593315Sopenharmony_ci        echo 'NGHTTP2_CMAKE_DIR='"$PWD" >> $GITHUB_ENV
3662c593315Sopenharmony_ci
3672c593315Sopenharmony_ci        cmake -DENABLE_WERROR=1 -DWITH_MRUBY=1 -DWITH_NEVERBLEED=1 -DENABLE_APP=1 $EXTRA_CMAKE_OPTS -DCPPFLAGS="$CPPFLAGS" -DLDFLAGS="$LDFLAGS" .
3682c593315Sopenharmony_ci    - name: Configure cmake (MacOS)
3692c593315Sopenharmony_ci      if: matrix.buildtool == 'cmake' && runner.os == 'macOS'
3702c593315Sopenharmony_ci      run: |
3712c593315Sopenharmony_ci        make dist
3722c593315Sopenharmony_ci        VERSION=$(grep PACKAGE_VERSION config.h | cut -d' ' -f3 | tr -d '"')
3732c593315Sopenharmony_ci        tar xf nghttp2-$VERSION.tar.gz
3742c593315Sopenharmony_ci        cd nghttp2-$VERSION
3752c593315Sopenharmony_ci        echo 'NGHTTP2_CMAKE_DIR='"$PWD" >> $GITHUB_ENV
3762c593315Sopenharmony_ci
3772c593315Sopenharmony_ci        # This fixes infamous 'stdio.h not found' error.
3782c593315Sopenharmony_ci        echo 'SDKROOT='"$(xcrun --sdk macosx --show-sdk-path)" >> $GITHUB_ENV
3792c593315Sopenharmony_ci
3802c593315Sopenharmony_ci        cmake -DENABLE_WERROR=1 -DWITH_MRUBY=1 -DENABLE_APP=1 $EXTRA_CMAKE_OPTS -DCPPFLAGS="$CPPFLAGS" -DLDFLAGS="$LDFLAGS" .
3812c593315Sopenharmony_ci    - name: Build nghttp2 with autotools (Linux)
3822c593315Sopenharmony_ci      if: matrix.buildtool == 'autotools' && runner.os == 'Linux'
3832c593315Sopenharmony_ci      run: |
3842c593315Sopenharmony_ci        make -j"$(nproc)" distcheck \
3852c593315Sopenharmony_ci          DISTCHECK_CONFIGURE_FLAGS="--with-mruby --with-neverbleed --with-libev --enable-werror $EXTRA_AUTOTOOLS_OPTS CPPFLAGS=\"$CPPFLAGS\" LDFLAGS=\"$LDFLAGS\""
3862c593315Sopenharmony_ci    - name: Build nghttp2 with autotools (MacOS)
3872c593315Sopenharmony_ci      if: matrix.buildtool == 'autotools' && runner.os == 'macOS'
3882c593315Sopenharmony_ci      run: |
3892c593315Sopenharmony_ci        make -j"$(sysctl -n hw.ncpu)" distcheck \
3902c593315Sopenharmony_ci          DISTCHECK_CONFIGURE_FLAGS="--with-mruby --with-libev --enable-werror $EXTRA_AUTOTOOLS_OPTS CPPFLAGS=\"$CPPFLAGS\" LDFLAGS=\"$LDFLAGS\""
3912c593315Sopenharmony_ci    - name: Build nghttp2 with cmake
3922c593315Sopenharmony_ci      if: matrix.buildtool == 'cmake'
3932c593315Sopenharmony_ci      run: |
3942c593315Sopenharmony_ci        cd $NGHTTP2_CMAKE_DIR
3952c593315Sopenharmony_ci        make -j"$(nproc 2> /dev/null || sysctl -n hw.ncpu)"
3962c593315Sopenharmony_ci        make -j"$(nproc 2> /dev/null || sysctl -n hw.ncpu)" check
3972c593315Sopenharmony_ci    - uses: actions/setup-go@v4
3982c593315Sopenharmony_ci      if: matrix.buildtool == 'cmake'
3992c593315Sopenharmony_ci      with:
4002c593315Sopenharmony_ci        go-version-file: go.mod
4012c593315Sopenharmony_ci    - name: Integration test
4022c593315Sopenharmony_ci      # Integration tests for nghttpx; autotools erases build
4032c593315Sopenharmony_ci      # artifacts.
4042c593315Sopenharmony_ci      if: matrix.buildtool == 'cmake'
4052c593315Sopenharmony_ci      run: |
4062c593315Sopenharmony_ci        cd $NGHTTP2_CMAKE_DIR/integration-tests
4072c593315Sopenharmony_ci        make itprep it
4082c593315Sopenharmony_ci
4092c593315Sopenharmony_ci  build-cross:
4102c593315Sopenharmony_ci    strategy:
4112c593315Sopenharmony_ci      matrix:
4122c593315Sopenharmony_ci        host: [x86_64-w64-mingw32, i686-w64-mingw32]
4132c593315Sopenharmony_ci
4142c593315Sopenharmony_ci    runs-on: ubuntu-22.04
4152c593315Sopenharmony_ci
4162c593315Sopenharmony_ci    env:
4172c593315Sopenharmony_ci      HOST: ${{ matrix.host }}
4182c593315Sopenharmony_ci
4192c593315Sopenharmony_ci    steps:
4202c593315Sopenharmony_ci    - uses: actions/checkout@v4
4212c593315Sopenharmony_ci    - name: Linux setup
4222c593315Sopenharmony_ci      run: |
4232c593315Sopenharmony_ci        sudo dpkg --add-architecture i386
4242c593315Sopenharmony_ci        sudo apt-get update
4252c593315Sopenharmony_ci        sudo apt-get install \
4262c593315Sopenharmony_ci          gcc-mingw-w64 \
4272c593315Sopenharmony_ci          autoconf \
4282c593315Sopenharmony_ci          automake \
4292c593315Sopenharmony_ci          autotools-dev \
4302c593315Sopenharmony_ci          libtool \
4312c593315Sopenharmony_ci          pkg-config \
4322c593315Sopenharmony_ci          wine
4332c593315Sopenharmony_ci    - name: Build CUnit
4342c593315Sopenharmony_ci      run: |
4352c593315Sopenharmony_ci        curl -LO https://jaist.dl.sourceforge.net/project/cunit/CUnit/2.1-3/CUnit-2.1-3.tar.bz2
4362c593315Sopenharmony_ci        tar xf CUnit-2.1-3.tar.bz2
4372c593315Sopenharmony_ci        cd CUnit-2.1-3
4382c593315Sopenharmony_ci        ./bootstrap
4392c593315Sopenharmony_ci        ./configure --disable-shared --host="$HOST" --prefix="$PWD/build"
4402c593315Sopenharmony_ci        make -j$(nproc) install
4412c593315Sopenharmony_ci    - name: Configure autotools
4422c593315Sopenharmony_ci      run: |
4432c593315Sopenharmony_ci        autoreconf -i && \
4442c593315Sopenharmony_ci        ./configure --enable-werror --enable-lib-only --with-cunit \
4452c593315Sopenharmony_ci          --host="$HOST" PKG_CONFIG_PATH="$PWD/CUnit-2.1-3/build/lib/pkgconfig" \
4462c593315Sopenharmony_ci          CFLAGS="-g -O2 -D_WIN32_WINNT=0x0600"
4472c593315Sopenharmony_ci    - name: Build nghttp2
4482c593315Sopenharmony_ci      run: |
4492c593315Sopenharmony_ci        make -j$(nproc)
4502c593315Sopenharmony_ci        make -j$(nproc) check TESTS=""
4512c593315Sopenharmony_ci    - name: Run tests
4522c593315Sopenharmony_ci      if: matrix.host == 'x86_64-w64-mingw32'
4532c593315Sopenharmony_ci      run: |
4542c593315Sopenharmony_ci        cd tests
4552c593315Sopenharmony_ci        wine main.exe
4562c593315Sopenharmony_ci
4572c593315Sopenharmony_ci  build-windows:
4582c593315Sopenharmony_ci    strategy:
4592c593315Sopenharmony_ci      matrix:
4602c593315Sopenharmony_ci        arch: [x86, x64]
4612c593315Sopenharmony_ci        include:
4622c593315Sopenharmony_ci        - arch: x86
4632c593315Sopenharmony_ci          platform: Win32
4642c593315Sopenharmony_ci        - arch: x64
4652c593315Sopenharmony_ci          platform: x64
4662c593315Sopenharmony_ci
4672c593315Sopenharmony_ci    runs-on: windows-latest
4682c593315Sopenharmony_ci
4692c593315Sopenharmony_ci    steps:
4702c593315Sopenharmony_ci    - uses: actions/checkout@v4
4712c593315Sopenharmony_ci    - uses: microsoft/setup-msbuild@v1
4722c593315Sopenharmony_ci    - run: |
4732c593315Sopenharmony_ci        vcpkg --triplet=${{ matrix.arch }}-windows install cunit
4742c593315Sopenharmony_ci    - name: Configure cmake
4752c593315Sopenharmony_ci      run: |
4762c593315Sopenharmony_ci        mkdir build
4772c593315Sopenharmony_ci        cd build
4782c593315Sopenharmony_ci        cmake -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_GENERATOR_PLATFORM=${{ matrix.platform }} -DVCPKG_TARGET_TRIPLET=${{ matrix.arch}}-windows ..
4792c593315Sopenharmony_ci    - name: Build nghttp2
4802c593315Sopenharmony_ci      run: |
4812c593315Sopenharmony_ci        cmake --build build
4822c593315Sopenharmony_ci        cmake --build build --target check
483