You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2022/09/07 03:53:29 UTC

[couchdb] 01/02: Update pull request jenkinsfile to shortcut building docs

This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a commit to branch integrate-docs-2
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 29a97f5daf21da5dd064d19d3b282e4b77cc183f
Author: Nick Vatamaniuc <va...@apache.org>
AuthorDate: Fri Sep 2 01:01:45 2022 -0400

    Update pull request jenkinsfile to shortcut building docs
    
    If docs are changed then docs "check" is run If only docs changed and
    not other files, then only docs are built and other stages are
    "fast-forwarded".
    
    Also, remove docs from gitignore and from rebar.config.
---
 .gitignore               |   1 -
 build-aux/Jenkinsfile.pr | 103 ++++++++++++++++++++++++++++++++++++++++++++++-
 rebar.config.script      |   4 +-
 3 files changed, 103 insertions(+), 5 deletions(-)

diff --git a/.gitignore b/.gitignore
index 4a02f57ce..518ec7b19 100644
--- a/.gitignore
+++ b/.gitignore
@@ -50,7 +50,6 @@ src/couch/priv/couch_ejson_compare/couch_ejson_compare.d
 src/couch/priv/couch_js/**/*.d
 src/couch/priv/icu_driver/couch_icu_driver.d
 src/mango/src/mango_cursor_text.nocompile
-src/docs/
 src/ets_lru/
 src/excoveralls/
 src/fauxton/
diff --git a/build-aux/Jenkinsfile.pr b/build-aux/Jenkinsfile.pr
index db0d095d0..f97648719 100644
--- a/build-aux/Jenkinsfile.pr
+++ b/build-aux/Jenkinsfile.pr
@@ -26,6 +26,35 @@ make check || (make build-report && false)
 
 pipeline {
 
+   // Cache some git diff shell results so we don't have to run them
+   // for every stage
+   def boolean docsChangedCached = null
+   def boolean onlyDocsChangedCached = null
+
+   def boolean docsChanged() {
+     if (docsChangedCached != null) {
+         return docsChangedCached
+     }
+     boolean result = sh(
+       returnStatus: true,
+       script: "git diff --name-only origin/${env.CHANGE_TARGET} | grep -q '^src/docs/'"
+     ) == 0
+     docsChangedCached = result
+     return result
+   }
+
+   def boolean onlyDocsChanged() {
+     if (onlyDocsChangedCached != null) {
+         return onlyDocsChangedCached
+     }
+     boolean result = docsChanged() && (sh(
+       returnStatus: true,
+       script: "git diff --name-only origin/${env.CHANGE_TARGET} | grep -q -v '^src/docs/'"
+     ) == 1)
+     onlyDocsChangedCached = result
+     return result
+  }
+
   // no top-level agent; agents must be declared for each stage
   agent none
 
@@ -61,7 +90,78 @@ pipeline {
 
   stages {
 
+    stage('Docs Check') {
+      // Run docs `make check` stage if any docs changed
+      when { expression { return docsChanged() } }
+      agent {
+          docker {
+            image "${DOCKER_IMAGE}"
+            label 'docker'
+            args "${DOCKER_ARGS}"
+            registryUrl 'https://docker.io/'
+            registryCredentialsId 'dockerhub_creds'
+          }
+      }
+      options {
+        timeout(time: 15, unit: 'MINUTES')
+      }
+      steps {
+        sh '''
+          (cd src/docs && make check)
+        '''
+      }
+      post {
+        cleanup {
+          // UGH see https://issues.jenkins-ci.org/browse/JENKINS-41894
+          sh 'rm -rf ${WORKSPACE}/*'
+        }
+      }
+    } // Docs Check
+
+    stage('Build Docs') {
+      // Build docs separately if only docs changed. If there are other changes, docs are
+      // already built as part of `make dist`
+      when { expression { return onlyDocsChanged() } }
+      matrix {
+        axes {
+          axis {
+            name 'TARGET'
+            values "html", "man"
+          }
+        }
+        stages {
+          stage('Doc Test') {
+
+            agent {
+              docker {
+                image "${DOCKER_IMAGE}"
+                label 'docker'
+                args "${DOCKER_ARGS}"
+                registryUrl 'https://docker.io/'
+                registryCredentialsId 'dockerhub_creds'
+              }
+            }
+            options {
+              timeout(time: 90, unit: 'MINUTES')
+            }
+            steps {
+              sh '''
+                (cd src/docs && make ${TARGET})
+              '''
+            }
+            post {
+              cleanup {
+                // UGH see https://issues.jenkins-ci.org/browse/JENKINS-41894
+                sh 'rm -rf ${WORKSPACE}/*'
+              }
+            }
+          } // stage
+        } // stages
+      } // matrix
+    } // stage "Build Docs"
+
     stage('erlfmt') {
+      when { expression { return ! onlyDocsChanged() } }
       agent {
         docker {
           image "${DOCKER_IMAGE_BASE}-${LOW_ERLANG_VER}"
@@ -92,6 +192,7 @@ pipeline {
 
 
     stage('Build Release Tarball') {
+      when { expression { return ! onlyDocsChanged() } }
       agent {
         docker {
           image "${DOCKER_IMAGE_BASE}-${LOW_ERLANG_VER}"
@@ -129,7 +230,7 @@ pipeline {
     // https://issues.jenkins-ci.org/browse/JENKINS-48050
 
     stage('Make Check') {
-
+      when { expression { return ! onlyDocsChanged() } }
       matrix {
         axes {
           axis {
diff --git a/rebar.config.script b/rebar.config.script
index fc409c576..b0c2236bc 100644
--- a/rebar.config.script
+++ b/rebar.config.script
@@ -147,9 +147,7 @@ DepDescs = [
 {khash,            "khash",            {tag, "1.1.0"}},
 {snappy,           "snappy",           {tag, "CouchDB-1.0.8"}},
 
-%% Non-Erlang deps
-{docs,             {url, "https://github.com/apache/couchdb-documentation"},
-                   {tag, "3.2.1-1"}, [raw]},
+%% %% Non-Erlang deps
 {fauxton,          {url, "https://github.com/apache/couchdb-fauxton"},
                    {tag, "v1.2.8"}, [raw]},
 %% Third party deps