From 43e18ed9eb328b4703ad3d8cb95d7d4b6140db89 Mon Sep 17 00:00:00 2001
From: Nazir Bilal Yavuz <byavuz81@gmail.com>
Date: Thu, 7 Sep 2023 17:58:06 +0300
Subject: [PATCH v1 1/2] Only built the docs if there are changes are in the
 docs

Building the docs triggered although there are no changes in the docs.
So, the new 'Building the Docs' task is created. This task only
run if a specific OS is not requested and if there are changes in docs
or in the CI files.
---
 .cirrus.tasks.yml | 67 ++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 52 insertions(+), 15 deletions(-)

diff --git a/.cirrus.tasks.yml b/.cirrus.tasks.yml
index e137769850d..21e276beb3b 100644
--- a/.cirrus.tasks.yml
+++ b/.cirrus.tasks.yml
@@ -740,21 +740,6 @@ task:
       make -s -j${BUILD_JOBS} clean
       time make -s -j${BUILD_JOBS} world-bin
 
-  ###
-  # Verify docs can be built
-  ###
-  # XXX: Only do this if there have been changes in doc/ since last build
-  always:
-    docs_build_script: |
-      time ./configure \
-        --cache gcc.cache \
-        CC="ccache gcc" \
-        CXX="ccache g++" \
-        CLANG="ccache clang"
-      make -s -j${BUILD_JOBS} clean
-      time make -s -j${BUILD_JOBS} -C doc
-
-  ###
   # Verify headerscheck / cpluspluscheck succeed
   #
   # - Don't use ccache, the files are uncacheable, polluting ccache's
@@ -777,3 +762,55 @@ task:
 
   always:
     upload_caches: ccache
+
+
+task:
+  name: Build the Docs
+  depends_on: SanityCheck
+  # Only run if a specific OS is not requested and if there are changes in docs
+  # or in the CI files.
+  skip: $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:.*' || !changesInclude('doc/**', '.cirrus.yml', '.cirrus.tasks.yml')
+
+  env:
+    CPUS: 4
+    BUILD_JOBS: 4
+    IMAGE_FAMILY: pg-ci-bullseye
+    CCACHE_MAXSIZE: "10M"
+    CCACHE_DIR: "/tmp/ccache_dir"
+
+    LINUX_CONFIGURE_FEATURES: *LINUX_CONFIGURE_FEATURES
+    LINUX_MESON_FEATURES: *LINUX_MESON_FEATURES
+
+  <<: *linux_task_template
+
+  sysinfo_script: |
+    id
+    uname -a
+    cat /proc/cmdline
+    ulimit -a -H && ulimit -a -S
+    gcc -v
+    clang -v
+    export
+
+  ccache_cache:
+    folder: $CCACHE_DIR
+
+  setup_additional_packages_script: |
+    #apt-get update
+    #DEBIAN_FRONTEND=noninteractive apt-get -y install ...
+
+  setup_script: echo "COPT=-Werror" > src/Makefile.custom
+
+  # Verify docs can be built
+  always:
+    docs_build_script: |
+      time ./configure \
+        --cache gcc.cache \
+        CC="ccache gcc" \
+        CXX="ccache g++" \
+        CLANG="ccache clang"
+      make -s -j${BUILD_JOBS} clean
+      time make -s -j${BUILD_JOBS} -C doc
+
+  always:
+    upload_caches: ccache
-- 
2.40.1

