summaryrefslogtreecommitdiffstats
path: root/.github/workflows/vtest.yml
blob: 7b5254b04bf11c1e4ecfd2eb4e9bf9e82d668306 (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
# Copyright 2019 Ilya Shipitsin <chipitsine@gmail.com>
# Copyright 2020 Tim Duesterhus <tim@bastelstu.be>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version
# 2 of the License, or (at your option) any later version.

name: VTest

on:
  push:

permissions:
  contents: read

jobs:
  # The generate-matrix job generates the build matrix using JSON output
  # generated by .github/matrix.py.
  generate-matrix:
    name: Generate Build Matrix
    runs-on: ubuntu-latest
    outputs:
      matrix: ${{ steps.set-matrix.outputs.matrix }}
    steps:
      - uses: actions/checkout@v4
      - name: Generate Build Matrix
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        id: set-matrix
        run: python3 .github/matrix.py "${{ github.ref_name }}"

  # The Test job actually runs the tests.
  Test:
    name: ${{ matrix.name }}
    needs: generate-matrix
    runs-on: ${{ matrix.os }}
    strategy:
      matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
      fail-fast: false
    env:
      # Configure a short TMPDIR to prevent failures due to long unix socket
      # paths.
      TMPDIR: /tmp
      # Force ASAN output into asan.log to make the output more readable.
      ASAN_OPTIONS: log_path=asan.log
      OT_CPP_VERSION: 1.6.0
    steps:
    - uses: actions/checkout@v4
      with:
        fetch-depth: 100
#
# Github Action cache key cannot contain comma, so we calculate it based on job name
#
    - name: Generate cache key
      id: generate-cache-key
      run: |
        echo "key=$(echo ${{ matrix.name }} | sha256sum | awk '{print $1}')" >> $GITHUB_OUTPUT

    - name: Cache SSL libs
      if: ${{ matrix.ssl && matrix.ssl != 'stock' && matrix.ssl != 'BORINGSSL=yes' && matrix.ssl != 'QUICTLS=yes' }}
      id: cache_ssl
      uses: actions/cache@v4
      with:
        path: '~/opt/'
        key: ssl-${{ steps.generate-cache-key.outputs.key }}

    - name: Cache OpenTracing
      if: ${{ contains(matrix.FLAGS, 'USE_OT=1') }}
      id: cache_ot
      uses: actions/cache@v4
      with:
        path: '~/opt-ot/'
        key: ot-${{ matrix.CC }}-${{ env.OT_CPP_VERSION }}-${{ contains(matrix.name, 'ASAN') }}
    - name: Install apt dependencies
      if: ${{ startsWith(matrix.os, 'ubuntu-') }}
      run: |
        sudo apt-get update
        sudo apt-get install -y \
          liblua5.3-dev \
          libpcre2-dev \
          libsystemd-dev \
          ninja-build \
          socat
    - name: Install brew dependencies
      if: ${{ startsWith(matrix.os, 'macos-') }}
      run: |
        brew install socat
        brew install lua
    - name: Install VTest
      run: |
        scripts/build-vtest.sh
    - name: Install SSL ${{ matrix.ssl }}
      if: ${{ matrix.ssl && matrix.ssl != 'stock' && steps.cache_ssl.outputs.cache-hit != 'true' }}
      run: env ${{ matrix.ssl }} scripts/build-ssl.sh
    - name: Install OpenTracing libs
      if: ${{ contains(matrix.FLAGS, 'USE_OT=1') && steps.cache_ot.outputs.cache-hit != 'true'  }}
      run: |
        OT_PREFIX=${HOME}/opt-ot scripts/build-ot.sh
    - name: Build WURFL
      if: ${{ contains(matrix.FLAGS, 'USE_WURFL=1') }}
      run: make -C addons/wurfl/dummy
    - name: Compile HAProxy with ${{ matrix.CC }}
      run: |
        echo "::group::Show compiler's version"
        echo | ${{ matrix.CC }} -v
        echo "::endgroup::"
        echo "::group::Show platform specific defines"
        echo | ${{ matrix.CC }} -dM -xc -E -
        echo "::endgroup::"
        make -j$(nproc) all \
          ERR=1 \
          TARGET=${{ matrix.TARGET }} \
          CC=${{ matrix.CC }} \
          DEBUG="-DDEBUG_STRICT -DDEBUG_MEMORY_POOLS -DDEBUG_POOL_INTEGRITY" \
          ${{ join(matrix.FLAGS, ' ') }} \
          ADDLIB="-Wl,-rpath,/usr/local/lib/ -Wl,-rpath,$HOME/opt/lib/"
        sudo make install
    - name: Show HAProxy version
      id: show-version
      run: |
        echo "::group::Show dynamic libraries."
        if command -v ldd > /dev/null; then
          # Linux
          ldd $(which haproxy)
        else
          # macOS
          otool -L $(which haproxy)
        fi
        echo "::endgroup::"
        haproxy -vv
        echo "version=$(haproxy -v |awk 'NR==1{print $3}')" >> $GITHUB_OUTPUT
    - name: Install problem matcher for VTest
      # This allows one to more easily see which tests fail.
      run: echo "::add-matcher::.github/vtest.json"
    - name: Run VTest for HAProxy ${{ steps.show-version.outputs.version }}
      id: vtest
      run: |
        # This is required for macOS which does not actually allow to increase
        # the '-n' soft limit to the hard limit, thus failing to run.
        ulimit -n 65536
        make reg-tests VTEST_PROGRAM=../vtest/vtest REGTESTS_TYPES=default,bug,devel
    - name: Config syntax check memleak smoke testing
      if: ${{ contains(matrix.name, 'ASAN') }}
      run: |
        ./haproxy -f .github/h2spec.config -c
    - name: Show VTest results
      if: ${{ failure() && steps.vtest.outcome == 'failure' }}
      run: |
        for folder in ${TMPDIR}/haregtests-*/vtc.*; do
          printf "::group::"
          cat $folder/INFO
          cat $folder/LOG
          echo "::endgroup::"
        done
        shopt -s nullglob
        for asan in asan.log*; do
          echo "::group::$asan"
          cat $asan
          echo "::endgroup::"
        done
        exit 1