ci: add vmtest as a reusable workflow

Signed-off-by: Ihor Solodrai <ihor.solodrai@pm.me>
This commit is contained in:
Ihor Solodrai
2024-11-14 11:02:24 -08:00
committed by Andrii Nakryiko
parent dcf6ad6c70
commit e0687f9f54
5 changed files with 159 additions and 25 deletions

View File

@@ -1,19 +1,17 @@
name: libbpf-ci
on:
on:
pull_request:
push:
schedule:
- cron: '0 18 * * *'
concurrency:
concurrency:
group: ci-test-${{ github.head_ref }}
cancel-in-progress: true
jobs:
vmtest:
runs-on: ${{ matrix.runs_on }}
name: Kernel ${{ matrix.kernel }} on ${{ matrix.arch }} + selftests
strategy:
fail-fast: false
matrix:
@@ -21,15 +19,13 @@ jobs:
- kernel: 'LATEST'
runs_on: ubuntu-24.04
arch: 'x86_64'
steps:
- uses: actions/checkout@v4
name: Checkout
- uses: ./.github/actions/setup
name: Setup
- uses: ./.github/actions/vmtest
name: vmtest
continue-on-error: false
timeout-minutes: 180
with:
kernel: ${{ matrix.kernel }}
arch: ${{ matrix.arch }}
llvm-version: '17'
pahole: 'master'
name: ${{ matrix.kernel }} kernel llvm-${{ matrix.llvm-version }} pahole@${{ matrix.pahole }}
uses: ./.github/workflows/vmtest.yml
with:
runs_on: ${{ matrix.runs_on }}
kernel: ${{ matrix.kernel }}
arch: ${{ matrix.arch }}
llvm-version: ${{ matrix.llvm-version }}
pahole: ${{ matrix.pahole }}

134
.github/workflows/vmtest.yml vendored Normal file
View 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 }}