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

new(ci): add a sample kmod source to test that we are able to build a kmod after kernel headers are installed #2

Closed
Closed
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions .github/workflows/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
MODULENAME=kmod

obj-m += $(MODULENAME).o

module:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules

clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
16 changes: 16 additions & 0 deletions .github/workflows/kmod.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <linux/module.h>

MODULE_LICENSE("GPL");
MODULE_AUTHOR("test");

static int devnode_dev_const_init(void)
{
return 0;
}

static void devnode_dev_const_exit(void)
{
}

module_init(devnode_dev_const_init);
module_exit(devnode_dev_const_exit);
34 changes: 18 additions & 16 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,40 @@ jobs:
test-composite-action:
runs-on: ubuntu-latest
steps:
- name: Echo kernelrelease
run: uname -a

- uses: actions/checkout@v4

- name: Test action
uses: ./
with:
cache: 'true'

- name: Check kernel sources
run: ls -la /usr/src
- name: Check that a fake module can be built
working-directory: .github/workflows
run: make

test-composite-action-cached:
runs-on: ubuntu-latest
needs: test-composite-action
steps:
- name: Echo kernelrelease
run: uname -a

- uses: actions/checkout@v4

- name: Store KERNEL_RELEASE
shell: bash
run: |
echo "KERNEL_RELEASE=$(uname -r)" >> $GITHUB_ENV

- name: Check kernel sources (empty)
run: ls -la /usr/src
echo "KERNEL_RELEASE=$(uname -r)" >> $GITHUB_ENV

- name: Retrieve cached kernel sources
- name: Test that kernel sources are cached
uses: actions/cache@v4
with:
path: |
/usr/src/linux
key: ${{ runner.os }}-${{ runner.arch }}-${{env.KERNEL_RELEASE}}
key: ${{ runner.os }}-${{ runner.arch }}-${{env.KERNEL_RELEASE}}

- name: Fully restore through action
uses: ./
with:
cache: 'true'

- name: Check kernel sources again
run: ls -la /usr/src
- name: Check that a fake module can be built again
working-directory: .github/workflows
run: make