CI: Add tests for onf-make

Since this is a library of makefiles, standard code tests can't be
implemented. Instead, this change introduces modified versions of
build & test jobs for other repos, which are kicked off by pushes
to onf-make, and test those builds with the change to the onf-make
library.

Signed-off-by: Eric Ball <eball@linuxfoundation.org>
Change-Id: I1e40e2a49996c5a04f0d5bc6cba7a0eb603ed8e5
diff --git a/vars/getVolthaCode.groovy b/vars/getVolthaCode.groovy
index aecb30d..4230b9e 100644
--- a/vars/getVolthaCode.groovy
+++ b/vars/getVolthaCode.groovy
@@ -76,8 +76,8 @@
             'voltha-helm-charts',
         ]
 
-        // We are always downloading those repos, if the patch under test is in one of those
-        // just checkout the patch, no need to clone it again
+        // We are always downloading those repos, if the patch under test is in
+        // one of those just checkout the patch, no need to clone it again
         if (cfg.gerritProject == '')
         {
             // Revisit:
@@ -88,6 +88,36 @@
             // checkout during an error condition.
             // Case: when cfg= is invalid due to a jenkins hiccup.
         }
+        else if (params.GERRIT_PROJECT == "onf-make")
+        {
+            // When testing onf-make, the tests are kicked off from the onf-make
+            // repo, so the GERRIT_PROJECT and GERRIT_PATCHSET_REVISION params
+            // will carry the data of what we want the submodule to be.
+            // However, the gerritProject is overridden, so that we can pull
+            // in another repo and run the tests to make sure that they work
+            // with the code changes to onf-make.
+            repo_project = "https://gerrit.opencord.org/${cfg.gerritProject}"
+
+            checkout([
+                $class: 'GitSCM',
+                userRemoteConfigs: [[ url:repo_project ]],
+                branches: [[ name: "${cfg.branch}", ]],
+                extensions: [
+                    [$class: 'WipeWorkspace'],
+                    [$class: 'RelativeTargetDirectory', relativeTargetDir: "${cfg.gerritProject}"],
+                    [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
+                    submodule(recursiveSubmodules: true, reference: "${params.GERRIT_PATCHSET_REVISION}"),
+                ],
+            ])
+
+            sh("""pushd $WORKSPACE/${cfg.gerritProject}
+                  git fetch "$repo_project" ${cfg.gerritRefspec} && git checkout FETCH_HEAD
+
+                  echo "Currently on commit: \n"
+                  git log -1 --oneline
+                  popd
+               """)
+        }
         else if (!(cfg.gerritProject in frequent_repos))
         {
             repo_project = "https://gerrit.opencord.org/${cfg.gerritProject}"
@@ -103,14 +133,13 @@
                 ],
             ])
 
-            sh("""
-        pushd $WORKSPACE/${cfg.gerritProject}
-        git fetch "$repo_project" ${cfg.gerritRefspec} && git checkout FETCH_HEAD
+            sh("""pushd $WORKSPACE/${cfg.gerritProject}
+                  git fetch "$repo_project" ${cfg.gerritRefspec} && git checkout FETCH_HEAD
 
-        echo "Currently on commit: \n"
-        git log -1 --oneline
-        popd
-      """)
+                  echo "Currently on commit: \n"
+                  git log -1 --oneline
+                  popd
+               """)
         }
     }