summaryrefslogtreecommitdiffstats
path: root/.github/workflows/build.yml
blob: 0c2abfcd4f64a827c74297a36e6c5d5e659b638e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
name: build

on: [push, pull_request]

jobs:
  build:
    strategy:
      matrix:
        os: [ubuntu-22.04, macos-11]
        compiler: [gcc, clang]
        buildtool: [autotools, distcheck, cmake]
        openssl: [openssl1, openssl3]
        sockaddr: [native-sockaddr, generic-sockaddr]
        exclude:
        - os: macos-11
          buildtool: distcheck
        - compiler: gcc
          buildtool: distcheck
        - openssl: openssl3
          buildtool: distcheck
        - compiler: gcc
          sockaddr: generic-sockaddr
        - openssl: openssl3
          sockaddr: generic-sockaddr
        - buildtool: distcheck
          sockaddr: generic-sockaddr
        - buildtool: cmake
          sockaddr: generic-sockaddr
        - os: macos-11
          compiler: gcc
        - os: macos-11
          openssl: openssl3

    runs-on: ${{ matrix.os }}

    steps:
    - uses: actions/checkout@v3
    - name: Startup
      run: |
        echo 'NGTCP2_SOURCE_DIR='"$PWD" >> $GITHUB_ENV
    - name: Linux setup
      if: runner.os == 'Linux'
      run: |
        sudo apt-get update
        sudo apt-get install \
          g++-12 \
          clang-14 \
          autoconf \
          automake \
          autotools-dev \
          libtool \
          pkg-config \
          libcunit1-dev \
          libssl-dev \
          libev-dev \
          libgnutls28-dev \
          cmake \
          cmake-data \
          python3-pytest

        echo 'NPROC='"$(nproc)" >> $GITHUB_ENV
    - name: MacOS setup
      if: runner.os == 'macOS'
      run: |
        brew install libev gnutls cunit autoconf automake pkg-config libtool

        echo 'NPROC='"$(sysctl -n hw.ncpu)" >> $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
      if: runner.os == 'Linux' && matrix.compiler == 'gcc'
      run: |
        echo 'CC=gcc-12' >> $GITHUB_ENV
        echo 'CXX=g++-12' >> $GITHUB_ENV
    - name: Build OpenSSL v1.1.1
      if: matrix.openssl == 'openssl1'
      run: |
        ./ci/build_openssl1.sh
    - name: Build OpenSSL v3.0.x
      if: matrix.openssl == 'openssl3'
      run: |
        ./ci/build_openssl3.sh
    - name: Build BoringSSL
      run: |
        ./ci/build_boringssl.sh
    - name: Build Picotls
      run: |
        ./ci/build_picotls.sh
    - name: Build wolfSSL
      run: |
        ./ci/build_wolfssl.sh
    - name: Build nghttp3
      run: |
        ./ci/build_nghttp3.sh
    - name: Setup environment variables
      run: |
        PKG_CONFIG_PATH="$PWD/openssl/build/lib/pkgconfig:$PWD/openssl/build/lib64/pkgconfig:$PWD/wolfssl/build/lib/pkgconfig:$PWD/nghttp3/build/lib/pkgconfig"
        LDFLAGS="$EXTRA_LDFLAGS -Wl,-rpath,$PWD/openssl/build/lib -Wl,-rpath,$PWD/openssl/build/lib64"
        BORINGSSL_CFLAGS="-I$PWD/boringssl/include/"
        BORINGSSL_LIBS="-L$PWD/boringssl/build/ssl -lssl -L$PWD/boringssl/build/crypto -lcrypto"
        PICOTLS_CFLAGS="-I$PWD/picotls/include/"
        PICOTLS_LIBS="-L$PWD/picotls/build -lpicotls-openssl -lpicotls-core"

        echo 'PKG_CONFIG_PATH='"$PKG_CONFIG_PATH" >> $GITHUB_ENV
        echo 'LDFLAGS='"$LDFLAGS" >> $GITHUB_ENV
        echo 'BORINGSSL_CFLAGS='"$BORINGSSL_CFLAGS" >> $GITHUB_ENV
        echo 'BORINGSSL_LIBS='"$BORINGSSL_LIBS" >> $GITHUB_ENV
        echo 'PICOTLS_CFLAGS='"$PICOTLS_CFLAGS" >> $GITHUB_ENV
        echo 'PICOTLS_LIBS='"$PICOTLS_LIBS" >> $GITHUB_ENV
    - name: Enable ASAN
      if: runner.os == 'Linux'
      run: |
        asanflags="-fsanitize=address,undefined -fno-sanitize-recover=undefined"

        LDFLAGS="$LDFLAGS $asanflags"
        CFLAGS="$CFLAGS $asanflags -g3"
        CXXFLAGS="$CXXFLAGS $asanflags -g3"

        echo 'LDFLAGS='"$LDFLAGS" >> $GITHUB_ENV
        echo 'CFLAGS='"$CFLAGS" >> $GITHUB_ENV
        echo 'CXXFLAGS='"$CXXFLAGS" >> $GITHUB_ENV
    - name: BoringSSL pthread requirement
      if: runner.os == 'Linux'
      run: |
        BORINGSSL_LIBS="$BORINGSSL_LIBS -pthread"

        echo 'BORINGSSL_LIBS='"$BORINGSSL_LIBS" >> $GITHUB_ENV
    - name: Enable generic sockaddr
      if: matrix.sockaddr == 'generic-sockaddr'
      run: |
        CFLAGS="$CFLAGS -DNGTCP2_USE_GENERIC_SOCKADDR"
        EXTRA_AUTOTOOLS_OPTS="$EXTRA_AUTOTOOLS_OPTS --enable-lib-only"

        echo 'CFLAGS='"$CFLAGS" >> $GITHUB_ENV
        echo 'EXTRA_AUTOTOOLS_OPTS='"$EXTRA_AUTOTOOLS_OPTS" >> $GITHUB_ENV
    - name: Configure autotools
      if: matrix.buildtool == 'autotools'
      run: |
        autoreconf -i && \
        ./configure --enable-werror \
          --with-openssl --with-gnutls --with-boringssl --with-wolfssl \
          --with-picotls \
          $EXTRA_AUTOTOOLS_OPTS
    - name: Configure autotools for distcheck
      if: matrix.buildtool == 'distcheck'
      run: |
        autoreconf -i && ./configure
    - name: Configure cmake
      if: matrix.buildtool == 'cmake'
      run: |
        autoreconf -i && ./configure
        make dist

        VERSION=$(grep PACKAGE_VERSION config.h | cut -d' ' -f3 | tr -d '"')
        tar xf ngtcp2-$VERSION.tar.gz
        cd ngtcp2-$VERSION
        mkdir build
        cd build

        echo 'NGTCP2_BUILD_DIR='"$PWD" >> $GITHUB_ENV

        cmake $CMAKE_OPTS \
          -DENABLE_GNUTLS=ON \
          -DENABLE_BORINGSSL=ON \
          -DBORINGSSL_LIBRARIES="$BORINGSSL_LIBS" \
          -DBORINGSSL_INCLUDE_DIR="$NGTCP2_SOURCE_DIR/boringssl/include/" \
          -DENABLE_PICOTLS=ON \
          -DPICOTLS_LIBRARIES="$PICOTLS_LIBS" \
          -DPICOTLS_INCLUDE_DIR="$NGTCP2_SOURCE_DIR/picotls/include/" \
          -DENABLE_WOLFSSL=ON ..
    - name: Build ngtcp2
      if: matrix.buildtool != 'distcheck'
      run: |
        [ -n "$NGTCP2_BUILD_DIR" ] && cd "$NGTCP2_BUILD_DIR"
        make -j"$NPROC"
        make -j"$NPROC" check
    - name: Build ngtcp2 with distcheck
      if: matrix.buildtool == 'distcheck'
      run: |
        make -j"$NPROC" distcheck \
          DISTCHECK_CONFIGURE_FLAGS="--enable-werror --with-openssl --with-gnutls --with-boringssl $EXTRA_AUTOTOOLS_OPTS"
    - name: examples/tests
      if: matrix.buildtool == 'autotools' && matrix.sockaddr == 'native-sockaddr' && runner.os == 'Linux'
      run: |
        cd examples/tests
        # Do not run resumption and earlydata between gtlsserver and
        # wsslclient until ubuntu gets GnuTLS v3.7.5.
        #
        # There is an issue around the ticket age validation between
        # gtlsserver and bsslclient that causes early data test
        # failure; see https://gitlab.com/gnutls/gnutls/-/issues/1403
        pytest-3 -v -k 'not (gnutls-wolfssl and (resume or earlydata)) and not (gnutls-boringssl and earlydata)'
    - name: Integration test
      if: matrix.buildtool != 'distcheck' && matrix.sockaddr == 'native-sockaddr'
      run: |
        [ -n "$NGTCP2_BUILD_DIR" ] && cd "$NGTCP2_BUILD_DIR"
        "$NGTCP2_SOURCE_DIR"/ci/gen-certificate.sh

        CLIENTS="client gtlsclient bsslclient wsslclient ptlsclient"
        SERVERS="server gtlsserver bsslserver wsslserver ptlsserver"

        for client in $CLIENTS; do
          for server in $SERVERS; do
            echo "# $client - $server"
            ./examples/$server localhost 4433 cert/server.key cert/server.crt > sv.log 2>&1 &
            SVPID="$!"
            ./examples/$client localhost 4433 https://localhost/ --exit-on-first-stream-close
            kill -INT "$SVPID"
            sleep 5
            if wait "$SVPID"; then
              cat sv.log
            else
              cat sv.log
              exit 1
            fi
          done
        done

  build-cross:
    strategy:
      matrix:
        host: [x86_64-w64-mingw32, i686-w64-mingw32]
        include:
        - host: x86_64-w64-mingw32
          oscc: mingw64
        - host: i686-w64-mingw32
          oscc: mingw

    runs-on: ubuntu-22.04

    env:
      HOST: ${{ matrix.host }}
      OSCC: ${{ matrix.oscc }}

    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 OpenSSL v1.1.1
      run: |
        ./ci/build_openssl1_cross.sh
    - 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: Setup environment variables
      run: |
        PKG_CONFIG_PATH="$PWD/openssl/build/lib/pkgconfig:$PWD/CUnit-2.1-3/build/lib/pkgconfig"

        echo 'PKG_CONFIG_PATH='"$PKG_CONFIG_PATH" >> $GITHUB_ENV
    - name: Configure autotools
      run: |
        autoreconf -i && \
        ./configure --enable-werror --with-openssl --with-cunit --host="$HOST"
    - name: Build ngtcp2
      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:
    runs-on: windows-latest

    steps:
    - uses: actions/checkout@v3
    - name: Configure cmake
      run: |
        mkdir build
        cd build
        cmake ..
    - name: Build ngtcp2
      run: |
        cmake --build build