diff options
Diffstat (limited to '.github/workflows/tests.yml')
-rw-r--r-- | .github/workflows/tests.yml | 143 |
1 files changed, 143 insertions, 0 deletions
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..3922093 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,143 @@ +name: Run tests + +on: [push, pull_request] + +jobs: + test-distributions: + name: Build in containers + strategy: + matrix: + distro: + - {name: "alpine", tag: "3.14", variant: "-lts"} + - {name: "alpine", tag: "3.14", variant: "-virt"} + - {name: "alpine", tag: "3.13", variant: "-lts"} + - {name: "alpine", tag: "3.13", variant: "-virt"} + - {name: "alpine", tag: "3.12", variant: "-lts"} + - {name: "alpine", tag: "3.12", variant: "-virt"} + - {name: "alpine", tag: "3.11", variant: "-lts"} + - {name: "alpine", tag: "3.11", variant: "-virt"} + - {name: "alpine", tag: "3.10", variant: "-vanilla"} + - {name: "alpine", tag: "3.10", variant: "-virt"} + - {name: "archlinux", tag: "latest"} + - {name: "archlinux", tag: "latest", variant: "-lts"} + - {name: "archlinux", tag: "latest", variant: "-zen"} + - {name: "centos", tag: "7"} + - {name: "almalinux", tag: "8"} + - {name: "almalinux", tag: "9"} + - {name: "debian", tag: "11"} + - {name: "debian", tag: "10"} + - {name: "debian", tag: "9"} + - {name: "debian", tag: "8"} + - {name: "ubuntu", tag: "22.04"} + - {name: "ubuntu", tag: "20.04"} + - {name: "ubuntu", tag: "18.04"} + runs-on: ubuntu-20.04 + container: + image: docker://docker.io/library/${{ matrix.distro.name }}:${{ matrix.distro.tag }} + + steps: + - uses: actions/checkout@v3 + + - name: Install Alpine dependencies + if: matrix.distro.name == 'alpine' + run: | + apk --no-cache --update add bash gcc linux${{ matrix.distro.variant }} linux${{ matrix.distro.variant }}-dev make openssl + + - name: Install Arch Linux dependencies + if: matrix.distro.name == 'archlinux' + run: | + pacman -Syu --noconfirm diffutils gcc make linux${{ matrix.distro.variant }}-headers openssl + + - name: Install CentOS dependencies + if: matrix.distro.name == 'centos' + run: | + yum install -y diffutils elfutils-libelf-devel gcc kernel kernel-devel make openssl + + - name: Install AlmaLinux dependencies + if: matrix.distro.name == 'almalinux' + run: | + yum install -y diffutils elfutils-libelf-devel gcc kernel kernel-devel make openssl + + - name: Install Debian dependencies + if: matrix.distro.name == 'debian' + run: | + EXTRA_ARGS='' + if [ "${{ matrix.distro.tag }}" = 8 ] ; then + # repo key is expired + EXTRA_ARGS="--allow-unauthenticated" + fi + apt-get update -q + apt-get install -qy $EXTRA_ARGS gcc make linux-headers-amd64 linux-image-amd64 openssl + + - name: Install Ubuntu dependencies + if: matrix.distro.name == 'ubuntu' + run: | + apt-get update -q + apt-get install -qy gcc make linux-headers-generic linux-image-generic openssl shim-signed + + - name: Compute packaged kernel version + id: versions + run: | + KERNEL_VER='' + if [ "${{ matrix.distro.name }}" = alpine ] ; then + KERNEL_VER="$(apk info --contents "linux${{ matrix.distro.variant }}-dev" | sed -n 's:^lib/modules/\([^/][^/]*\)/.*:\1:p' | head -n 1)" + elif [ "${{ matrix.distro.name }}" = archlinux ] ; then + KERNEL_VER="$(pacman -Qql "linux${{ matrix.distro.variant }}-headers" | sed -n 's:^/usr/lib/modules/\([^/]\+\)/.*:\1:p' | head -n 1)" + elif [ "${{ matrix.distro.name }}" = centos ] || [ "${{ matrix.distro.name }}" = almalinux ] ; then + KERNEL_VER="$(LANG=C rpm -qi kernel-devel | sed -n 's/^Source RPM *: kernel-\(.*\).src.rpm$/\1.x86_64/p' | tail -n 1)" + elif [ "${{ matrix.distro.name }}" = debian ] ; then + KERNEL_VER="$(LANG=C dpkg --status linux-headers-amd64 | sed -n 's/^Depends: linux-headers-\(\S\+\)\( .*\)\?/\1/p' | head -n 1)" + elif [ "${{ matrix.distro.name }}" = ubuntu ] ; then + KERNEL_VER="$(LANG=C dpkg --status linux-headers-generic | sed -n 's/^Depends: linux-headers-\(\S\+\)\( .*\)\?/\1/p' | head -n 1)" + fi + if [ -z "${KERNEL_VER}" ] ; then + echo >&2 "Error: no kernel package found" + exit 1 + fi + echo "Found packaged kernel ${KERNEL_VER}" + echo "KERNEL_VER=${KERNEL_VER}" >> "$GITHUB_ENV" + + - name: Install dkms + run: make install + + - name: Run tests + run: | + if [ "${{ matrix.distro.name }}" = alpine ] && ([ "${{ matrix.distro.tag }}" = 3.10 ] || [ "${{ matrix.distro.variant }}" = "-lts" ]); then + ./run_test.sh --no-signing-tool + elif [ "${{ matrix.distro.name }}" = debian ] && [ "${{ matrix.distro.tag }}" = 8 ]; then + ./run_test.sh --no-signing-tool + else + ./run_test.sh + fi + + test-vm: + name: Test in Ubuntu VM + strategy: + matrix: + version: + - 22.04 + - 20.04 + runs-on: ubuntu-${{ matrix.version }} + + steps: + - uses: actions/checkout@v3 + + - name: Install dependencies + run: | + sudo apt-get update -q + sudo apt-get install -qqy make + + - name: Install dkms + run: sudo make install + + - name: Run tests + run: sudo ./run_test.sh + + - name: Install the test module + run: sudo dkms install test/dkms_test-1.0 + + - name: Load the test module + run: sudo modprobe dkms_test + + - name: Remove the test module + run: sudo dkms remove --all -m dkms_test -v 1.0 |