blob: 781a2b32b2ceaf90ecebb92d8bd00b5f05dd4cea [file] [log] [blame]
Tim Duesterhus288c0772020-07-28 23:00:35 +02001# Copyright 2019 Ilya Shipitsin <chipitsine@gmail.com>
2# Copyright 2020 Tim Duesterhus <tim@bastelstu.be>
3#
4# This program is free software; you can redistribute it and/or
5# modify it under the terms of the GNU General Public License
6# as published by the Free Software Foundation; either version
7# 2 of the License, or (at your option) any later version.
8
9name: VTest
10
11on:
12 push:
13
14jobs:
15 # The generate-matrix job generates the build matrix using JSON output
16 # generated by .github/matrix.py.
17 generate-matrix:
18 name: Generate Build Matrix
19 runs-on: ubuntu-latest
20 outputs:
21 matrix: ${{ steps.set-matrix.outputs.matrix }}
22 steps:
Tim Duesterhus4bb778b2022-04-09 22:08:41 +020023 - uses: actions/checkout@v3
Tim Duesterhus288c0772020-07-28 23:00:35 +020024 - name: Generate Build Matrix
25 id: set-matrix
Tim Duesterhus8d173e12020-11-20 00:16:00 +010026 run: python3 .github/matrix.py "${{ github.event_name }}"
Tim Duesterhus288c0772020-07-28 23:00:35 +020027
28 # The Test job actually runs the tests.
29 Test:
30 name: ${{ matrix.name }}
31 needs: generate-matrix
32 runs-on: ${{ matrix.os }}
33 strategy:
34 matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
35 fail-fast: false
36 env:
37 # Configure a short TMPDIR to prevent failures due to long unix socket
38 # paths.
39 TMPDIR: /tmp
40 # Force ASAN output into asan.log to make the output more readable.
41 ASAN_OPTIONS: log_path=asan.log
Ilya Shipitsinef86b472022-01-13 11:36:28 +050042 OT_CPP_VERSION: 1.5.0
Tim Duesterhus288c0772020-07-28 23:00:35 +020043 steps:
Tim Duesterhus4bb778b2022-04-09 22:08:41 +020044 - uses: actions/checkout@v3
Tim Duesterhus288c0772020-07-28 23:00:35 +020045 with:
46 fetch-depth: 100
Ilya Shipitsin81189f62022-01-22 00:00:44 +050047#
48# Github Action cache key cannot contain comma, so we calculate it based on job name
49#
50 - name: Generate cache key
51 id: generate-cache-key
52 run: |
Tim Duesterhus03072a92022-10-14 19:46:07 +020053 echo "key=$(echo ${{ matrix.name }} | sha256sum | awk '{print $1}')" >> $GITHUB_OUTPUT
Ilya Shipitsin81189f62022-01-22 00:00:44 +050054
55 - name: Cache SSL libs
56 if: ${{ matrix.ssl && matrix.ssl != 'stock' && matrix.ssl != 'BORINGSSL=yes' && matrix.ssl != 'QUICTLS=yes' }}
57 id: cache_ssl
Tim Duesterhus075dcae2022-04-09 22:08:42 +020058 uses: actions/cache@v3
Ilya Shipitsin81189f62022-01-22 00:00:44 +050059 with:
60 path: '~/opt/'
61 key: ssl-${{ steps.generate-cache-key.outputs.key }}
62
Ilya Shipitsinef86b472022-01-13 11:36:28 +050063 - name: Cache OpenTracing
64 if: ${{ contains(matrix.FLAGS, 'USE_OT=1') }}
65 id: cache_ot
Tim Duesterhus075dcae2022-04-09 22:08:42 +020066 uses: actions/cache@v3
Ilya Shipitsinef86b472022-01-13 11:36:28 +050067 with:
68 path: '~/opt-ot/'
69 key: ot-${{ matrix.CC }}-${{ env.OT_CPP_VERSION }}-${{ contains(matrix.name, 'ASAN') }}
Tim Duesterhus288c0772020-07-28 23:00:35 +020070 - name: Install apt dependencies
71 if: ${{ startsWith(matrix.os, 'ubuntu-') }}
72 run: |
Ilya Shipitsine48853a2020-11-21 13:42:19 +050073 sudo apt-get update
Tim Duesterhus288c0772020-07-28 23:00:35 +020074 sudo apt-get install -y \
75 liblua5.3-dev \
76 libpcre2-dev \
77 libsystemd-dev \
78 ninja-build \
79 socat
80 - name: Install brew dependencies
81 if: ${{ startsWith(matrix.os, 'macos-') }}
82 run: |
83 brew install socat
84 brew install lua
85 - name: Install VTest
86 run: |
Tim Duesterhus2ca0bbc2021-03-02 19:18:59 +010087 curl -fsSL https://github.com/vtest/VTest/archive/master.tar.gz -o VTest.tar.gz
Tim Duesterhus288c0772020-07-28 23:00:35 +020088 mkdir VTest
89 tar xvf VTest.tar.gz -C VTest --strip-components=1
Tim Duesterhusb38b5c32021-05-12 21:08:49 +020090 make -C VTest -j$(nproc) FLAGS="-O2 -s -Wall"
Tim Duesterhus288c0772020-07-28 23:00:35 +020091 sudo install -m755 VTest/vtest /usr/local/bin/vtest
Tim Duesterhus288c0772020-07-28 23:00:35 +020092 - name: Install SSL ${{ matrix.ssl }}
Ilya Shipitsin81189f62022-01-22 00:00:44 +050093 if: ${{ matrix.ssl && matrix.ssl != 'stock' && steps.cache_ssl.outputs.cache-hit != 'true' }}
Tim Duesterhus288c0772020-07-28 23:00:35 +020094 run: env ${{ matrix.ssl }} scripts/build-ssl.sh
Ilya Shipitsin73c3ed92021-05-18 09:46:43 +000095 - name: Install OpenTracing libs
Ilya Shipitsinef86b472022-01-13 11:36:28 +050096 if: ${{ contains(matrix.FLAGS, 'USE_OT=1') && steps.cache_ot.outputs.cache-hit != 'true' }}
97 run: |
98 wget https://github.com/opentracing/opentracing-cpp/archive/v${OT_CPP_VERSION}.tar.gz
99 tar xf v${OT_CPP_VERSION}.tar.gz
100 cd opentracing-cpp-${OT_CPP_VERSION}
101 mkdir build
102 cd build
103 cmake -DCMAKE_INSTALL_PREFIX=${HOME}/opt-ot -DBUILD_STATIC_LIBS=OFF -DBUILD_MOCKTRACER=OFF -DBUILD_TESTING=OFF ..
104 make -j$(nproc)
105 make install
106 git clone https://github.com/haproxytech/opentracing-c-wrapper.git
107 cd opentracing-c-wrapper
108 ./scripts/bootstrap
109 ./configure --prefix=${HOME}/opt-ot --with-opentracing=${HOME}/opt-ot
110 make -j$(nproc)
111 make install
Tim Duesterhus288c0772020-07-28 23:00:35 +0200112 - name: Build WURFL
113 if: ${{ contains(matrix.FLAGS, 'USE_WURFL=1') }}
Willy Tarreau57610c62021-04-02 16:39:44 +0200114 run: make -C addons/wurfl/dummy
Tim Duesterhus288c0772020-07-28 23:00:35 +0200115 - name: Compile HAProxy with ${{ matrix.CC }}
116 run: |
Willy Tarreauc0a0def2022-11-14 11:03:18 +0100117 echo "::group::Show compiler's version"
118 echo | ${{ matrix.CC }} -v
119 echo "::endgroup::"
Willy Tarreau06bed612021-11-26 15:45:41 +0100120 echo "::group::Show platform specific defines"
121 echo | ${{ matrix.CC }} -dM -xc -E -
122 echo "::endgroup::"
Tim Duesterhus288c0772020-07-28 23:00:35 +0200123 make -j$(nproc) all \
124 ERR=1 \
125 TARGET=${{ matrix.TARGET }} \
126 CC=${{ matrix.CC }} \
Willy Tarreau16bfd732022-02-23 17:58:46 +0100127 DEBUG="-DDEBUG_STRICT -DDEBUG_MEMORY_POOLS -DDEBUG_POOL_INTEGRITY" \
Tim Duesterhus288c0772020-07-28 23:00:35 +0200128 ${{ join(matrix.FLAGS, ' ') }} \
129 ADDLIB="-Wl,-rpath,/usr/local/lib/ -Wl,-rpath,$HOME/opt/lib/"
130 sudo make install
131 - name: Show HAProxy version
132 id: show-version
133 run: |
134 echo "::group::Show dynamic libraries."
135 if command -v ldd > /dev/null; then
136 # Linux
137 ldd $(which haproxy)
138 else
139 # macOS
140 otool -L $(which haproxy)
141 fi
142 echo "::endgroup::"
143 haproxy -vv
Tim Duesterhus03072a92022-10-14 19:46:07 +0200144 echo "version=$(haproxy -v |awk 'NR==1{print $3}')" >> $GITHUB_OUTPUT
Tim Duesterhus288c0772020-07-28 23:00:35 +0200145 - name: Install problem matcher for VTest
146 # This allows one to more easily see which tests fail.
147 run: echo "::add-matcher::.github/vtest.json"
148 - name: Run VTest for HAProxy ${{ steps.show-version.outputs.version }}
149 id: vtest
150 # sudo is required, because macOS fails due to an open files limit.
151 run: sudo make reg-tests REGTESTS_TYPES=default,bug,devel
152 - name: Show results
153 if: ${{ failure() }}
154 # The chmod / sudo is necessary due to the `sudo` while running the tests.
155 run: |
156 sudo chmod a+rX ${TMPDIR}/haregtests-*/
157 for folder in ${TMPDIR}/haregtests-*/vtc.*; do
158 printf "::group::"
159 cat $folder/INFO
160 cat $folder/LOG
161 echo "::endgroup::"
162 done
163 shopt -s nullglob
164 for asan in asan.log*; do
165 echo "::group::$asan"
166 sudo cat $asan
167 echo "::endgroup::"
168 done