|
| 1 | +name: bpf-ci |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + |
| 6 | +concurrency: |
| 7 | + group: ci-test-${{ github.head_ref }} |
| 8 | + cancel-in-progress: true |
| 9 | + |
| 10 | +jobs: |
| 11 | + llvm-toolchain: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + outputs: |
| 14 | + llvm: ${{ steps.llvm-toolchain-impl.outputs.version }} |
| 15 | + steps: |
| 16 | + - id: llvm-version |
| 17 | + uses: libbpf/ci/get-llvm-version@master |
| 18 | + - id: llvm-toolchain-impl |
| 19 | + shell: bash |
| 20 | + run: echo "::set-output name=version::llvm-${{ steps.llvm-version.outputs.version }}" |
| 21 | + set-matrix: |
| 22 | + needs: llvm-toolchain |
| 23 | + runs-on: ubuntu-latest |
| 24 | + outputs: |
| 25 | + build-matrix: ${{ steps.set-matrix-impl.outputs.build_matrix }} |
| 26 | + test-matrix: ${{ steps.set-matrix-impl.outputs.test_matrix }} |
| 27 | + steps: |
| 28 | + - id: set-matrix-impl |
| 29 | + shell: python3 -I {0} |
| 30 | + run: | |
| 31 | + from json import dumps |
| 32 | +
|
| 33 | + matrix = [ |
| 34 | + {"kernel": "LATEST", "runs_on": ["ubuntu-latest", "self-hosted"], "arch": "x86_64", "toolchain": "gcc"}, |
| 35 | + {"kernel": "LATEST", "runs_on": ["ubuntu-latest", "self-hosted"], "arch": "x86_64", "toolchain": "${{ needs.llvm-toolchain.outputs.llvm }}"}, |
| 36 | + {"kernel": "LATEST", "runs_on": ["z15", "self-hosted"], "arch": "s390x", "toolchain": "gcc"}, |
| 37 | + ] |
| 38 | +
|
| 39 | + if "${{ github.repository_owner }}" != "kernel-patches": |
| 40 | + # Outside of kernel-patches, remove the self-hosted label and skip |
| 41 | + # any testing on s390x, as no suitable runners will be available. |
| 42 | + for idx in range(len(matrix) - 1, -1, -1): |
| 43 | + if "z15" in matrix[idx]["runs_on"]: |
| 44 | + del matrix[idx] |
| 45 | + else: |
| 46 | + matrix[idx]["runs_on"].remove("self-hosted") |
| 47 | +
|
| 48 | + build_matrix = {"include": matrix} |
| 49 | + print(f"::set-output name=build_matrix::{dumps(build_matrix)}") |
| 50 | +
|
| 51 | + tests = ["test_progs", "test_progs_no_alu32", "test_maps", "test_verifier"] |
| 52 | + test_matrix = {"include": [{**config, **{"test": test}} |
| 53 | + for config in matrix |
| 54 | + for test in tests]} |
| 55 | + print(f"::set-output name=test_matrix::{dumps(test_matrix)}") |
| 56 | + build: |
| 57 | + name: build for ${{ matrix.arch }} with ${{ matrix.toolchain }} |
| 58 | + needs: set-matrix |
| 59 | + runs-on: ${{ matrix.runs_on }} |
| 60 | + timeout-minutes: 100 |
| 61 | + strategy: |
| 62 | + fail-fast: false |
| 63 | + matrix: ${{ fromJSON(needs.set-matrix.outputs.build-matrix) }} |
| 64 | + env: |
| 65 | + KERNEL: ${{ matrix.kernel }} |
| 66 | + REPO_ROOT: ${{ github.workspace }} |
| 67 | + REPO_PATH: "" |
| 68 | + steps: |
| 69 | + - uses: actions/checkout@v2 |
| 70 | + - if: ${{ github.repository == 'kernel-patches/vmtest' }} |
| 71 | + name: Download bpf-next tree |
| 72 | + uses: libbpf/ci/get-linux-source@master |
| 73 | + with: |
| 74 | + dest: '.kernel' |
| 75 | + - if: ${{ github.repository == 'kernel-patches/vmtest' }} |
| 76 | + name: Move linux source in place |
| 77 | + shell: bash |
| 78 | + run: | |
| 79 | + rm -rf .kernel/.git |
| 80 | + cp -rf .kernel/. . |
| 81 | + rm -rf .kernel |
| 82 | + - uses: libbpf/ci/patch-kernel@master |
| 83 | + with: |
| 84 | + patches-root: '${{ github.workspace }}/travis-ci/diffs' |
| 85 | + repo-root: '${{ github.workspace }}' |
| 86 | + - name: Setup build environment |
| 87 | + uses: libbpf/ci/setup-build-env@master |
| 88 | + - name: Build kernel image |
| 89 | + uses: libbpf/ci/build-linux@master |
| 90 | + with: |
| 91 | + arch: ${{ matrix.arch }} |
| 92 | + toolchain: ${{ matrix.toolchain }} |
| 93 | + - name: Build selftests |
| 94 | + uses: libbpf/ci/build-selftests@master |
| 95 | + with: |
| 96 | + vmlinux_btf: ${{ github.workspace }}/vmlinux |
| 97 | + toolchain: ${{ matrix.toolchain }} |
| 98 | + - name: Build samples |
| 99 | + uses: libbpf/ci/build-samples@master |
| 100 | + with: |
| 101 | + vmlinux_btf: ${{ github.workspace }}/vmlinux |
| 102 | + toolchain: ${{ matrix.toolchain }} |
| 103 | + - name: Tar artifacts |
| 104 | + run: | |
| 105 | + file_list="" |
| 106 | + if [ "${{ github.repository }}" == "kernel-patches/vmtest" ]; then |
| 107 | + # Package up a bunch of additional infrastructure to support running |
| 108 | + # 'make kernelrelease' and bpf tool checks later on. |
| 109 | + file_list="$(find . -iname Makefile | xargs) \ |
| 110 | + scripts/ \ |
| 111 | + tools/testing/selftests/bpf/ \ |
| 112 | + tools/include/ \ |
| 113 | + tools/bpf/bpftool/"; |
| 114 | + fi |
| 115 | +
|
| 116 | + tar -czf vmlinux-${{ matrix.arch }}-${{ matrix.toolchain }}.tar.gz \ |
| 117 | + .config \ |
| 118 | + arch/*/boot/bzImage \ |
| 119 | + include/config/auto.conf \ |
| 120 | + include/generated/autoconf.h \ |
| 121 | + ${file_list} \ |
| 122 | + --exclude '*.h' \ |
| 123 | + selftests/bpf/ \ |
| 124 | + vmlinux |
| 125 | + - uses: actions/upload-artifact@v3 |
| 126 | + with: |
| 127 | + name: vmlinux-${{ matrix.arch }}-${{ matrix.toolchain }} |
| 128 | + if-no-files-found: error |
| 129 | + path: vmlinux-${{ matrix.arch }}-${{ matrix.toolchain }}.tar.gz |
| 130 | + test: |
| 131 | + name: ${{ matrix.test }} on ${{ matrix.arch }} with ${{ matrix.toolchain }} |
| 132 | + needs: [set-matrix, build] |
| 133 | + strategy: |
| 134 | + fail-fast: false |
| 135 | + matrix: ${{ fromJSON(needs.set-matrix.outputs.test-matrix) }} |
| 136 | + runs-on: ${{ matrix.runs_on }} |
| 137 | + timeout-minutes: 100 |
| 138 | + env: |
| 139 | + KERNEL: ${{ matrix.kernel }} |
| 140 | + REPO_ROOT: ${{ github.workspace }} |
| 141 | + REPO_PATH: "" |
| 142 | + steps: |
| 143 | + - uses: actions/checkout@main |
| 144 | + - uses: actions/download-artifact@v3 |
| 145 | + with: |
| 146 | + name: vmlinux-${{ matrix.arch }}-${{ matrix.toolchain }} |
| 147 | + path: . |
| 148 | + - name: Untar artifacts |
| 149 | + run: tar -xzf vmlinux-${{ matrix.arch }}-${{ matrix.toolchain }}.tar.gz |
| 150 | + - name: Prepare rootfs |
| 151 | + uses: libbpf/ci/prepare-rootfs@master |
| 152 | + with: |
| 153 | + project-name: 'libbpf' |
| 154 | + arch: ${{ matrix.arch }} |
| 155 | + kernel: ${{ matrix.kernel }} |
| 156 | + kernel-root: '.' |
| 157 | + image-output: '/tmp/root.img' |
| 158 | + test: ${{ matrix.test }} |
| 159 | + - name: Run selftests |
| 160 | + uses: libbpf/ci/run-qemu@master |
| 161 | + with: |
| 162 | + arch: ${{ matrix.arch}} |
| 163 | + img: '/tmp/root.img' |
| 164 | + vmlinuz: '${{ github.workspace }}/vmlinuz' |
| 165 | + kernel-root: '.' |
0 commit comments