Skip to content

Commit

Permalink
add a github workflow
Browse files Browse the repository at this point in the history
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
  • Loading branch information
Andrea Righi committed May 3, 2024
1 parent 227b79e commit 2313d73
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/kernel.config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Add custom kernel configs here
37 changes: 37 additions & 0 deletions .github/workflows/run-kernel
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash
#
# Run a test for TIMEOUT seconds inside virtme-ng and catch potential errors.

# Maximum time the test run.
TEST_TIMEOUT=30

# Maximum timeout for the guest run (this is used to hard-shutdown the guest in
# case of system hangs).
GUEST_TIMEOUT=60

# Test command to run
TEST_CMD="uname -r"

# Check if virtme-ng is available.
if [ ! -x `which vng` ]; then
echo "vng not found, please install virtme-ng to enable testing"
exit 1
fi

# NOTE: virtme-ng automatically runs the kernel from the current working
# directory by default.
#
rm -f /tmp/output
(timeout --foreground --preserve-status ${GUEST_TIMEOUT} \
vng --force-9p --disable-microvm --verbose -- \
"timeout --foreground --preserve-status ${TEST_TIMEOUT} ${TEST_CMD}" \
2>&1 </dev/null || true) | tee /tmp/output
sed -n -e '/\bBUG:/q1' \
-e '/\bWARNING:/q1' /tmp/output
res=$?
if [ ${res} -ne 0 ]; then
echo "FAIL"
exit 1
else
echo "OK"
fi
33 changes: 33 additions & 0 deletions .github/workflows/test-kernel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: test-kernel
run-name: ${{ github.actor }} PR run
on: [pull_request, push]
jobs:
test-kernel:
runs-on: ubuntu-22.04
steps:
### OTHER REPOS ####

# Hard turn-off interactive mode
- run: echo 'debconf debconf/frontend select Noninteractive' | sudo debconf-set-selections

# Refresh packages list
- run: sudo apt update

### DOWNLOAD AND INSTALL DEPENDENCIES ###

# Download dependencies packaged by Ubuntu
- run: sudo apt -y install gcc make git coreutils cmake elfutils libelf-dev libunwind-dev libzstd-dev linux-headers-generic linux-tools-common linux-tools-generic ninja-build python3-pip python3-requests qemu-kvm udev iproute2 busybox-static libvirt-clients kbd kmod file rsync zstd pahole flex bison cpio libcap-dev libelf-dev python3-dev cargo rustc

# Checkout repository
- uses: actions/checkout@v4

# Install virtme-ng
- run: pip install virtme-ng

### END DEPENDENCIES ###

# Build a minimal kernel using virtme-ng
- run: vng -v --build --config .github/workflows/kernel.config

# Boot test the kernel
- run: .github/workflows/run-kernel

0 comments on commit 2313d73

Please sign in to comment.