Skip to content

Commit

Permalink
Add GitHub CI and fix test runner bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
parttimenerd committed Jan 26, 2024
1 parent 606924e commit d041f5a
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 9 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: ci
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: Build
runs-on: ubuntu-22.04
timeout-minutes: 10
steps:
- uses: actions/checkout@v4

- name: Setup Java 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'adopt'

- name: mvn package
run: mvn package -DskipTests

- name: upload bcc/target/bcc.jar
uses: actions/upload-artifact@v4
with:
name: bcc.jar
path: bcc/target/bcc.jar

vm-test:
name: Run tests on pre-built kernel
runs-on: ubuntu-22.04
needs: build
timeout-minutes: 10
strategy:
matrix:
version: ["6.6"]
env:
HBT_KERNEL_VERSION: "${{ matrix.version }}"
steps:
- uses: actions/checkout@v4

- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'adopt'

- run: sudo pip3 install https://github.com/amluto/virtme/archive/beb85146cd91de37ae455eccb6ab67c393e6e290.zip
- run: |
sudo apt-get update && sudo apt-get install -y --no-install-recommends qemu-system-x86 bpfcc-tools linux-headers-$(uname -r)
- name: Find libbcc.so
run: |
ls /lib*/**/libbcc.so
ls /var/**/libbcc.so
- name: Test
run: mvn test -Djvm=testutil/bin/java

- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
if: always()
with:
check_name: 'Test Report (Kernel ${{ matrix.KERNEL_VERSION }})'
report_paths: '**/build/test-results/test/TEST-*.xml'
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Hello eBPF
==========

[![ci](https://github.com/parttimenerd/hello-ebpf/actions/workflows/ci.yml/badge.svg)](https://github.com/parttimenerd/hello-ebpf/actions/workflows/ci.yml)

There are [user land libraries](https://ebpf.io/what-is-ebpf/#development-toolchains) for [eBPF](https://ebpf.io) that allow you to
write eBPF applications in C++, Rust, Go, Python and even
Lua. But there are none for Java, which is a pity.
Expand Down
7 changes: 3 additions & 4 deletions testutil/bin/java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
# Configuration per environment variables:
# - `HBT_JAVA_BINARY` - the java binary to use (default: `java`)
# - `HBT_KERNEL_VERSION` - the kernel version to use (default: `6.7`)
# - `HBT_KERNEL_VERSION` - the kernel version to use (default: `6.6`)
# see https://ghcr.io/cilium/ci-kernels for available versions
#
# Has to reside in bin/java so it can be passed to the `-Djvm` maven option.
Expand All @@ -20,8 +20,7 @@ set -e
HBT_JAVA_BINARY=${HBT_JAVA_BINARY:-java}

# The kernel version to use
HBT_KERNEL_VERSION=${HBT_KERNEL_VERSION:-6.7}
HBT_KERNEL_VERSION=${HBT_KERNEL_VERSION:-6.6}

testutil_dir=$(dirname "$0")/..
$testutil_dir/run-in-container.sh $HBT_KERNEL_VERSION $HBT_JAVA_BINARY $@
exit 0
$testutil_dir/run-in-container.sh $HBT_KERNEL_VERSION $HBT_JAVA_BINARY $@
2 changes: 0 additions & 2 deletions testutil/find_and_get_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,6 @@ def copy_headers_into_dest(arch: str, version: str, dest_root: Path):
argparse.add_argument("version", help="Kernel version")
argparse.add_argument("destination", help="Destination folder")
args = argparse.parse_args()
print(
f"Downloading headers for {args.version} (arch {get_arch()}) into {args.destination}")
copy_headers_into_dest(get_arch(),
args.version,
Path(args.destination))
6 changes: 6 additions & 0 deletions testutil/run-in-container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ fi
# get exact kernel version which is "$input/lib/modules/<version>/updates"
kernel_version=$(basename "$(find "${input}/lib/modules" -maxdepth 1 -type d)")

# /lib is a symlink which causes problems
mkdir "$input"/lib2
cp -r "$input"/lib/modules "$input"/lib2
rm -r "$input"/lib
mv $input/lib2 $input/lib

"$script_folder"/find_and_get_kernel.py "${kernel_version}" "$input"

mkdir -p "$input"/root
Expand Down
11 changes: 8 additions & 3 deletions testutil/setup-and-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ if [[ -d "/run/input/usr/src/linux/tools/testing/selftests/bpf" ]]; then
export KERNEL_SELFTESTS="/run/input/usr/src/linux/tools/testing/selftests/bpf"
fi

if [[ -d "/run/input/lib/modules" ]]; then
find /run/input/lib/modules -type f -name bpf_testmod.ko -exec insmod {} \;
fi
#if [[ -d "/run/input/lib/modules" ]]; then
# find /run/input/lib/modules -type f -name bpf_testmod.ko -exec insmod {} \;
#fi

# used for debugging to check if bcc works at all
#script_dir="$(dirname "$(realpath "$0")")"
#timeout 5 python3 $script_dir/../pysamples/bcc/hello_world.py


$* && touch /run/output/status

0 comments on commit d041f5a

Please sign in to comment.