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