From fbda8ea2e75fd220825a5ea9fbdd5831832e094c Mon Sep 17 00:00:00 2001 From: Alex Huszagh Date: Sat, 7 Sep 2024 19:59:42 -0500 Subject: [PATCH] Add CI for CMake. --- .github/workflows/cmake.yml | 22 ++++++++++++++++++ scripts/cmake.sh | 46 +++++++++++++++++++++++++++++++++++++ scripts/headless.sh | 10 ++++++++ 3 files changed, 78 insertions(+) create mode 100644 .github/workflows/cmake.yml create mode 100644 scripts/cmake.sh diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml new file mode 100644 index 0000000..f3c9cf7 --- /dev/null +++ b/.github/workflows/cmake.yml @@ -0,0 +1,22 @@ +name: CMake + +on: [push, pull_request] + +jobs: + cmake: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install dependencies + shell: bash + run: | + sudo apt-get update + sudo apt-get install xvfb + sudo apt-get install build-essential libgl1-mesa-dev libgstreamer-gl1.0-0 libpulse-dev \ + libxcb-glx0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 \ + libxcb-render0 libxcb-shape0 libxcb-shm0 libxcb-sync1 libxcb-util1 libxcb-xfixes0 \ + libxcb-xinerama0 libxcb1 libxkbcommon-dev libxkbcommon-x11-0 libxcb-xkb-dev cmake + sudo apt install qt6-base-dev qt6-svg-dev qtbase5-dev libqt5svg5 + - name: Running our CMake flow. + run: | + scripts/cmake.sh diff --git a/scripts/cmake.sh b/scripts/cmake.sh new file mode 100644 index 0000000..581ea13 --- /dev/null +++ b/scripts/cmake.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash +# +# Run custom CMake build script which auto-downloads, +# builds, and then uses the compiled code in an application. +# sudo apt-get update +# sudo apt-get install xvfb +# sudo apt-get install build-essential libgl1-mesa-dev libgstreamer-gl1.0-0 libpulse-dev \ +# libxcb-glx0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 \ +# libxcb-render0 libxcb-shape0 libxcb-shm0 libxcb-sync1 libxcb-util1 libxcb-xfixes0 \ +# libxcb-xinerama0 libxcb1 libxkbcommon-dev libxkbcommon-x11-0 libxcb-xkb-dev cmake +# sudo apt install qt6-base-dev qt6-svg-dev qtbase5-dev libqt5svg5 + +set -eux pipefail + +scripts_home="$(dirname "$(realpath "${BASH_SOURCE[0]}")")" +project_home="$(dirname "${scripts_home}")" +build_dir="${project_home}/dist/build" + +mkdir -p "${build_dir}/"{qt5,qt6} + +# we xcb installed for our headless running, so exit if we don't have it +if ! hash xvfb-run &>/dev/null; then + >&2 echo "Do not have xvfb installed..." + exit 1 +fi + +# first, try Qt5 +# NOTE: Since we're using `-e`, we need to specially +# capture the error code immediately. +export QT_QPA_PLATFORM=offscreen +cd "${build_dir}/qt5" +cmake ../../example/cmake -D QT_VERSION=Qt5 +make -j +timeout 1 xvfb-run -a ./testing || error_code=$? +if [[ "${error_code}" != 124 ]]; then + exit "${error_code}" +fi + +# first, try Qt6 +cd "${build_dir}/qt6" +cmake ../../example/cmake -D QT_VERSION=Qt6 +make -j +timeout 1 xvfb-run -a ./testing || error_code=$? +if [[ "${error_code}" != 124 ]]; then + exit "${error_code}" +fi diff --git a/scripts/headless.sh b/scripts/headless.sh index 1c8dd37..35b10d6 100755 --- a/scripts/headless.sh +++ b/scripts/headless.sh @@ -8,6 +8,16 @@ # - PySide6 # And if using Python 3.10 or earlier: # - PySide2 +# +# On Ubuntu, this requires the following install logic: +# python -m pip install --upgrade pip +# pip install PySide2 PySide6 PyQt5 PyQt6 +# sudo apt-get update +# sudo apt-get install xvfb +# sudo apt-get install build-essential libgl1-mesa-dev libgstreamer-gl1.0-0 libpulse-dev \ +# libxcb-glx0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 \ +# libxcb-render0 libxcb-shape0 libxcb-shm0 libxcb-sync1 libxcb-util1 libxcb-xfixes0 \ +# libxcb-xinerama0 libxcb1 libxkbcommon-dev libxkbcommon-x11-0 libxcb-xkb-dev set -eux pipefail