Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a Github workflow for executing the tests in Qemu on actual kernels. #23

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .github/workflows/kernel_integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: 'Kernel Integration Tests'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on:
push:
branches: [ main ]
pull_request:
branches: [ '**' ]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be "main", the branch to merge against.


jobs:
build-initramfs:
runs-on: ubuntu-latest
steps:
- name: set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18

- name: checkout
uses: actions/checkout@v3

- name: build initramfs
run: |
go install github.com/florianl/bluebox@latest
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use a pinned commit to avoid unexpected behavior. We'll have to update it from time to time but I think it's worth it.

I'd prefer to not use external tools though. Why is bluebox required? What about using a base file (e.g. from ubuntu-latest) and append the required test files to the cpio archive?


- name: build tests
run: |
go test -ldflags='-extldflags=-static' -trimpath -tags 'osusergo netgo static_build linux' -c -o go-landlock-tests ./landlock

- name: build initramfs
run: |
bluebox -e go-landlock-tests:-test.v -o initramfs.cpio

- name: upload initramfs for tests
# Upload the generated initramfs.cpio and make it available for the parallel per-kernel tests.
uses: actions/upload-artifact@v3
with:
name: initramfs
path: |
initramfs.cpio

per-kernel-tests:
needs: build-initramfs
runs-on: ubuntu-latest
strategy:
matrix:
kernel-version: ["5.12.0-plus", "5.15", "5.19-rc4"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh nice, I didn't know about the matrix strategy.

steps:
- name: install qemu && curl
# Make sure required software packages are available.
run: |
sudo apt --yes update
sudo apt --yes install qemu-system-x86 curl

- name: get initramfs
# Fetch the initramfs.cpio that was created in the previous step.
uses: actions/download-artifact@v3
with:
name: initramfs

- name: get kernel
# Fetch the public kernel image that will be used in this test run.
run: |
curl -s -L -o bzImage.${{ matrix.kernel-version }} --fail https://github.com/gnoack/linux-kernel-images/blob/main/bzImage.${{ matrix.kernel-version }}?raw=true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need to download whereas it is in a GitHub repository?

Anyway, I would prefer to download this bzImage from a bleeding-edge distro package.


- name: run tests on kernel
# Run the tests.
run: |
qemu-system-x86_64 -nographic -append "console=ttyS0 lsm=landlock" -m 2G -kernel bzImage.${{ matrix.kernel-version }} -initrd initramfs.cpio