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 ae05782
Show file tree
Hide file tree
Showing 5 changed files with 84 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" ]

env:
TMPDIR: /tmp
CI_MAX_KERNEL_VERSION: '6.7'
CI_MIN_CLANG_VERSION: '11'

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

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

- name: Setup Java 21
uses: actions/setup-java@v2
with:
java-version: '21'

- name: mvn package
run: mvn package

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

vm-test:
name: Run tests on pre-built kernel
runs-on: ubuntu-latest-4cores-16gb
needs: build-and-lint
timeout-minutes: 10
strategy:
matrix:
version: ["6.6", "6.1"]
env:
KERNEL_VERSION: "${{ matrix.version }}"
steps:
- uses: actions/checkout@v3

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

- 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

- name: Test
run: mvn test -Djvm=testutil/bin/jvm
env:
HBT_KERNEL_VERSION: ${{ matrix.KERNEL_VERSION }}

- 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'
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
8 changes: 5 additions & 3 deletions testutil/setup-and-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ 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

#timeout 5 python3 /home/i560383/code/experiments/ebpf/hello/pysamples/bcc/hello_world.py

$* && touch /run/output/status

0 comments on commit ae05782

Please sign in to comment.