xref: /curl/.github/workflows/linux.yml (revision 34555724)
1# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
2#
3# SPDX-License-Identifier: curl
4
5name: Linux
6
7on:
8  push:
9    branches:
10      - master
11      - '*/ci'
12    paths-ignore:
13      - '**/*.md'
14      - '.azure-pipelines.yml'
15      - '.circleci/**'
16      - '.cirrus.yml'
17      - 'appveyor.*'
18      - 'packages/**'
19      - 'plan9/**'
20      - 'projects/**'
21      - 'winbuild/**'
22  pull_request:
23    branches:
24      - master
25    paths-ignore:
26      - '**/*.md'
27      - '.azure-pipelines.yml'
28      - '.circleci/**'
29      - '.cirrus.yml'
30      - 'appveyor.*'
31      - 'packages/**'
32      - 'plan9/**'
33      - 'projects/**'
34      - 'winbuild/**'
35
36concurrency:
37  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
38  cancel-in-progress: true
39
40permissions: {}
41
42env:
43  MAKEFLAGS: -j 3
44  # unhandled
45  bearssl-version: 0.6
46  # renovate: datasource=github-tags depName=libressl-portable/portable versioning=semver registryUrl=https://github.com
47  libressl-version: 3.9.2
48  # renovate: datasource=github-tags depName=ARMmbed/mbedtls versioning=semver registryUrl=https://github.com
49  mbedtls-version: 3.5.0
50  # renovate: datasource=github-tags depName=icing/mod_h2 versioning=semver registryUrl=https://github.com
51  mod_h2-version: 2.0.27
52  # renovate: datasource=github-tags depName=nibanks/msh3 versioning=semver registryUrl=https://github.com
53  msh3-version: 0.6.0
54  # handled in renovate.json
55  openssl3-version: openssl-3.1.3
56  # unhandled
57  quictls-version: 3.1.4+quic
58  # renovate: datasource=github-tags depName=rustls/rustls-ffi versioning=semver registryUrl=https://github.com
59  rustls-version: 0.13.0
60
61jobs:
62  autotools:
63    name: ${{ matrix.build.name }}
64    runs-on: 'ubuntu-latest'
65    container: ${{ matrix.build.container }}
66    timeout-minutes: 90
67    strategy:
68      fail-fast: false
69      matrix:
70        build:
71          - name: bearssl
72            install_packages: zlib1g-dev valgrind
73            install_steps: bearssl pytest
74            configure: LDFLAGS="-Wl,-rpath,$HOME/bearssl/lib" --with-bearssl=$HOME/bearssl --enable-debug
75            singleuse: --unit
76
77          - name: bearssl-clang
78            install_packages: zlib1g-dev clang
79            install_steps: bearssl
80            configure: CC=clang LDFLAGS="-Wl,-rpath,$HOME/bearssl/lib" --with-bearssl=$HOME/bearssl --enable-debug
81            singleuse: --unit
82
83          - name: libressl
84            install_packages: zlib1g-dev valgrind
85            install_steps: libressl pytest
86            configure: LDFLAGS="-Wl,-rpath,$HOME/libressl/lib" --with-openssl=$HOME/libressl --enable-debug
87            singleuse: --unit
88
89          - name: libressl-clang
90            install_packages: zlib1g-dev clang
91            install_steps: libressl
92            configure: CC=clang LDFLAGS="-Wl,-rpath,$HOME/libressl/lib" --with-openssl=$HOME/libressl --enable-debug
93            singleuse: --unit
94
95          - name: mbedtls
96            install_packages: libnghttp2-dev valgrind
97            install_steps: mbedtls pytest
98            configure: LDFLAGS="-Wl,-rpath,$HOME/mbedtls/lib" --with-mbedtls=$HOME/mbedtls --enable-debug
99            singleuse: --unit
100
101          - name: mbedtls-clang
102            install_packages: libnghttp2-dev clang
103            install_steps: mbedtls
104            configure: CC=clang LDFLAGS="-Wl,-rpath,$HOME/mbedtls/lib" --with-mbedtls=$HOME/mbedtls --enable-debug
105            singleuse: --unit
106
107          - name: msh3
108            install_packages: zlib1g-dev valgrind
109            install_steps: quictls msh3
110            configure: LDFLAGS="-Wl,-rpath,$HOME/msh3/lib -Wl,-rpath,$HOME/quictls/lib" --with-msh3=$HOME/msh3 --with-openssl=$HOME/quictls --enable-debug
111            singleuse: --unit
112
113          - name: openssl3
114            install_packages: zlib1g-dev valgrind
115            install_steps: gcc-11 openssl3 pytest
116            configure: CFLAGS=-std=gnu89 LDFLAGS="-Wl,-rpath,$HOME/openssl3/lib" --with-openssl=$HOME/openssl3 --enable-debug --enable-websockets
117            singleuse: --unit
118
119          - name: openssl3-O3
120            install_packages: zlib1g-dev valgrind
121            install_steps: gcc-11 openssl3
122            configure: CPPFLAGS=-DCURL_WARN_SIGN_CONVERSION CFLAGS=-O3 LDFLAGS="-Wl,-rpath,$HOME/openssl3/lib" --with-openssl=$HOME/openssl3 --enable-debug --enable-websockets
123            singleuse: --unit
124
125          - name: openssl3-clang
126            install_packages: zlib1g-dev clang
127            install_steps: openssl3
128            configure: CC=clang LDFLAGS="-Wl,-rpath,$HOME/openssl3/lib" --with-openssl=$HOME/openssl3 --enable-debug --enable-websockets
129            singleuse: --unit
130
131          - name: address-sanitizer
132            install_packages: zlib1g-dev libssh2-1-dev clang libssl-dev libubsan1 libasan8 libtsan2
133            install_steps: pytest
134            configure: >
135              CC=clang
136              CFLAGS="-fsanitize=address,undefined,signed-integer-overflow -fno-sanitize-recover=undefined,integer -Wformat -Werror=format-security -Werror=array-bounds -g"
137              LDFLAGS="-fsanitize=address,undefined -fno-sanitize-recover=undefined,integer"
138              LIBS="-ldl -lubsan"
139              --with-openssl --enable-debug --enable-websockets
140            singleuse: --unit
141
142          - name: memory-sanitizer
143            install_packages: clang
144            install_steps:
145            configure: >
146              CC=clang
147              CFLAGS="-fsanitize=memory -Wformat -Werror=format-security -Werror=array-bounds -g"
148              LDFLAGS="-fsanitize=memory"
149              LIBS="-ldl"
150              --without-ssl --without-zlib --without-brotli --without-zstd --without-libpsl --without-nghttp2 --enable-debug --enable-websockets
151            singleuse: --unit
152
153          - name: event-based
154            install_packages: libssh-dev valgrind
155            configure: --enable-debug --disable-shared --disable-threaded-resolver --with-libssh --with-openssl
156            tflags: -n -e '!TLS-SRP'
157            singleuse: --unit
158
159          - name: hyper
160            install_steps: rust hyper valgrind
161            configure: LDFLAGS="-Wl,-rpath,$HOME/hyper/target/debug" --with-openssl --with-hyper=$HOME/hyper --enable-debug --enable-websockets
162            singleuse: --unit
163
164          - name: rustls
165            install_steps: rust rustls pytest valgrind libpsl-dev
166            configure: --with-rustls=$HOME/rustls --enable-debug
167            singleuse: --unit
168
169          - name: Intel compiler - without SSL
170            install_packages: zlib1g-dev valgrind
171            install_steps: intel
172            configure: CC=icc --enable-debug --without-ssl
173            singleuse: --unit
174
175          - name: Intel compiler - OpenSSL
176            install_packages: zlib1g-dev libssl-dev valgrind
177            install_steps: intel
178            configure: CC=icc --enable-debug --with-openssl
179            singleuse: --unit
180
181          - name: Slackware-openssl-with-gssapi-gcc
182            # These are essentially the same flags used to build the curl Slackware package
183            # https://ftpmirror.infania.net/slackware/slackware64-current/source/n/curl/curl.SlackBuild
184            configure: --with-openssl --with-libssh2 --with-gssapi --enable-ares --enable-static=no --without-ca-bundle --with-ca-path=/etc/ssl/certs
185            # Docker Hub image that `container-job` executes in
186            container: 'andy5995/slackware-build-essential:15.0'
187
188          - name: Alpine MUSL
189            configure: --enable-debug --enable-websockets --with-ssl --with-libssh2 --with-libidn2 --with-gssapi --enable-ldap --with-libpsl
190            container: 'alpine:3.18'
191            singleuse: --unit
192
193    steps:
194      - if: matrix.build.container == null
195        run: |
196          sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list
197          sudo apt-get update
198          sudo apt-get install libtool autoconf automake pkg-config stunnel4 libpsl-dev libbrotli-dev libzstd-dev ${{ matrix.build.install_packages }}
199          sudo python3 -m pip install impacket
200        name: 'install prereqs and impacket'
201
202      - if: startsWith(matrix.build.container, 'alpine')
203        run: |
204          apk add --no-cache build-base autoconf automake libtool perl openssl-dev libssh2-dev zlib-dev brotli-dev zstd-dev libidn2-dev openldap-dev heimdal-dev libpsl-dev py3-impacket py3-asn1 py3-six py3-pycryptodomex perl-time-hires openssh stunnel sudo git
205        name: 'install dependencies'
206
207      - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4
208
209      - name: Fix kernel mmap rnd bits
210        # Asan in llvm 14 provided in ubuntu 22.04 is incompatible with
211        # high-entropy ASLR in much newer kernels that GitHub runners are
212        # using leading to random crashes: https://reviews.llvm.org/D148280
213        # See https://github.com/actions/runner-images/issues/9491
214        continue-on-error: true
215        run: sudo sysctl vm.mmap_rnd_bits=28
216
217      - if: contains(matrix.build.install_steps, 'gcc-11')
218        run: |
219          sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa
220          sudo apt-get update
221          sudo apt-get install gcc-11
222          sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 100
223          sudo update-alternatives --set gcc /usr/bin/gcc-11
224          gcc --version
225        name: 'install gcc-11'
226
227      - name: cache bearssl
228        if: contains(matrix.build.install_steps, 'bearssl')
229        uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
230        id: cache-bearssl
231        env:
232          cache-name: cache-bearssl
233        with:
234          path: /home/runner/bearssl
235          key: ${{ runner.os }}-build-${{ env.cache-name }}-bearssl-${{ env.bearssl-version }}
236
237      - name: 'build bearssl'
238        if: contains(matrix.build.install_steps, 'bearssl') && steps.cache-bearssl.outputs.cache-hit != 'true'
239        run: |
240          curl -LOsSf --retry 6 --retry-connrefused --max-time 999 https://bearssl.org/bearssl-${{ env.bearssl-version }}.tar.gz
241          tar -xzf bearssl-${{ env.bearssl-version }}.tar.gz
242          cd bearssl-${{ env.bearssl-version }}
243          make
244          mkdir -p $HOME/bearssl/lib $HOME/bearssl/include
245          cp inc/*.h $HOME/bearssl/include
246          cp build/libbearssl.* $HOME/bearssl/lib
247
248      - name: cache libressl
249        if: contains(matrix.build.install_steps, 'libressl')
250        uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
251        id: cache-libressl
252        env:
253          cache-name: cache-libressl
254        with:
255          path: /home/runner/libressl
256          key: ${{ runner.os }}-build-${{ env.cache-name }}-libressl-${{ env.libressl-version }}
257
258      - name: 'build libressl'
259        if: contains(matrix.build.install_steps, 'libressl') && steps.cache-libressl.outputs.cache-hit != 'true'
260        run: |
261          git clone --quiet --depth=1 -b v${{ env.libressl-version }} https://github.com/libressl-portable/portable.git libressl-git
262          cd libressl-git
263          ./autogen.sh
264          ./configure --prefix=$HOME/libressl
265          make install
266
267      - name: cache mbedtls
268        if: contains(matrix.build.install_steps, 'mbedtls')
269        uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
270        id: cache-mbedtls
271        env:
272          cache-name: cache-mbedtls
273        with:
274          path: /home/runner/mbedtls
275          key: ${{ runner.os }}-build-${{ env.cache-name }}-mbedtls-${{ env.mbedtls-version }}
276
277      - name: 'build mbedtls'
278        if: contains(matrix.build.install_steps, 'mbedtls') && steps.cache-mbedtls.outputs.cache-hit != 'true'
279        run: |
280          git clone --quiet --depth=1 -b v${{ env.mbedtls-version }} https://github.com/ARMmbed/mbedtls
281          cd mbedtls
282          git submodule update --init
283          make DESTDIR=$HOME/mbedtls install
284
285      - name: cache openssl3
286        if: contains(matrix.build.install_steps, 'openssl3')
287        uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
288        id: cache-openssl3
289        env:
290          cache-name: cache-openssl3
291        with:
292          path: /home/runner/openssl3
293          key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.openssl3-version }}
294
295      - name: 'install openssl3'
296        if: contains(matrix.build.install_steps, 'openssl3') && steps.cache-openssl3.outputs.cache-hit != 'true'
297        run: |
298          git clone --quiet --depth=1 -b ${{ env.openssl3-version }} https://github.com/openssl/openssl
299          cd openssl
300          ./config --prefix=$HOME/openssl3 --libdir=$HOME/openssl3/lib
301          make -j1 install_sw
302
303      - name: cache quictls
304        if: contains(matrix.build.install_steps, 'quictls')
305        uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
306        id: cache-quictls
307        env:
308          cache-name: cache-quictls
309        with:
310          path: /home/runner/quictls
311          key: ${{ runner.os }}-build-${{ env.cache-name }}-quictls-${{ env.quictls-version }}
312
313      - name: 'build quictls'
314        if: contains(matrix.build.install_steps, 'quictls') && steps.cache-quictls.outputs.cache-hit != 'true'
315        run: |
316          git clone --quiet --depth=1 -b openssl-${{ env.quictls-version }} https://github.com/quictls/openssl
317          cd openssl
318          ./config --prefix=$HOME/quictls --libdir=$HOME/quictls/lib
319          make -j1 install_sw
320
321      - name: cache msh3
322        if: contains(matrix.build.install_steps, 'msh3')
323        uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
324        id: cache-msh3
325        env:
326          cache-name: cache-msh3
327        with:
328          path: /home/runner/msh3
329          key: ${{ runner.os }}-build-${{ env.cache-name }}-msh3-${{ env.msh3-version }}
330
331      - name: 'build msh3'
332        if: contains(matrix.build.install_steps, 'msh3') && steps.cache-msh3.outputs.cache-hit != 'true'
333        run: |
334          git clone --quiet -b v${{ env.msh3-version }} --depth=1 --recursive https://github.com/nibanks/msh3
335          cd msh3 && mkdir build && cd build
336          cmake -G 'Unix Makefiles' -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=$HOME/msh3 ..
337          cmake --build .
338          cmake --install .
339
340      - if: contains(matrix.build.install_steps, 'rust')
341        run: |
342          cd $HOME
343          curl -sSf --compressed https://sh.rustup.rs/ | sh -s -- -y
344          source $HOME/.cargo/env
345          rustup toolchain install nightly
346        name: 'install rust'
347
348      - name: cache rustls
349        if: contains(matrix.build.install_steps, 'rustls')
350        uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
351        id: cache-rustls
352        env:
353          cache-name: cache-rustls
354        with:
355          path: /home/runner/rustls
356          key: ${{ runner.os }}-build-${{ env.cache-name }}-rustls-${{ env.rustls-version }}
357
358      - name: 'build rustls'
359        if: contains(matrix.build.install_steps, 'rustls') && steps.cache-rustls.outputs.cache-hit != 'true'
360        run: |
361          git clone --quiet --depth=1 -b v${{ env.rustls-version }} --recursive https://github.com/rustls/rustls-ffi.git
362          cd rustls-ffi
363          make DESTDIR=$HOME/rustls install
364
365      - if: contains(matrix.build.install_steps, 'hyper')
366        run: |
367          cd $HOME
368          git clone --quiet --depth=1 https://github.com/hyperium/hyper.git
369          cd $HOME/hyper
370          RUSTFLAGS="--cfg hyper_unstable_ffi" cargo +nightly rustc --features client,http1,http2,ffi -Z unstable-options --crate-type cdylib
371          echo "LD_LIBRARY_PATH=$HOME/hyper/target/debug:/usr/local/lib" >> $GITHUB_ENV
372        name: 'install hyper'
373
374      - if: contains(matrix.build.install_steps, 'intel')
375        run: |
376          cd /tmp
377          curl -sSf --compressed https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | sudo apt-key add -
378          sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
379          sudo apt install --no-install-recommends intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic
380          source /opt/intel/oneapi/setvars.sh
381          printenv >> $GITHUB_ENV
382        name: 'install Intel compilers'
383
384      - if: contains(matrix.build.install_steps, 'pytest')
385        run: |
386          sudo apt-get install apache2 apache2-dev libnghttp2-dev vsftpd
387          sudo python3 -m pip install -r tests/http/requirements.txt
388        name: 'install pytest and apach2-dev'
389
390      - name: cache mod_h2
391        if: contains(matrix.build.install_steps, 'pytest')
392        uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
393        id: cache-mod_h2
394        env:
395          cache-name: cache-mod_h2
396        with:
397          path: /home/runner/mod_h2
398          key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.mod_h2-version }}
399
400      - name: 'build mod_h2'
401        if: contains(matrix.build.install_steps, 'pytest') && steps.cache-mod_h2.outputs.cache-hit != 'true'
402        run: |
403          cd $HOME
404          git clone --quiet --depth=1 -b v${{ env.mod_h2-version }} https://github.com/icing/mod_h2
405          cd mod_h2
406          autoreconf -fi
407          ./configure
408          make
409
410      - name: 'install mod_h2'
411        if: contains(matrix.build.install_steps, 'pytest')
412        run: |
413          cd $HOME/mod_h2
414          sudo make install
415
416      - run: autoreconf -fi
417        name: 'autoreconf'
418
419      - run: ./configure --enable-warnings --enable-werror ${{ matrix.build.configure }}
420        name: 'configure'
421
422      - run: make V=1
423        name: 'make'
424
425      - run: |
426          git config --global --add safe.directory "*"
427          ./scripts/singleuse.pl ${{ matrix.build.singleuse }} lib/.libs/libcurl.a
428        name: single-use function check
429
430      - run: ./src/curl -V
431        name: 'check curl -V output'
432
433      - run: make V=1 examples
434        name: 'make examples'
435
436      - run: make V=1 -C tests
437        name: 'make tests'
438
439      - run: make V=1 test-ci
440        name: 'run tests'
441        env:
442          TFLAGS: "${{ matrix.build.tflags }}"
443
444      - if: contains(matrix.build.install_steps, 'pytest')
445        # run for `tests` directory, so pytest does not pick up any other
446        # packages we might have built here
447        run:
448          pytest -v tests
449        name: 'run pytest'
450        env:
451          TFLAGS: "${{ matrix.build.tflags }}"
452          CURL_CI: github
453