You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@yetus.apache.org by aw...@apache.org on 2020/10/03 02:50:11 UTC

[yetus] branch main updated: YETUS-940. Update for Semaphore CI 2.0 (#143)

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

aw pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/yetus.git


The following commit(s) were added to refs/heads/main by this push:
     new 4c7d648  YETUS-940. Update for Semaphore CI 2.0 (#143)
4c7d648 is described below

commit 4c7d64806a3170c933c03f52950693eeea9ced0b
Author: Allen Wittenauer <aw...@apache.org>
AuthorDate: Fri Oct 2 19:50:04 2020 -0700

    YETUS-940. Update for Semaphore CI 2.0 (#143)
---
 precommit/src/main/shell/robots.d/semaphoreci.sh | 24 +++++++++++++++++++---
 precommit/src/main/shell/test-patch.d/github.sh  | 26 ------------------------
 2 files changed, 21 insertions(+), 29 deletions(-)

diff --git a/precommit/src/main/shell/robots.d/semaphoreci.sh b/precommit/src/main/shell/robots.d/semaphoreci.sh
index 628048a..592c99d 100755
--- a/precommit/src/main/shell/robots.d/semaphoreci.sh
+++ b/precommit/src/main/shell/robots.d/semaphoreci.sh
@@ -24,14 +24,26 @@ if [[ "${CI}" = true ]] && [[ "${SEMAPHORE}" = true ]] &&
   ROBOT=true
   ROBOTTYPE=semaphoreci
   INSTANCE=${SEMAPHORE_JOB_ID}
-  BUILDMODE=full
 
   if [[ -e ${SEMAPHORE_GIT_DIR}/.git ]]; then
     BASEDIR=${SEMAPHORE_GIT_DIR}
   fi
 
-  PATCH_OR_ISSUE=GHSHA:${SEMAPHORE_GIT_SHA}
-  USER_PARAMS+=("GHSHA:${SEMAPHORE_GIT_SHA}")
+  case "${SEMAPHORE_GIT_REF_TYPE}" in
+    branch)
+      BUILDMODE=full
+      USER_PARAMS+=("--empty-patch")
+      PATCH_BRANCH=${SEMAPHORE_GIT_BRANCH}
+      ;;
+    tag)
+      BUILDMODE=full
+      USER_PARAMS+=("--empty-patch")
+      PATCH_BRANCH=${SEMAPHORE_GIT_TAG}
+      ;;
+    pull-request)
+      PATCH_OR_ISSUE="GH:${SEMAPHORE_GIT_PR_NUMBER}"
+      ;;
+  esac
 
   yetus_add_array_element EXEC_MODES SemaphoreCI
   yetus_add_array_element EXEC_MODES ResetRepo
@@ -41,10 +53,16 @@ if [[ "${CI}" = true ]] && [[ "${SEMAPHORE}" = true ]] &&
   add_docker_env \
     CI \
     SEMAPHORE \
+    SEMAPHORE_GIT_BRANCH \
     SEMAPHORE_GIT_DIR \
+    SEMAPHORE_GIT_PR_NUMBER \
+    SEMAPHORE_GIT_REF_TYPE \
     SEMAPHORE_GIT_SHA \
+    SEMAPHORE_GIT_TAG \
     SEMAPHORE_GIT_URL \
     SEMAPHORE_JOB_ID
+
+  GITHUB_REPO=${SEMAPHORE_GIT_REPO_SLUG}
 fi
 
 function semaphoreci_set_plugin_defaults
diff --git a/precommit/src/main/shell/test-patch.d/github.sh b/precommit/src/main/shell/test-patch.d/github.sh
index 9356f3f..32ccb29 100755
--- a/precommit/src/main/shell/test-patch.d/github.sh
+++ b/precommit/src/main/shell/test-patch.d/github.sh
@@ -428,32 +428,6 @@ function github_locate_sha_patch
   number=${number//\s}
   number=${number%,}
 
-  # Semaphore CI doesn't tell us if the sha is a PR or not, so...
-  if [[ -z "${number}" ]]; then
-     if [[ "${ROBOTTYPE}" = semaphoreci ]]; then
-
-      echo "This appears to be a full build on Semaphore CI. Switching modes."
-
-      PATCH_BRANCH=${SEMAPHORE_GIT_BRANCH}
-
-      # shellcheck disable=SC2034
-      PATCH_OR_ISSUE=""
-      # shellcheck disable=SC2034
-      BUILDMODE=full
-      add_docker_env BUILDMODE
-      set_buildmode
-      return 0
-    else
-      # shellcheck disable=SC2034
-      PATCH_OR_ISSUE=""
-      # shellcheck disable=SC2034
-      BUILDMODE=full
-      add_docker_env BUILDMODE
-      set_buildmode
-      return 0
-    fi
-  fi
-
   github_locate_pr_patch "GH:${number}" "${patchout}" "${diffout}"
 }