Skip to content

Commit 9cf59e7

Browse files
author
Nobody
committed
adding ci files
1 parent 8940e6b commit 9cf59e7

13 files changed

+3773
-18
lines changed

.github/actions/vmtest/action.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: 'vmtest'
2+
description: 'Build + run vmtest'
3+
runs:
4+
using: "composite"
5+
steps:
6+
# 1. Setup environment
7+
- name: Setup build environment
8+
uses: libbpf/ci/setup-build-env@master
9+
# 2. Build
10+
- name: Build kernel image
11+
shell: bash
12+
run: ${GITHUB_ACTION_PATH}/build.sh
13+
- name: Build selftests
14+
shell: bash
15+
run: ${GITHUB_ACTION_PATH}/build_selftests.sh
16+
env:
17+
VMLINUX_BTF: ${{ github.workspace }}/vmlinux
18+
# 3. Test
19+
- name: Prepare rootfs
20+
uses: libbpf/ci/prepare-rootfs@master
21+
with:
22+
project-name: 'libbpf'
23+
arch: 'x86_64'
24+
kernel-root: '.'
25+
- name: Run selftests
26+
uses: libbpf/ci/run-qemu@master
27+
with:
28+
arch: 'x86_64'
29+
img: '/tmp/root.img'
30+
vmlinuz: '${{ github.workspace }}/vmlinuz'

.github/actions/vmtest/build.sh

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
THISDIR="$(cd $(dirname $0) && pwd)"
6+
7+
source "${THISDIR}"/helpers.sh
8+
9+
travis_fold start build_kernel "Building kernel"
10+
11+
cp "${GITHUB_ACTION_PATH}"/latest.config .config
12+
make -j $((4*$(nproc))) olddefconfig all > /dev/null
13+
14+
travis_fold end build_kernel
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
THISDIR="$(cd $(dirname $0) && pwd)"
6+
7+
source "${THISDIR}"/helpers.sh
8+
9+
travis_fold start prepare_selftests "Building selftests"
10+
11+
LLVM_VER=15
12+
LIBBPF_PATH="${REPO_ROOT}"
13+
14+
PREPARE_SELFTESTS_SCRIPT=${THISDIR}/prepare_selftests-${KERNEL}.sh
15+
if [ -f "${PREPARE_SELFTESTS_SCRIPT}" ]; then
16+
(cd "${REPO_ROOT}/${REPO_PATH}/tools/testing/selftests/bpf" && ${PREPARE_SELFTESTS_SCRIPT})
17+
fi
18+
19+
if [[ "${KERNEL}" = 'LATEST' ]]; then
20+
VMLINUX_H=
21+
else
22+
VMLINUX_H=${THISDIR}/vmlinux.h
23+
fi
24+
25+
cd ${REPO_ROOT}/${REPO_PATH}
26+
make \
27+
CLANG=clang-${LLVM_VER} \
28+
LLC=llc-${LLVM_VER} \
29+
LLVM_STRIP=llvm-strip-${LLVM_VER} \
30+
VMLINUX_BTF="${VMLINUX_BTF}" \
31+
VMLINUX_H="${VMLINUX_H}" \
32+
-C "${REPO_ROOT}/${REPO_PATH}/tools/testing/selftests/bpf" \
33+
-j $((4*$(nproc))) > /dev/null
34+
cd -
35+
mkdir "${LIBBPF_PATH}"/selftests
36+
cp -R "${REPO_ROOT}/${REPO_PATH}/tools/testing/selftests/bpf" \
37+
"${LIBBPF_PATH}"/selftests
38+
cd "${LIBBPF_PATH}"
39+
rm selftests/bpf/.gitignore
40+
git add selftests
41+
42+
travis_fold end prepare_selftests

.github/actions/vmtest/helpers.sh

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# $1 - start or end
2+
# $2 - fold identifier, no spaces
3+
# $3 - fold section description
4+
travis_fold() {
5+
local YELLOW='\033[1;33m'
6+
local NOCOLOR='\033[0m'
7+
if [ -z ${GITHUB_WORKFLOW+x} ]; then
8+
echo travis_fold:$1:$2
9+
if [ ! -z "${3:-}" ]; then
10+
echo -e "${YELLOW}$3${NOCOLOR}"
11+
fi
12+
echo
13+
else
14+
if [ $1 = "start" ]; then
15+
line="::group::$2"
16+
if [ ! -z "${3:-}" ]; then
17+
line="$line - ${YELLOW}$3${NOCOLOR}"
18+
fi
19+
else
20+
line="::endgroup::"
21+
fi
22+
echo -e "$line"
23+
fi
24+
}
25+
26+
__print() {
27+
local TITLE=""
28+
if [[ -n $2 ]]; then
29+
TITLE=" title=$2"
30+
fi
31+
echo "::$1${TITLE}::$3"
32+
}
33+
34+
# $1 - title
35+
# $2 - message
36+
print_error() {
37+
__print error $1 $2
38+
}
39+
40+
# $1 - title
41+
# $2 - message
42+
print_notice() {
43+
__print notice $1 $2
44+
}

0 commit comments

Comments
 (0)