summaryrefslogtreecommitdiffstats
path: root/.github/workflows/tests.yml
blob: 30d6d1d8d4858e75a999f5c7b4722d9ad1d52ad4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
name: Run tests

on:
  # Build at 23:00 every Sunday
  schedule:
    - cron: "0 23 * * 1"
  pull_request:
  push:

jobs:
  test-distributions:
    name: Build in containers
    strategy:
      matrix:
        distro:
          - {name: "almalinux", tag: "9"}
          - {name: "almalinux", tag: "8"}
          - {name: "alpine", tag: "3.19", variant: "-lts"}
          - {name: "alpine", tag: "3.19", variant: "-virt"}
          - {name: "alpine", tag: "3.18", variant: "-lts"}
          - {name: "alpine", tag: "3.18", variant: "-virt"}
          - {name: "alpine", tag: "3.17", variant: "-lts"}
          - {name: "alpine", tag: "3.17", variant: "-virt"}
          - {name: "alpine", tag: "3.16", variant: "-lts"}
          - {name: "alpine", tag: "3.16", variant: "-virt"}
          - {name: "archlinux", tag: "latest"}
          - {name: "archlinux", tag: "latest", variant: "-lts"}
          - {name: "archlinux", tag: "latest", variant: "-zen"}
          - {name: "centos/centos", tag: "stream9", url: "quay.io/"}
          - {name: "centos/centos", tag: "stream8", url: "quay.io/"}
          - {name: "centos", tag: "7"}
          - {name: "debian", tag: "testing"}
          - {name: "debian", tag: "12"}
          - {name: "debian", tag: "11"}
          - {name: "debian", tag: "10"}
          - {name: "fedora/fedora", tag: "39", url: "quay.io/"}
          - {name: "fedora/fedora", tag: "38", url: "quay.io/"}
          - {name: "gentoo/stage3", tag: "latest"}
          - {name: "opensuse/tumbleweed", tag: "latest", variant: "-default", url: "registry.opensuse.org/"}
          - {name: "opensuse/leap", tag: "15.5", variant: "-default", url: "registry.opensuse.org/"}
          - {name: "ubuntu", tag: "23.10"}
          - {name: "ubuntu", tag: "22.04"}
          - {name: "ubuntu", tag: "20.04"}
          - {name: "ubuntu", tag: "18.04"}
    runs-on: ubuntu-20.04
    container:
      image: ${{ matrix.distro.url }}${{ matrix.distro.name }}:${{ matrix.distro.tag }}

    steps:
    - name: Install git for checkout action
      if: contains(matrix.distro.name, 'opensuse')
      run: |
        zypper --non-interactive install git

    - uses: actions/checkout@v3

    - name: Install AlmaLinux dependencies
      if: matrix.distro.name == 'almalinux'
      run: |
        yum install -y diffutils elfutils-libelf gcc kernel kernel-devel make openssl

    - 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 coreutils

    - name: Install Arch Linux dependencies
      if: matrix.distro.name == 'archlinux'
      run: |
        pacman -Syu --noconfirm diffutils gcc make linux${{ matrix.distro.variant }} linux${{ matrix.distro.variant }}-headers openssl

    - name: Install CentOS dependencies
      if: contains(matrix.distro.name, 'centos')
      run: |
        yum install -y diffutils elfutils-libelf gcc kernel kernel-devel make openssl

    - name: Install Debian dependencies
      if: matrix.distro.name == 'debian'
      run: |
        apt-get update -q
        apt-get install -qy make linux-headers-amd64 linux-image-amd64 openssl xz-utils

    - name: Install Fedora dependencies
      if: contains(matrix.distro.name, 'fedora')
      run: |
        yum install -y diffutils elfutils-libelf gcc kernel kernel-devel make openssl

    - name: Install Gentoo Linux dependencies
      if: matrix.distro.name == 'gentoo/stage3'
      run: |
        echo -e "ACCEPT_KEYWORDS=\"~amd64\"\nACCEPT_LICENSE=\"*\"" >> /etc/portage/make.conf
        emerge --sync
        FEATURES="getbinpkg binpkg-ignore-signature" USE="generic-uki" emerge --noreplace -j$(nproc) -l$(nproc) --autounmask-continue '>=sys-kernel/gentoo-kernel-bin-6.6.0'

    - name: Install openSUSE leap dependencies
      if: contains(matrix.distro.name, 'opensuse')
      run: |
        zypper --non-interactive install diffutils elfutils gcc kernel${{ matrix.distro.variant }} kernel${{ matrix.distro.variant }}-devel make 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: Install dkms
      run: make install

    - name: Run tests
      run: |
        for moddir in /usr/lib/modules/ /lib/modules/; do
            if [ -e "$moddir" ]; then
                kernels=$(find "$moddir" -maxdepth 1 -type d -exec basename {} \;)
                break
            fi
        done

        # There should be two entries - "modules" and the kernel we installed
        if [ $(echo "${kernels}" | wc -l) -ne 2 ]; then
            echo >&2 "Error: invalid number of kernels installed"
        fi

        KERNEL_VER=$(echo "${kernels}" | tail -n1)
        if [ -z "${KERNEL_VER}" ] ; then
            echo >&2 "Error: no kernel package found"
            exit 1
        fi

        echo "Found kernel ${KERNEL_VER}"
        export KERNEL_VER

        echo "Module search paths"
        for depmod in /etc/depmod.d/ /usr/lib/depmod.d/ /lib/depmod.d/; do
            [ -e "$depmod" ] && grep -r ^search "$depmod" || true
        done

        if [ "${{ matrix.distro.name }}" = alpine ] && [ "${{ matrix.distro.variant }}" = "-lts" ]; then
            if [ "${{ matrix.distro.tag}}" = "3.16" ] || [ "${{ matrix.distro.tag }}" = "3.17" ]; then
                ./run_test.sh --no-signing-tool
            else
                ./run_test.sh
            fi
        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