Subject: [PATCH 3/8] cirrus: upload changed html docs as artifacts

From: Justin Pryzby <[email-masked]>
Date: Sat, 15 Jan 2022 11:27:28 -0600

Always run doc build; to allow them to be shown in cfbot, they should not be
skipped if the linux build fails.

This could be done on the client side (cfbot).  One advantage of doing it here
is that fewer docs are uploaded - many patches won't upload docs at all.

https://cirrus-ci.com/task/5396696388599808

ci-os-only: linux
---
 .cirrus.yml | 43 +++++++++++++++++++++++++++++++------------
 1 file changed, 31 insertions(+), 12 deletions(-)

diff --git a/.cirrus.yml b/.cirrus.yml
index 2d023a31d2d..39021804cfa 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -455,10 +455,6 @@ task:
 task:
   name: CompilerWarnings
 
-  # To limit unnecessary work only run this once the normal linux test succeeds
-  depends_on:
-    - Linux - Debian Bullseye
-
   env:
     CPUS: 4
     BUILD_JOBS: 4
@@ -487,6 +483,13 @@ task:
     clang -v
     export
 
+    git remote -v
+    git branch -a
+    git remote add postgres https://github.com/postgres/postgres
+    time git fetch -v postgres master
+    git log -1 postgres/master
+    git diff --name-only postgres/master..
+
   ccache_cache:
     folder: $CCACHE_DIR
 
@@ -558,16 +561,32 @@ task:
   ###
   # 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
+      # Do nothing if the patch doesn't update doc:
+      git diff --name-only --cherry-pick --exit-code postgres/master... doc && exit
+  
+      # Exercise HTML and other docs:
+      ./configure >/dev/null
+      make -s -C doc
+      cp -a doc new-docs
+  
+      # Build HTML docs from the parent commit
+      git checkout postgres/master -- doc
+      make -s -C doc clean
+      make -s -C doc html
+      cp -a doc old-docs
+  
+      # Copy HTML which differ into html_docs
+      mkdir html_docs
+      cp new-docs/src/sgml/html/*.css new-docs/src/sgml/html/*.svg html_docs/
+      for f in `git diff --no-index --name-only old-docs/src/sgml/html new-docs/src/sgml/html`
+      do
+        cp $f html_docs/
+      done
+
+    html_docs_artifacts:
+      paths: ['html_docs/**/*.html', 'html_docs/**/*.png', 'html_docs/**/*.css']
 
   always:
     upload_caches: ccache
-- 
2.17.1

--4e5ZDkbgLEOfWmLx
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="0004-s-build-docs-as-a-separate-task.patch"