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