Skip to content

Commit 22694d5

Browse files
committed
Add GitHub CI and fix test runner bugs
1 parent 606924e commit 22694d5

File tree

6 files changed

+88
-9
lines changed

6 files changed

+88
-9
lines changed

.github/workflows/ci.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: ci
2+
on:
3+
push:
4+
branches: [ "main" ]
5+
pull_request:
6+
branches: [ "main" ]
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
build:
14+
name: Build
15+
runs-on: ubuntu-22.04
16+
timeout-minutes: 10
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Setup Java 21
21+
uses: actions/setup-java@v4
22+
with:
23+
java-version: '21'
24+
distribution: 'adopt'
25+
26+
- name: mvn package
27+
run: mvn package -DskipTests
28+
29+
- name: upload bcc/target/bcc.jar
30+
uses: actions/upload-artifact@v4
31+
with:
32+
name: bcc.jar
33+
path: bcc/target/bcc.jar
34+
35+
vm-test:
36+
name: Run tests on pre-built kernel
37+
runs-on: ubuntu-22.04
38+
needs: build
39+
timeout-minutes: 10
40+
strategy:
41+
matrix:
42+
version: ["6.6"]
43+
env:
44+
HBT_KERNEL_VERSION: "${{ matrix.version }}"
45+
steps:
46+
- uses: actions/checkout@v4
47+
48+
- name: Set up Java
49+
uses: actions/setup-java@v4
50+
with:
51+
java-version: '21'
52+
distribution: 'adopt'
53+
54+
- run: sudo pip3 install https://github.com/amluto/virtme/archive/beb85146cd91de37ae455eccb6ab67c393e6e290.zip
55+
- run: |
56+
sudo apt-get update && sudo apt-get install -y --no-install-recommends qemu-system-x86 bpfcc-tools linux-headers-$(uname -r)
57+
58+
- name: Find libbcc.so
59+
run: |
60+
ls /lib*/**/libbcc.so
61+
- name: Test
62+
run: mvn test -Djvm=testutil/bin/java
63+
64+
- name: Publish Test Report
65+
uses: mikepenz/action-junit-report@v4
66+
if: always()
67+
with:
68+
check_name: 'Test Report (Kernel ${{ matrix.KERNEL_VERSION }})'
69+
report_paths: '**/build/test-results/test/TEST-*.xml'

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Hello eBPF
22
==========
33

4+
[![ci](https://github.com/parttimenerd/hello-ebpf/actions/workflows/ci.yml/badge.svg)](https://github.com/parttimenerd/hello-ebpf/actions/workflows/ci.yml)
5+
46
There are [user land libraries](https://ebpf.io/what-is-ebpf/#development-toolchains) for [eBPF](https://ebpf.io) that allow you to
57
write eBPF applications in C++, Rust, Go, Python and even
68
Lua. But there are none for Java, which is a pity.

testutil/bin/java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#
77
# Configuration per environment variables:
88
# - `HBT_JAVA_BINARY` - the java binary to use (default: `java`)
9-
# - `HBT_KERNEL_VERSION` - the kernel version to use (default: `6.7`)
9+
# - `HBT_KERNEL_VERSION` - the kernel version to use (default: `6.6`)
1010
# see https://ghcr.io/cilium/ci-kernels for available versions
1111
#
1212
# Has to reside in bin/java so it can be passed to the `-Djvm` maven option.
@@ -20,8 +20,7 @@ set -e
2020
HBT_JAVA_BINARY=${HBT_JAVA_BINARY:-java}
2121

2222
# The kernel version to use
23-
HBT_KERNEL_VERSION=${HBT_KERNEL_VERSION:-6.7}
23+
HBT_KERNEL_VERSION=${HBT_KERNEL_VERSION:-6.6}
2424

2525
testutil_dir=$(dirname "$0")/..
26-
$testutil_dir/run-in-container.sh $HBT_KERNEL_VERSION $HBT_JAVA_BINARY $@
27-
exit 0
26+
$testutil_dir/run-in-container.sh $HBT_KERNEL_VERSION $HBT_JAVA_BINARY $@

testutil/find_and_get_kernel.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,6 @@ def copy_headers_into_dest(arch: str, version: str, dest_root: Path):
135135
argparse.add_argument("version", help="Kernel version")
136136
argparse.add_argument("destination", help="Destination folder")
137137
args = argparse.parse_args()
138-
print(
139-
f"Downloading headers for {args.version} (arch {get_arch()}) into {args.destination}")
140138
copy_headers_into_dest(get_arch(),
141139
args.version,
142140
Path(args.destination))

testutil/run-in-container.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ fi
7272
# get exact kernel version which is "$input/lib/modules/<version>/updates"
7373
kernel_version=$(basename "$(find "${input}/lib/modules" -maxdepth 1 -type d)")
7474

75+
# /lib is a symlink which causes problems
76+
mkdir "$input"/lib2
77+
cp -r "$input"/lib/modules "$input"/lib2
78+
rm -r "$input"/lib
79+
mv $input/lib2 $input/lib
80+
7581
"$script_folder"/find_and_get_kernel.py "${kernel_version}" "$input"
7682

7783
mkdir -p "$input"/root

testutil/setup-and-run.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@ if [[ -d "/run/input/usr/src/linux/tools/testing/selftests/bpf" ]]; then
99
export KERNEL_SELFTESTS="/run/input/usr/src/linux/tools/testing/selftests/bpf"
1010
fi
1111

12-
if [[ -d "/run/input/lib/modules" ]]; then
13-
find /run/input/lib/modules -type f -name bpf_testmod.ko -exec insmod {} \;
14-
fi
12+
#if [[ -d "/run/input/lib/modules" ]]; then
13+
# find /run/input/lib/modules -type f -name bpf_testmod.ko -exec insmod {} \;
14+
#fi
15+
16+
# used for debugging to check if bcc works at all
17+
#script_dir="$(dirname "$(realpath "$0")")"
18+
#timeout 5 python3 $script_dir/../pysamples/bcc/hello_world.py
19+
1520

1621
$* && touch /run/output/status

0 commit comments

Comments
 (0)