From 2c52adc8e8fb7e69237eda5559634153e28bd2b9 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sat, 6 Apr 2024 23:11:32 +0200 Subject: [PATCH] CI: expand functionality of build.sh Make it easier to "just do the nightly build" in a Docker setting by passing the name of the workflow to the script. --- CONTRIBUTING.md | 7 ++++++- ci/build.sh | 30 ++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 36199a5ca..a73f90589 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -154,10 +154,15 @@ dependencies for the image (in this example, for openSUSE and Qt6). - `./ci/deps-opensuse-qt6.sh` Then run CMake (add any CMake options you like at the end) and ninja. -There is a script `ci/build.sh` that does this, too (without options). - `cmake -S /src -B /build -G Ninja` - `ninja -C /build` +There is a script `ci/build.sh` that does the CMake an ninja steps. +- If you set `CMAKE_ARGS` in the environment those extra CMake options are used. +- If you add an argument to the script command which names a workflow + (e.g. "nightly-opensuse-qt6") then `CMAKE_ARGS` are extracted from that + workflow and used for the build. + ### Running in Docker To run Calamares inside the container, or e.g. `loadmodule` to test diff --git a/ci/build.sh b/ci/build.sh index 60b3bc7ca..7108f9d1d 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -5,6 +5,36 @@ # - BUILDDIR (e.g. /build) # - CMAKE_ARGS (e.g. "-DWITH_QT6=ON -DCMAKE_BUILD_TYPE=Debug") # +# If SRCDIR is not set, it is assumed to be the directory above +# wherever this script is being run from (this script is in ci/). +# +# If BUILDDIR is not set, and /build exists (e.g. in the recommended +# Docker setup) then /build is used. +# +# If CMAKE_ARGS is not set, but the script is given an argument +# that exists as a workflow (e.g. "nightly-opensuse-qt6" or +# "nightly-debian.yml") and yq is installed, then the CMAKE_ARGS +# are extracted from that workflow file. +# +# Summary, pick one: +# - set environment variables, run "build.sh" +# - set no variables, run "build.sh " + +if test -z "$SRCDIR" ; then + _d=$(dirname "$0" ) + _d=$(dirname "$_d" ) + test -f "$_d/CMakeLists.txt" && SRCDIR="$_d" +fi +if test -z "$BUILDDIR" ; then + test -d "/build" && BUILDDIR=/build +fi +if test -z "$CMAKE_ARGS" -a -n "$1" ; then + test -x "$(which yq)" || { echo "! No yq command for finding CMAKE_ARGS for workflow $1" ; exit 1 ; } + _d="$SRCDIR/.github/workflows/$1" + test -f "$_d" || _d="$SRCDIR/.github/workflows/$1.yml" + test -f "$_d" || { echo "! No workflow $1" ; exit 1 ; } + CMAKE_ARGS=$(yq ".env.CMAKE_ARGS" "$_d") +fi # Sanity check test -n "$BUILDDIR" || { echo "! \$BUILDDIR not set" ; exit 1 ; }