mirror of
https://github.com/netdata/libbpf.git
synced 2026-04-05 16:19:06 +08:00
ci: add vmtest as a reusable workflow
Signed-off-by: Ihor Solodrai <ihor.solodrai@pm.me>
This commit is contained in:
committed by
Andrii Nakryiko
parent
dcf6ad6c70
commit
e0687f9f54
28
.github/workflows/test.yml
vendored
28
.github/workflows/test.yml
vendored
@@ -1,19 +1,17 @@
|
|||||||
name: libbpf-ci
|
name: libbpf-ci
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
push:
|
push:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '0 18 * * *'
|
- cron: '0 18 * * *'
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ci-test-${{ github.head_ref }}
|
group: ci-test-${{ github.head_ref }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
vmtest:
|
vmtest:
|
||||||
runs-on: ${{ matrix.runs_on }}
|
|
||||||
name: Kernel ${{ matrix.kernel }} on ${{ matrix.arch }} + selftests
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -21,15 +19,13 @@ jobs:
|
|||||||
- kernel: 'LATEST'
|
- kernel: 'LATEST'
|
||||||
runs_on: ubuntu-24.04
|
runs_on: ubuntu-24.04
|
||||||
arch: 'x86_64'
|
arch: 'x86_64'
|
||||||
steps:
|
llvm-version: '17'
|
||||||
- uses: actions/checkout@v4
|
pahole: 'master'
|
||||||
name: Checkout
|
name: ${{ matrix.kernel }} kernel llvm-${{ matrix.llvm-version }} pahole@${{ matrix.pahole }}
|
||||||
- uses: ./.github/actions/setup
|
uses: ./.github/workflows/vmtest.yml
|
||||||
name: Setup
|
with:
|
||||||
- uses: ./.github/actions/vmtest
|
runs_on: ${{ matrix.runs_on }}
|
||||||
name: vmtest
|
kernel: ${{ matrix.kernel }}
|
||||||
continue-on-error: false
|
arch: ${{ matrix.arch }}
|
||||||
timeout-minutes: 180
|
llvm-version: ${{ matrix.llvm-version }}
|
||||||
with:
|
pahole: ${{ matrix.pahole }}
|
||||||
kernel: ${{ matrix.kernel }}
|
|
||||||
arch: ${{ matrix.arch }}
|
|
||||||
|
|||||||
134
.github/workflows/vmtest.yml
vendored
Normal file
134
.github/workflows/vmtest.yml
vendored
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
name: 'Build kernel and selftests/bpf, run selftests via vmtest'
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
runs_on:
|
||||||
|
required: true
|
||||||
|
default: 'ubuntu-24.04'
|
||||||
|
type: string
|
||||||
|
arch:
|
||||||
|
description: 'what arch to test'
|
||||||
|
required: true
|
||||||
|
default: 'x86_64'
|
||||||
|
type: string
|
||||||
|
kernel:
|
||||||
|
description: 'kernel version or LATEST'
|
||||||
|
required: true
|
||||||
|
default: 'LATEST'
|
||||||
|
type: string
|
||||||
|
pahole:
|
||||||
|
description: 'pahole rev or branch'
|
||||||
|
required: false
|
||||||
|
default: 'master'
|
||||||
|
type: string
|
||||||
|
llvm-version:
|
||||||
|
description: 'llvm version'
|
||||||
|
required: false
|
||||||
|
default: '17'
|
||||||
|
type: string
|
||||||
|
jobs:
|
||||||
|
vmtest:
|
||||||
|
runs-on: ${{ inputs.runs_on }}
|
||||||
|
steps:
|
||||||
|
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup environment
|
||||||
|
uses: theihor/libbpf-ci/setup-build-env@run-vmtest-v2
|
||||||
|
with:
|
||||||
|
pahole: ${{ inputs.pahole }}
|
||||||
|
arch: ${{ inputs.arch }}
|
||||||
|
llvm-version: ${{ inputs.llvm-version }}
|
||||||
|
|
||||||
|
- name: Get checkpoint commit
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
cat CHECKPOINT-COMMIT
|
||||||
|
echo "CHECKPOINT=$(cat CHECKPOINT-COMMIT)" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Get kernel source at checkpoint
|
||||||
|
uses: theihor/libbpf-ci/get-linux-source@run-vmtest-v2
|
||||||
|
with:
|
||||||
|
repo: 'https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git'
|
||||||
|
rev: ${{ env.CHECKPOINT }}
|
||||||
|
dest: '${{ github.workspace }}/.kernel'
|
||||||
|
|
||||||
|
- name: Patch kernel source
|
||||||
|
uses: theihor/libbpf-ci/patch-kernel@run-vmtest-v2
|
||||||
|
with:
|
||||||
|
patches-root: '${{ github.workspace }}/ci/diffs'
|
||||||
|
repo-root: '.kernel'
|
||||||
|
|
||||||
|
- name: Configure kernel build
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
cd .kernel
|
||||||
|
cat tools/testing/selftests/bpf/config \
|
||||||
|
tools/testing/selftests/bpf/config.${{ inputs.arch }} > .config
|
||||||
|
# this file might or mihgt not exist depending on kernel version
|
||||||
|
cat tools/testing/selftests/bpf/config.vm >> .config || :
|
||||||
|
make olddefconfig && make prepare
|
||||||
|
cd -
|
||||||
|
|
||||||
|
- name: Build kernel image
|
||||||
|
if: ${{ inputs.kernel == 'LATEST' }}
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
cd .kernel
|
||||||
|
make -j $((4*$(nproc))) all
|
||||||
|
cp vmlinux ${{ github.workspace }}
|
||||||
|
cd -
|
||||||
|
|
||||||
|
- name: Download prebuilt kernel
|
||||||
|
if: ${{ inputs.kernel != 'LATEST' }}
|
||||||
|
uses: theihor/libbpf-ci/download-vmlinux@run-vmtest-v2
|
||||||
|
with:
|
||||||
|
kernel: ${{ inputs.kernel }}
|
||||||
|
arch: ${{ inputs.arch }}
|
||||||
|
|
||||||
|
- name: Prepare to build selftests
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
PREPARE_SCRIPT: ${{ github.workspace }}/ci/vmtest/prepare-selftests-build-${{ inputs.kernel }}.sh
|
||||||
|
SELFTESTS_BPF: ${{ github.workspace }}/.kernel/tools/testing/selftests/bpf
|
||||||
|
run: |
|
||||||
|
if [ -f "${PREPARE_SCRIPT}" ]; then
|
||||||
|
bash "${PREPARE_SCRIPT}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Build selftests/bpf
|
||||||
|
uses: theihor/libbpf-ci/build-selftests@run-vmtest-v2
|
||||||
|
env:
|
||||||
|
MAX_MAKE_JOBS: 32
|
||||||
|
VMLINUX_BTF: ${{ github.workspace }}/vmlinux
|
||||||
|
VMLINUX_H: ${{ inputs.kernel != 'LATEST' && format('{0}/.github/actions/build-selftests/vmlinux.h', github.workspace) || '' }}
|
||||||
|
with:
|
||||||
|
arch: ${{ inputs.arch }}
|
||||||
|
kernel-root: ${{ github.workspace }}/.kernel
|
||||||
|
llvm-version: ${{ inputs.llvm-version }}
|
||||||
|
|
||||||
|
- name: Prepare to run selftests
|
||||||
|
env:
|
||||||
|
ALLOWLIST_FILE: /tmp/allowlist
|
||||||
|
DENYLIST_FILE: /tmp/denylist
|
||||||
|
ARCH: ${{ inputs.arch }}
|
||||||
|
KERNEL: ${{ inputs.kernel }}
|
||||||
|
SELFTESTS_BPF: ${{ github.workspace }}/.kernel/tools/testing/selftests/bpf
|
||||||
|
VMTEST_CONFIGS: ${{ github.workspace }}/ci/vmtest/configs
|
||||||
|
shell: bash
|
||||||
|
run: ${{ github.workspace }}/ci/vmtest/prepare-selftests-run.sh
|
||||||
|
|
||||||
|
- name: Run selftests
|
||||||
|
env:
|
||||||
|
ALLOWLIST_FILE: /tmp/allowlist
|
||||||
|
DENYLIST_FILE: /tmp/denylist
|
||||||
|
KERNEL: ${{ inputs.kernel }}
|
||||||
|
VMLINUX: ${{ github.workspace }}/vmlinux
|
||||||
|
uses: theihor/libbpf-ci/run-vmtest@run-vmtest-v2
|
||||||
|
with:
|
||||||
|
arch: ${{ inputs.arch }}
|
||||||
|
kbuild-output: ${{ github.workspace }}/.kernel
|
||||||
|
kernel-root: ${{ github.workspace }}/.kernel
|
||||||
|
kernel-test: ${{ env.KERNEL_TEST || '' }}
|
||||||
|
vmlinuz: ${{ inputs.arch }}/vmlinuz-${{ inputs.kernel }}
|
||||||
12
ci/vmtest/prepare-selftests-LATEST.sh
Executable file
12
ci/vmtest/prepare-selftests-LATEST.sh
Executable file
@@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# noop script: it's here as a reminder that we might need it for other kernel versions
|
||||||
|
|
||||||
|
# for 4.9.0 and 5.5.0 code was:
|
||||||
|
# cd "${SELFTESTS_BPF}"
|
||||||
|
# printf "all:\n\ttouch bpf_testmod.ko\n\nclean:\n" > bpf_testmod/Makefile
|
||||||
|
# printf "all:\n\ttouch bpf_test_no_cfi.ko\n\nclean:\n" > bpf_test_no_cfi/Makefile
|
||||||
|
|
||||||
|
exit 0
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
cd "${SELFTESTS_BPF}"
|
|
||||||
printf "all:\n\ttouch bpf_testmod.ko\n\nclean:\n" > bpf_testmod/Makefile
|
|
||||||
printf "all:\n\ttouch bpf_test_no_cfi.ko\n\nclean:\n" > bpf_test_no_cfi/Makefile
|
|
||||||
|
|
||||||
@@ -36,6 +36,6 @@ if [[ "${KERNEL}" == "5.5.0" ]]; then
|
|||||||
echo "KERNEL_TEST=test_progs test_progs_no_alu32" >> $GITHUB_ENV
|
echo "KERNEL_TEST=test_progs test_progs_no_alu32" >> $GITHUB_ENV
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir "${GITHUB_WORKSPACE}/selftests"
|
mkdir -p "${GITHUB_WORKSPACE}/selftests"
|
||||||
cp -R "${SELFTESTS_BPF}" "${GITHUB_WORKSPACE}/selftests"
|
cp -R "${SELFTESTS_BPF}" "${GITHUB_WORKSPACE}/selftests"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user