]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
ci: Generalize OS setup in one action
authorLucas De Marchi <lucas.de.marchi@gmail.com>
Wed, 12 Mar 2025 13:55:03 +0000 (08:55 -0500)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Tue, 25 Mar 2025 19:01:26 +0000 (14:01 -0500)
Use just one action for OS setup and make it call the right script. This
makes it easier to maintain as when devs are working with containers,
they can just call the script, and it also avoids repeated conditional
steps in the workflows.

If a distro is not supported, the action will simply fail and support
may be added later.

With the move to .sh files, also run shellcheck in them: surprisingly
just one quote missing.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/321
15 files changed:
.github/actions/setup-alpine/action.yml [deleted file]
.github/actions/setup-archlinux/action.yml [deleted file]
.github/actions/setup-debian/action.yml [deleted file]
.github/actions/setup-fedora/action.yml [deleted file]
.github/actions/setup-os/action.yml [new file with mode: 0644]
.github/actions/setup-os/setup-alpine.sh [new file with mode: 0755]
.github/actions/setup-os/setup-arch.sh [new file with mode: 0755]
.github/actions/setup-os/setup-debian.sh [new file with mode: 0755]
.github/actions/setup-os/setup-fedora.sh [new file with mode: 0755]
.github/actions/setup-os/setup-ubuntu.sh [new file with mode: 0755]
.github/actions/setup-ubuntu/action.yml [deleted file]
.github/workflows/codeql.yml
.github/workflows/coverage.yml
.github/workflows/docs.yml
.github/workflows/main.yml

diff --git a/.github/actions/setup-alpine/action.yml b/.github/actions/setup-alpine/action.yml
deleted file mode 100644 (file)
index 591089d..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-# SPDX-FileCopyrightText: 2024 Emil Velikov <emil.l.velikov@gmail.com>
-# SPDX-FileCopyrightText: 2024 Lucas De Marchi <lucas.de.marchi@gmail.com>
-#
-# SPDX-License-Identifier: LGPL-2.1-or-later
-
-name: 'setup Alpine'
-description: 'Setup an Alpine container for running CI'
-runs:
-  using: 'composite'
-  steps:
-    - name: Install dependencies
-      shell: sh
-      run: |
-        apk update
-        apk add \
-          bash \
-          build-base \
-          coreutils \
-          clang \
-          git \
-          gtk-doc \
-          linux-edge-dev \
-          meson \
-          openssl-dev \
-          scdoc \
-          tar \
-          xz-dev \
-          zlib-dev \
-          zstd-dev
diff --git a/.github/actions/setup-archlinux/action.yml b/.github/actions/setup-archlinux/action.yml
deleted file mode 100644 (file)
index 75d2b74..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-# SPDX-FileCopyrightText: 2024 Emil Velikov <emil.l.velikov@gmail.com>
-# SPDX-FileCopyrightText: 2024 Lucas De Marchi <lucas.de.marchi@gmail.com>
-#
-# SPDX-License-Identifier: LGPL-2.1-or-later
-
-name: 'setup Archlinux'
-description: 'Setup an Archlinux container for running CI'
-runs:
-  using: 'composite'
-  steps:
-    - name: Install dependencies
-      shell: bash
-      run: |
-        # Semi-regularly the packager key may have (temporarily) expired.
-        # Somewhat robust solution is to wipe the local keyring and
-        # regenerate/reinstall it prior to any other packages on the system.
-        rm -rf /etc/pacman.d/gnupg
-        pacman-key --init
-        pacman-key --populate
-        pacman --noconfirm -Sy archlinux-keyring
-
-        pacman --noconfirm -Su \
-          clang \
-          git \
-          gtk-doc \
-          linux-headers \
-          lld \
-          meson \
-          scdoc
diff --git a/.github/actions/setup-debian/action.yml b/.github/actions/setup-debian/action.yml
deleted file mode 100644 (file)
index b9a09ce..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-# SPDX-FileCopyrightText: 2024 Emil Velikov <emil.l.velikov@gmail.com>
-# SPDX-FileCopyrightText: 2024 Lucas De Marchi <lucas.de.marchi@gmail.com>
-#
-# SPDX-License-Identifier: LGPL-2.1-or-later
-
-name: 'setup Debian'
-description: 'Setup a Debian container for running CI'
-runs:
-  using: 'composite'
-  steps:
-    - name: Install dependencies
-      shell: bash
-      run: |
-        export DEBIAN_FRONTEND=noninteractive
-        export TZ=Etc/UTC
-
-        . /etc/os-release
-
-        backports_pkgs=()
-        if [[ "$VERSION_CODENAME" == "bullseye" ]]; then
-          echo "deb http://deb.debian.org/debian bullseye-backports main" >> /etc/apt/sources.list
-          backports_pkgs=("meson" "ninja-build")
-        fi
-
-        apt-get update
-        apt-get install --yes \
-          build-essential \
-          clang \
-          gcc-multilib \
-          git \
-          gtk-doc-tools \
-          liblzma-dev \
-          libssl-dev \
-          libzstd-dev \
-          linux-headers-generic \
-          meson \
-          scdoc \
-          zlib1g-dev \
-          zstd
-
-        if (( ${#backports_pkgs[@]} )); then
-          apt-get install --yes -t ${VERSION_CODENAME}-backports "${backports_pkgs[@]}"
-        fi
diff --git a/.github/actions/setup-fedora/action.yml b/.github/actions/setup-fedora/action.yml
deleted file mode 100644 (file)
index 882b9ef..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-# SPDX-FileCopyrightText: 2024 Emil Velikov <emil.l.velikov@gmail.com>
-# SPDX-FileCopyrightText: 2024 Lucas De Marchi <lucas.de.marchi@gmail.com>
-#
-# SPDX-License-Identifier: LGPL-2.1-or-later
-
-name: 'setup Fedora'
-description: 'Setup a Fedora container for running CI'
-runs:
-  using: 'composite'
-  steps:
-    - name: Install dependencies
-      shell: bash
-      run: |
-        dnf update -y
-        dnf install -y \
-          clang \
-          compiler-rt \
-          gcc \
-          git \
-          gtk-doc \
-          kernel-devel \
-          libasan \
-          libhwasan \
-          liblsan \
-          libtsan \
-          libubsan \
-          libzstd-devel \
-          make \
-          meson \
-          openssl-devel \
-          scdoc \
-          xz-devel \
-          zlib-devel
-        # CI builds with KDIR pointing to /usr/lib/modules/*/build
-        # so just a foo/build pointing to the right place, assuming
-        # just one kernel installed
-        mkdir -p /usr/lib/modules/foo/
-        ln -s /usr/src/kernels/* /usr/lib/modules/foo/build
diff --git a/.github/actions/setup-os/action.yml b/.github/actions/setup-os/action.yml
new file mode 100644 (file)
index 0000000..8235caa
--- /dev/null
@@ -0,0 +1,19 @@
+# SPDX-FileCopyrightText: 2025 Lucas De Marchi <lucas.de.marchi@gmail.com>
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+name: 'Setup OS'
+description: 'Setup an OS container for running CI'
+runs:
+  using: 'composite'
+  steps:
+    - name: Detect distro
+      shell: sh
+      run: |
+        . /etc/os-release
+        DISTRO=$ID
+        echo "Distro: $DISTRO"
+        echo DISTRO="$DISTRO" >> $GITHUB_ENV
+
+    - name: Setup distro
+      shell: sh
+      run: ${GITHUB_ACTION_PATH}/setup-${DISTRO}.sh
diff --git a/.github/actions/setup-os/setup-alpine.sh b/.github/actions/setup-os/setup-alpine.sh
new file mode 100755 (executable)
index 0000000..990accb
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/sh
+# SPDX-FileCopyrightText: 2024 Emil Velikov <emil.l.velikov@gmail.com>
+# SPDX-FileCopyrightText: 2024 Lucas De Marchi <lucas.de.marchi@gmail.com>
+#
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+apk update
+apk add \
+    bash \
+    build-base \
+    coreutils \
+    clang \
+    git \
+    gtk-doc \
+    linux-edge-dev \
+    meson \
+    openssl-dev \
+    scdoc \
+    tar \
+    xz-dev \
+    zlib-dev \
+    zstd-dev
diff --git a/.github/actions/setup-os/setup-arch.sh b/.github/actions/setup-os/setup-arch.sh
new file mode 100755 (executable)
index 0000000..d7bcb75
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/bash
+# SPDX-FileCopyrightText: 2024 Emil Velikov <emil.l.velikov@gmail.com>
+# SPDX-FileCopyrightText: 2024 Lucas De Marchi <lucas.de.marchi@gmail.com>
+#
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+# Semi-regularly the packager key may have (temporarily) expired. Somewhat
+# robust solution is to wipe the local keyring and regenerate/reinstall it
+# prior to any other packages on the system.
+rm -rf /etc/pacman.d/gnupg
+pacman-key --init
+pacman-key --populate
+pacman --noconfirm -Sy archlinux-keyring
+
+pacman --noconfirm -Su \
+    clang \
+    git \
+    gtk-doc \
+    linux-headers \
+    lld \
+    meson \
+    scdoc
diff --git a/.github/actions/setup-os/setup-debian.sh b/.github/actions/setup-os/setup-debian.sh
new file mode 100755 (executable)
index 0000000..b8bf22e
--- /dev/null
@@ -0,0 +1,36 @@
+#!/bin/bash
+# SPDX-FileCopyrightText: 2024 Emil Velikov <emil.l.velikov@gmail.com>
+# SPDX-FileCopyrightText: 2024 Lucas De Marchi <lucas.de.marchi@gmail.com>
+#
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+export DEBIAN_FRONTEND=noninteractive
+export TZ=Etc/UTC
+
+. /etc/os-release
+
+backports_pkgs=()
+if [[ "$VERSION_CODENAME" == "bullseye" ]]; then
+    echo "deb http://deb.debian.org/debian bullseye-backports main" >> /etc/apt/sources.list
+    backports_pkgs=("meson" "ninja-build")
+fi
+
+apt-get update
+apt-get install --yes \
+    build-essential \
+    clang \
+    gcc-multilib \
+    git \
+    gtk-doc-tools \
+    liblzma-dev \
+    libssl-dev \
+    libzstd-dev \
+    linux-headers-generic \
+    meson \
+    scdoc \
+    zlib1g-dev \
+    zstd
+
+if (( ${#backports_pkgs[@]} )); then
+    apt-get install --yes -t "${VERSION_CODENAME}"-backports "${backports_pkgs[@]}"
+fi
diff --git a/.github/actions/setup-os/setup-fedora.sh b/.github/actions/setup-os/setup-fedora.sh
new file mode 100755 (executable)
index 0000000..e52b19c
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/bash
+# SPDX-FileCopyrightText: 2024 Emil Velikov <emil.l.velikov@gmail.com>
+# SPDX-FileCopyrightText: 2024 Lucas De Marchi <lucas.de.marchi@gmail.com>
+#
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+dnf update -y
+dnf install -y \
+    clang \
+    compiler-rt \
+    gcc \
+    git \
+    gtk-doc \
+    kernel-devel \
+    libasan \
+    libhwasan \
+    liblsan \
+    libtsan \
+    libubsan \
+    libzstd-devel \
+    make \
+    meson \
+    openssl-devel \
+    scdoc \
+    xz-devel \
+    zlib-devel
+
+    # CI builds with KDIR pointing to /usr/lib/modules/*/build
+    # so just a foo/build pointing to the right place, assuming
+    # just one kernel installed
+    mkdir -p /usr/lib/modules/foo/
+    ln -s /usr/src/kernels/* /usr/lib/modules/foo/build
diff --git a/.github/actions/setup-os/setup-ubuntu.sh b/.github/actions/setup-os/setup-ubuntu.sh
new file mode 100755 (executable)
index 0000000..8adfb6a
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/bash
+# SPDX-FileCopyrightText: 2024 Emil Velikov <emil.l.velikov@gmail.com>
+# SPDX-FileCopyrightText: 2024 Lucas De Marchi <lucas.de.marchi@gmail.com>
+#
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+export DEBIAN_FRONTEND=noninteractive
+export TZ=Etc/UTC
+apt-get update
+apt-get install --yes \
+    build-essential \
+    clang \
+    gcc-multilib \
+    gcovr \
+    git \
+    gtk-doc-tools \
+    liblzma-dev \
+    libssl-dev \
+    libzstd-dev \
+    linux-headers-generic \
+    meson \
+    scdoc \
+    zlib1g-dev \
+    zstd
diff --git a/.github/actions/setup-ubuntu/action.yml b/.github/actions/setup-ubuntu/action.yml
deleted file mode 100644 (file)
index c644643..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-# SPDX-FileCopyrightText: 2024 Emil Velikov <emil.l.velikov@gmail.com>
-# SPDX-FileCopyrightText: 2024 Lucas De Marchi <lucas.de.marchi@gmail.com>
-#
-# SPDX-License-Identifier: LGPL-2.1-or-later
-
-name: 'setup Ubuntu'
-description: 'Setup an Ubuntu container for running CI'
-runs:
-  using: 'composite'
-  steps:
-    - name: Install dependencies
-      shell: bash
-      run: |
-        export DEBIAN_FRONTEND=noninteractive
-        export TZ=Etc/UTC
-        apt-get update
-        apt-get install --yes \
-          build-essential \
-          clang \
-          gcc-multilib \
-          gcovr \
-          git \
-          gtk-doc-tools \
-          liblzma-dev \
-          libssl-dev \
-          libzstd-dev \
-          linux-headers-generic \
-          meson \
-          scdoc \
-          zlib1g-dev \
-          zstd
index 87f752b5c3a4fe71ac169942ea016cd4f992b76f..885323e19ab0114d5cb812663a8547ffc269fb05 100644 (file)
@@ -40,8 +40,8 @@ jobs:
         with:
           sparse-checkout: .github
 
-      - uses: ./.github/actions/setup-ubuntu
-        if: ${{ startsWith(matrix.container.name, 'ubuntu') }}
+      - name: Setup OS
+        uses: ./.github/actions/setup-os
 
       - name: Checkout the whole project
         uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
index fc1a4919d88aeb11837eaeb7d70782f00243cb2f..72a6d5ec135126b90826bcfaf2a7c94c5e67b1bd 100644 (file)
@@ -36,8 +36,8 @@ jobs:
         with:
           sparse-checkout: .github
 
-      - uses: ./.github/actions/setup-ubuntu
-        if: ${{ startsWith(matrix.container.name, 'ubuntu') }}
+      - name: Setup OS
+        uses: ./.github/actions/setup-os
 
       - name: Checkout the whole project
         uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
index 0da4f492c73e45a7a44b633cf7931b2443a0b4de..0b43c57c60dd0c2104e9b82947f18874a496a2c8 100644 (file)
@@ -24,8 +24,8 @@ jobs:
       - name: Checkout
         uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
 
-      - name: Setup Ubuntu
-        uses: ./.github/actions/setup-ubuntu
+      - name: Setup OS
+        uses: ./.github/actions/setup-os
 
       - name: Build docs
         run: |
index 3f6d553ba04ef0668b7179f4f7e805dd6b06b38a..abc30bc2734a6c8f8885dd24ae5c8c5c93f887aa 100644 (file)
@@ -121,16 +121,8 @@ jobs:
         with:
           sparse-checkout: .github
 
-      - uses: ./.github/actions/setup-alpine
-        if: ${{ startsWith(matrix.container, 'alpine') }}
-      - uses: ./.github/actions/setup-archlinux
-        if: ${{ startsWith(matrix.container, 'archlinux') }}
-      - uses: ./.github/actions/setup-debian
-        if: ${{ startsWith(matrix.container, 'debian') }}
-      - uses: ./.github/actions/setup-fedora
-        if: ${{ startsWith(matrix.container, 'fedora') }}
-      - uses: ./.github/actions/setup-ubuntu
-        if: ${{ startsWith(matrix.container, 'ubuntu') }}
+      - name: Setup OS
+        uses: ./.github/actions/setup-os
 
       - name: Checkout the whole project
         uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2