From df3dab8f602b8e6b81dc34c31fb4431b807a5a4e Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Tue, 29 Jul 2025 17:46:15 +0200 Subject: [PATCH] .github: add CI pipeline This pipeline builds the driver against the latest Xserver stable release as well as current master. Signed-off-by: Enrico Weigelt, metux IT consult --- .github/actions/build-driver/action.yaml | 69 +++++++++++++++++ .github/scripts/conf.sh | 13 ++++ .github/scripts/github/make-release | 17 +++++ .github/scripts/install-prereq.sh | 15 ++++ .github/scripts/ubuntu/install-pkg.sh | 94 ++++++++++++++++++++++++ .github/scripts/util.sh | 85 +++++++++++++++++++++ .github/workflows/build.yml | 43 +++++++++++ 7 files changed, 336 insertions(+) create mode 100644 .github/actions/build-driver/action.yaml create mode 100644 .github/scripts/conf.sh create mode 100755 .github/scripts/github/make-release create mode 100755 .github/scripts/install-prereq.sh create mode 100755 .github/scripts/ubuntu/install-pkg.sh create mode 100644 .github/scripts/util.sh create mode 100644 .github/workflows/build.yml diff --git a/.github/actions/build-driver/action.yaml b/.github/actions/build-driver/action.yaml new file mode 100644 index 0000000..3032abd --- /dev/null +++ b/.github/actions/build-driver/action.yaml @@ -0,0 +1,69 @@ +name: 'build driver' +description: 'build driver against specific Xserver' +inputs: + xserver-version: + required: true + +runs: + using: "composite" + steps: + - name: check out driver repo + uses: actions/checkout@v4 + + - name: prepare build environment + shell: bash + run: | + MACHINE=`gcc -dumpmachine` + echo "MACHINE=$MACHINE" >> "$GITHUB_ENV" + echo "PKG_CONFIG_PATH=$X11_PREFIX/share/pkgconfig:$X11_PREFIX/lib/$MACHINE/pkgconfig:$X11_PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH" >> "$GITHUB_ENV" + sudo chown root /bin/tar && sudo chmod u+s /bin/tar + + - name: apt cache + uses: actions/cache@v4 + with: + path: /var/cache/apt + key: apt-cache-${{ hashFiles('.github/scripts/ubuntu/install-pkg.sh') }} + restore-keys: apt-cache- + + - name: pkg install + shell: bash + run: sudo .github/scripts/ubuntu/install-pkg.sh + + - name: X11 prereq cache + uses: actions/cache@v4 + with: + path: | + ${{ env.X11_PREFIX }} + key: ${{ runner.name }}-x11-deps-${{ hashFiles('.github/scripts/install-prereq.sh') }} + restore-keys: ${{ runner.name }}-x11-deps- + + - name: generic prereq + shell: bash + run: .github/scripts/install-prereq.sh + + - name: check out xserver repo + uses: actions/checkout@v4 + with: + repository: X11Libre/xserver + path: xserver-sdk + ref: ${{ inputs.xserver-version }} + + - name: build xserver sdk + shell: bash + env: + MESON_ARGS: -Dc_args="-fno-common" -Dprefix=/usr -Dnamespace=false -Dxselinux=false -Dxephyr=false -Dwerror=false -Dxcsecurity=false -Dxorg=true -Dxvfb=false -Dxnest=false -Ddocs=false + run: | + cd xserver-sdk + echo -n > .meson_environment + echo "export MESON_BUILDDIR=$MESON_BUILDDIR" >> .meson_environment + echo "export PKG_CONFIG_PATH=$PKG_CONFIG_PATH" >> .meson_environment + .gitlab-ci/meson-build.sh --skip-test + sudo meson install --no-rebuild -C "$MESON_BUILDDIR" + sudo mkdir -p /usr/local/lib/$MACHINE/xorg/modules # /home/runner/x11/lib/xorg/modules + sudo chown -R runner /usr/local/lib/$MACHINE/xorg/modules # /home/runner/x11/lib/xorg/modules + + - name: compile driver + shell: bash + run: | + CFLAGS="-Wall" ./autogen.sh # --prefix=$X11_PREFIX + CFLAGS="-Wall" make -j # install diff --git a/.github/scripts/conf.sh b/.github/scripts/conf.sh new file mode 100644 index 0000000..7cdab25 --- /dev/null +++ b/.github/scripts/conf.sh @@ -0,0 +1,13 @@ +export X11_OS=`uname -s` + +export X11_PREFIX="${X11_PREFIX:-$HOME/x11}" +export X11_BUILD_DIR="${X11_BUILD_DIR:-$HOME/build-deps}" +export DRV_BUILD_DIR="${DRV_BUILD_DIR:-$HOME/build-drivers}" + +case "$X11_OS" in +Darwin) export FDO_CI_CONCURRENT=`sysctl -n hw.logicalcpu` ;; +Linux) export FDO_CI_CONCURRENT=`nproc` ;; +esac + +export PATH="$X11_PREFIX/bin:$PATH" +export PKG_CONFIG_PATH="$X11_PREFIX/lib/x86_64-linux-gnu/pkgconfig:$X11_PREFIX/lib/pkgconfig:$X11_PREFIX/share/pkgconfig:$PKG_CONFIG_PATH" diff --git a/.github/scripts/github/make-release b/.github/scripts/github/make-release new file mode 100755 index 0000000..89152ba --- /dev/null +++ b/.github/scripts/github/make-release @@ -0,0 +1,17 @@ +#!/bin/bash + +err() { + echo "$0: $*" +} + +[ "$GITHUB_REPOSITORY" ] || err "missing variable GITHUB_REPOSITORY" + +TITLE=$(git tag -l --format='%(contents)' $tag) + +echo "tag=$tag" +echo "title=$TITLE" + +gh release create "$tag" \ + --repo="$GITHUB_REPOSITORY" \ + --title="$tag" \ + --generate-notes diff --git a/.github/scripts/install-prereq.sh b/.github/scripts/install-prereq.sh new file mode 100755 index 0000000..e2bd846 --- /dev/null +++ b/.github/scripts/install-prereq.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +set -e + +. .github/scripts/util.sh + +mkdir -p $X11_BUILD_DIR +cd $X11_BUILD_DIR + +if [ "$X11_OS" = "Linux" ]; then +build_meson drm https://gitlab.freedesktop.org/mesa/drm libdrm-2.4.121 "" \ + -Domap=enabled +fi +build_meson libxcvt https://gitlab.freedesktop.org/xorg/lib/libxcvt libxcvt-0.1.0 +build_ac xorgproto https://gitlab.freedesktop.org/xorg/proto/xorgproto xorgproto-2024.1 diff --git a/.github/scripts/ubuntu/install-pkg.sh b/.github/scripts/ubuntu/install-pkg.sh new file mode 100755 index 0000000..0cdaf88 --- /dev/null +++ b/.github/scripts/ubuntu/install-pkg.sh @@ -0,0 +1,94 @@ +#!/bin/bash + +set -e + +# Packages which are needed by this script, but not for the xserver build +EPHEMERAL=" + libexpat-dev + libgles2-mesa-dev + libxkbcommon-dev + x11-utils + x11-xserver-utils + xauth + xvfb +" + +apt-get update + +apt-get install -y \ + $EPHEMERAL \ + autoconf \ + automake \ + build-essential \ + ca-certificates \ + libaudit-dev \ + libbsd-dev \ + libcairo2-dev \ + libdbus-1-dev \ + libdrm-dev \ + libegl1-mesa-dev \ + libepoxy-dev \ + libevdev2 \ + libexpat1 \ + libffi-dev \ + libgbm-dev \ + libgcrypt-dev \ + libgl1-mesa-dev \ + libgles2 \ + libglx-mesa0 \ + libinput10 \ + libinput-dev \ + libnvidia-egl-wayland-dev \ + libpciaccess-dev \ + libpixman-1-dev \ + libspice-protocol-dev \ + libsystemd-dev \ + libudev-dev \ + libunwind-dev \ + libx11-dev \ + libx11-xcb-dev \ + libxau-dev \ + libxaw7-dev \ + libxcb-glx0-dev \ + libxcb-icccm4-dev \ + libxcb-image0-dev \ + libxcb-keysyms1-dev \ + libxcb-randr0-dev \ + libxcb-render-util0-dev \ + libxcb-render0-dev \ + libxcb-shape0-dev \ + libxcb-shm0-dev \ + libxcb-util0-dev \ + libxcb-xf86dri0-dev \ + libxcb-xkb-dev \ + libxcb-xv0-dev \ + libxcb1-dev \ + libxdmcp-dev \ + libxext-dev \ + libxfixes-dev \ + libxfont-dev \ + libxi-dev \ + libxinerama-dev \ + libxkbcommon0 \ + libxkbfile-dev \ + libxmu-dev \ + libxmuu-dev \ + libxpm-dev \ + libxrender-dev \ + libxres-dev \ + libxshmfence-dev \ + libxt-dev \ + libxtst-dev \ + libxv-dev \ + mesa-common-dev \ + meson \ + nettle-dev \ + libpango1.0-dev \ + pkg-config \ + x11-xkb-utils \ + xfonts-utils \ + xkb-data \ + xtrans-dev \ + xutils-dev \ + libxaw7-dev \ + python3-mako diff --git a/.github/scripts/util.sh b/.github/scripts/util.sh new file mode 100644 index 0000000..dea16ae --- /dev/null +++ b/.github/scripts/util.sh @@ -0,0 +1,85 @@ + +. .github/scripts/conf.sh + +clone_source() { + local pkgname="$1" + local url="$2" + local ref="$3" + local commit="$4" + + if [ ! -f $pkgname/.git/config ]; then + echo "need to clone $pkgname" + if [ "$commit" ]; then + git clone $url $pkgname --branch=$ref + else + git clone $url $pkgname --branch=$ref --depth 1 + fi + else + echo "already cloned $pkgname" + fi + + if [ "$commit" ]; then + ( cd $pkgname && git checkout -f "$commit" ) + fi +} + +build_meson() { + local pkgname="$1" + local url="$2" + local ref="$3" + local commit="$4" + shift + shift + shift + shift || true + if [ -f $X11_PREFIX/$pkgname.DONE ]; then + echo "package $pkgname already built" + else + clone_source "$pkgname" "$url" "$ref" "$commit" + ( + cd $pkgname + meson "$@" build -Dprefix=$X11_PREFIX + ninja -j${FDO_CI_CONCURRENT:-4} -C build install + ) + touch $X11_PREFIX/$pkgname.DONE + fi +} + +build_ac() { + local pkgname="$1" + local url="$2" + local ref="$3" + local commit="$4" + shift + shift + shift + shift || true + if [ -f $X11_PREFIX/$pkgname.DONE ]; then + echo "package $pkgname already built" + else + clone_source "$pkgname" "$url" "$ref" "$commit" + ( + cd $pkgname + ./autogen.sh --prefix=$X11_PREFIX + make -j${FDO_CI_CONCURRENT:-4} install + ) + touch $X11_PREFIX/$pkgname.DONE + fi +} + +build_drv_ac() { + local pkgname="$1" + local url="$2" + local ref="$3" + local commit="$4" + shift + shift + shift + shift || true + clone_source "$pkgname" "$url" "$ref" "$commit" + ( + cd $pkgname + ./autogen.sh # --prefix=$X11_PREFIX + make -j${FDO_CI_CONCURRENT:-4} # install + ) +} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..23644b0 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,43 @@ +name: Build driver + +permissions: + contents: write + +env: + MESON_BUILDDIR: "build" + X11_PREFIX: /home/runner/x11 + X11_BUILD_DIR: /home/runner/build-deps + +on: + push: + pull_request: + +jobs: + for-xserver-stable-25_0: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/build-driver + with: + xserver-version: xlibre-xserver-25.0.0.5 + + for-xserver-master: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/build-driver + with: + xserver-version: master + + release: + name: Release pushed tag + runs-on: ubuntu-latest + if: ${{ startsWith(github.ref, 'refs/tags/xlibre-') }} + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Create release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ github.ref_name }} + run: .github/scripts/github/make-release