From: Lucas De Marchi Date: Wed, 12 Mar 2025 13:55:03 +0000 (-0500) Subject: ci: Generalize OS setup in one action X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5c188bd1982e22c7e665fdf705162350ff4f919d;p=thirdparty%2Fkmod.git ci: Generalize OS setup in one action 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 Reviewed-by: Emil Velikov Link: https://github.com/kmod-project/kmod/pull/321 --- diff --git a/.github/actions/setup-alpine/action.yml b/.github/actions/setup-alpine/action.yml deleted file mode 100644 index 591089d6..00000000 --- a/.github/actions/setup-alpine/action.yml +++ /dev/null @@ -1,29 +0,0 @@ -# SPDX-FileCopyrightText: 2024 Emil Velikov -# SPDX-FileCopyrightText: 2024 Lucas De Marchi -# -# 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 index 75d2b741..00000000 --- a/.github/actions/setup-archlinux/action.yml +++ /dev/null @@ -1,29 +0,0 @@ -# SPDX-FileCopyrightText: 2024 Emil Velikov -# SPDX-FileCopyrightText: 2024 Lucas De Marchi -# -# 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 index b9a09cef..00000000 --- a/.github/actions/setup-debian/action.yml +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-FileCopyrightText: 2024 Emil Velikov -# SPDX-FileCopyrightText: 2024 Lucas De Marchi -# -# 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 index 882b9ef9..00000000 --- a/.github/actions/setup-fedora/action.yml +++ /dev/null @@ -1,38 +0,0 @@ -# SPDX-FileCopyrightText: 2024 Emil Velikov -# SPDX-FileCopyrightText: 2024 Lucas De Marchi -# -# 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 index 00000000..8235caac --- /dev/null +++ b/.github/actions/setup-os/action.yml @@ -0,0 +1,19 @@ +# SPDX-FileCopyrightText: 2025 Lucas De Marchi +# 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 index 00000000..990accb7 --- /dev/null +++ b/.github/actions/setup-os/setup-alpine.sh @@ -0,0 +1,22 @@ +#!/bin/sh +# SPDX-FileCopyrightText: 2024 Emil Velikov +# SPDX-FileCopyrightText: 2024 Lucas De Marchi +# +# 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 index 00000000..d7bcb752 --- /dev/null +++ b/.github/actions/setup-os/setup-arch.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# SPDX-FileCopyrightText: 2024 Emil Velikov +# SPDX-FileCopyrightText: 2024 Lucas De Marchi +# +# 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 index 00000000..b8bf22e8 --- /dev/null +++ b/.github/actions/setup-os/setup-debian.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# SPDX-FileCopyrightText: 2024 Emil Velikov +# SPDX-FileCopyrightText: 2024 Lucas De Marchi +# +# 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 index 00000000..e52b19cd --- /dev/null +++ b/.github/actions/setup-os/setup-fedora.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# SPDX-FileCopyrightText: 2024 Emil Velikov +# SPDX-FileCopyrightText: 2024 Lucas De Marchi +# +# 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 index 00000000..8adfb6ac --- /dev/null +++ b/.github/actions/setup-os/setup-ubuntu.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# SPDX-FileCopyrightText: 2024 Emil Velikov +# SPDX-FileCopyrightText: 2024 Lucas De Marchi +# +# 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 index c644643b..00000000 --- a/.github/actions/setup-ubuntu/action.yml +++ /dev/null @@ -1,31 +0,0 @@ -# SPDX-FileCopyrightText: 2024 Emil Velikov -# SPDX-FileCopyrightText: 2024 Lucas De Marchi -# -# 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 diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 87f752b5..885323e1 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -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 diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index fc1a4919..72a6d5ec 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -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 diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 0da4f492..0b43c57c 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -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: | diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3f6d553b..abc30bc2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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