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