xref: /dpdk/.github/workflows/build.yml (revision b14e8a57)
1name: build
2
3on:
4  push:
5  schedule:
6    - cron: '0 0 * * 1'
7
8defaults:
9  run:
10    shell: bash --noprofile --norc -exo pipefail {0}
11
12jobs:
13  ubuntu-vm-builds:
14    name: ${{ join(matrix.config.*, '-') }}
15    runs-on: ${{ matrix.config.os }}
16    env:
17      AARCH64: ${{ matrix.config.cross == 'aarch64' }}
18      ABI_CHECKS: ${{ contains(matrix.config.checks, 'abi') }}
19      BUILD_32BIT: ${{ matrix.config.cross == 'i386' }}
20      BUILD_DOCS: ${{ contains(matrix.config.checks, 'doc') }}
21      CC: ccache ${{ matrix.config.compiler }}
22      DEF_LIB: ${{ matrix.config.library }}
23      LIBABIGAIL_VERSION: libabigail-1.8
24      MINI: ${{ matrix.config.mini != '' }}
25      PPC64LE: ${{ matrix.config.cross == 'ppc64le' }}
26      REF_GIT_TAG: v22.03
27      RUN_TESTS: ${{ contains(matrix.config.checks, 'tests') }}
28
29    strategy:
30      fail-fast: false
31      matrix:
32        config:
33          - os: ubuntu-18.04
34            compiler: gcc
35            library: static
36          - os: ubuntu-18.04
37            compiler: gcc
38            library: shared
39            mini: mini
40          - os: ubuntu-18.04
41            compiler: gcc
42            library: shared
43            checks: abi+doc+tests
44          - os: ubuntu-18.04
45            compiler: clang
46            library: static
47          - os: ubuntu-18.04
48            compiler: clang
49            library: shared
50            checks: doc+tests
51          - os: ubuntu-18.04
52            compiler: gcc
53            library: static
54            cross: i386
55          # Note: common/cnxk is disabled for Ubuntu 18.04
56          # https://bugs.dpdk.org/show_bug.cgi?id=697
57          - os: ubuntu-18.04
58            compiler: gcc
59            library: static
60            cross: aarch64
61          - os: ubuntu-18.04
62            compiler: gcc
63            library: shared
64            cross: aarch64
65          - os: ubuntu-18.04
66            compiler: gcc
67            library: static
68            cross: ppc64le
69          - os: ubuntu-18.04
70            compiler: gcc
71            library: shared
72            cross: ppc64le
73
74    steps:
75    - name: Checkout sources
76      uses: actions/checkout@v2
77    - name: Generate cache keys
78      id: get_ref_keys
79      run: |
80        echo -n '::set-output name=ccache::'
81        echo 'ccache-${{ matrix.config.os }}-${{ matrix.config.compiler }}-${{ matrix.config.cross }}-'$(date -u +%Y-w%W)
82        echo -n '::set-output name=libabigail::'
83        echo 'libabigail-${{ matrix.config.os }}'
84        echo -n '::set-output name=abi::'
85        echo 'abi-${{ matrix.config.os }}-${{ matrix.config.compiler }}-${{ matrix.config.cross }}-${{ env.LIBABIGAIL_VERSION }}-${{ env.REF_GIT_TAG }}'
86    - name: Retrieve ccache cache
87      uses: actions/cache@v2
88      with:
89        path: ~/.ccache
90        key: ${{ steps.get_ref_keys.outputs.ccache }}-${{ github.ref }}
91        restore-keys: |
92          ${{ steps.get_ref_keys.outputs.ccache }}-refs/heads/main
93    - name: Retrieve libabigail cache
94      id: libabigail-cache
95      uses: actions/cache@v2
96      if: env.ABI_CHECKS == 'true'
97      with:
98        path: libabigail
99        key: ${{ steps.get_ref_keys.outputs.libabigail }}
100    - name: Retrieve ABI reference cache
101      uses: actions/cache@v2
102      if: env.ABI_CHECKS == 'true'
103      with:
104        path: reference
105        key: ${{ steps.get_ref_keys.outputs.abi }}
106    - name: Update APT cache
107      run: sudo apt update || true
108    - name: Install packages
109      run: sudo apt install -y ccache libnuma-dev python3-setuptools
110        python3-wheel python3-pip python3-pyelftools ninja-build libbsd-dev
111        libpcap-dev libibverbs-dev libcrypto++-dev libfdt-dev libjansson-dev
112        libarchive-dev
113    - name: Install libabigail build dependencies if no cache is available
114      if: env.ABI_CHECKS == 'true' && steps.libabigail-cache.outputs.cache-hit != 'true'
115      run: sudo apt install -y autoconf automake libtool pkg-config libxml2-dev
116          libdw-dev
117    - name: Install i386 cross compiling packages
118      if: env.BUILD_32BIT == 'true'
119      run: sudo apt install -y gcc-multilib g++-multilib
120    - name: Install aarch64 cross compiling packages
121      if: env.AARCH64 == 'true'
122      run: sudo apt install -y gcc-aarch64-linux-gnu libc6-dev-arm64-cross
123        pkg-config-aarch64-linux-gnu
124    - name: Install ppc64le cross compiling packages
125      if: env.PPC64LE == 'true'
126      run: sudo apt install -y gcc-powerpc64le-linux-gnu libc6-dev-ppc64el-cross
127        pkg-config-powerpc-linux-gnu
128    - name: Install test tools packages
129      if: env.AARCH64 != 'true' || env.PPC64LE != 'true' || env.RUN_TESTS == 'true'
130      run: sudo apt install -y gdb
131    - name: Install doc generation packages
132      if: env.BUILD_DOCS == 'true'
133      run: sudo apt install -y doxygen graphviz python3-sphinx
134        python3-sphinx-rtd-theme
135    - name: Run setup
136      run: |
137        .ci/linux-setup.sh
138        # Workaround on $HOME permissions as EAL checks them for plugin loading
139        chmod o-w $HOME
140    - name: Build and test
141      run: .ci/linux-build.sh
142    - name: Upload logs on failure
143      if: failure()
144      uses: actions/upload-artifact@v2
145      with:
146        name: meson-logs-${{ join(matrix.config.*, '-') }}
147        path: |
148          build/.ninja_log
149          build/gdb.log
150          build/meson-logs/meson-log.txt
151          build/meson-logs/testlog.txt
152
153  prepare-container-images:
154    name: ${{ join(matrix.config.*, '-') }}
155    runs-on: ubuntu-latest
156
157    strategy:
158      fail-fast: false
159      matrix:
160        config:
161          - image: fedora:35
162
163    steps:
164    - name: Generate various keys
165      id: get_keys
166      run: |
167        echo -n '::set-output name=image::'
168        echo 'image-${{ matrix.config.image }}-'$(date -u +%Y-%m-%d)
169    - name: Retrieve image cache
170      id: image_cache
171      uses: actions/cache@v2
172      with:
173        path: ~/.image
174        key: ${{ steps.get_keys.outputs.image }}
175    - name: Pull and prepare a fresh image
176      if: steps.image_cache.outputs.cache-hit != 'true'
177      run: |
178        docker pull registry.fedoraproject.org/${{ matrix.config.image }}
179        docker run -d -i --rm --name dpdk \
180          registry.fedoraproject.org/${{ matrix.config.image }} \
181          bash -li
182    - name: Update
183      if: steps.image_cache.outputs.cache-hit != 'true'
184      run: docker exec -i dpdk dnf update -y
185    - name: Install packages
186      if: steps.image_cache.outputs.cache-hit != 'true'
187      run: docker exec -i dpdk dnf install -y ccache numactl-devel
188        python3-setuptools python3-wheel python3-pip python3-pyelftools
189        ninja-build libatomic libbpf-devel libfdt-devel libpcap-devel
190        openssl-devel rdma-core-devel zlib-devel
191    - name: Save image in cache
192      if: steps.image_cache.outputs.cache-hit != 'true'
193      run: |
194        docker commit dpdk dpdk-local
195        mkdir -p ~/.image
196        docker save -o ~/.image/${{ matrix.config.image }}.tar dpdk-local
197    - name: Stop image
198      if: steps.image_cache.outputs.cache-hit != 'true'
199      run: docker kill dpdk
200
201  rpm-container-builds:
202    needs: prepare-container-images
203    name: ${{ join(matrix.config.*, '-') }}
204    runs-on: ubuntu-latest
205
206    strategy:
207      fail-fast: false
208      matrix:
209        config:
210          - image: fedora:35
211            compiler: gcc
212            library: static
213          - image: fedora:35
214            compiler: gcc
215            library: shared
216          - image: fedora:35
217            compiler: clang
218            library: static
219          - image: fedora:35
220            compiler: clang
221            library: shared
222
223    steps:
224    - name: Checkout sources
225      uses: actions/checkout@v2
226    - name: Generate various keys
227      id: get_keys
228      run: |
229        echo -n '::set-output name=ccache::'
230        echo 'ccache-${{ matrix.config.image }}-${{ matrix.config.compiler }}-'$(date -u +%Y-w%W)
231        echo -n '::set-output name=image::'
232        echo 'image-${{ matrix.config.image }}-'$(date -u +%Y-%m-%d)
233        echo -n '::set-output name=logs::'
234        echo 'meson-logs-${{ join(matrix.config.*, '-') }}' | tr -d ':'
235    - name: Retrieve image cache
236      id: image_cache
237      uses: actions/cache@v2
238      with:
239        path: ~/.image
240        key: ${{ steps.get_keys.outputs.image }}
241    - name: Fail if no image (not supposed to happen)
242      if: steps.image_cache.outputs.cache-hit != 'true'
243      run: |
244        echo 'Image ${{ matrix.config.image }} is not cached.'
245        false
246    - name: Retrieve ccache cache
247      uses: actions/cache@v2
248      with:
249        path: ~/.ccache
250        key: ${{ steps.get_keys.outputs.ccache }}-${{ github.ref }}
251        restore-keys: |
252          ${{ steps.get_keys.outputs.ccache }}-refs/heads/main
253    - name: Prepare working directory
254      run: |
255        mkdir -p ~/.ccache
256        > ~/env
257        echo CC=ccache ${{ matrix.config.compiler }} >> ~/env
258        echo DEF_LIB=${{ matrix.config.library }} >> ~/env
259    - name: Load the cached image
260      run: |
261        docker load -i ~/.image/${{ matrix.config.image }}.tar
262        docker run -d -i --rm --name dpdk \
263          --mount type=bind,src=$HOME/.ccache,dst=/root/.ccache \
264          --mount type=bind,src=$(pwd),dst=/root/dpdk \
265          --env-file ~/env \
266          -w /root/dpdk \
267          dpdk-local
268          bash -li
269    - name: Update
270      run: docker exec -i dpdk dnf update -y || true
271    - name: Install packages
272      run: docker exec -i dpdk dnf install -y ccache numactl-devel
273        python3-setuptools python3-wheel python3-pip python3-pyelftools
274        ninja-build libatomic libbpf-devel libfdt-devel libpcap-devel
275        openssl-devel rdma-core-devel zlib-devel ${{ matrix.config.compiler }}
276    - name: Run setup
277      run: docker exec -i dpdk .ci/linux-setup.sh
278    - name: Build
279      run: docker exec -i dpdk .ci/linux-build.sh
280    - name: Stop image
281      run: docker kill dpdk
282    - name: Upload logs on failure
283      if: failure()
284      uses: actions/upload-artifact@v2
285      with:
286        name: ${{ steps.get_keys.outputs.logs }}
287        path: |
288          build/.ninja_log
289          build/meson-logs/meson-log.txt
290