yetus-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject yetus git commit: YETUS-77. add bugzilla support
Date Thu, 29 Oct 2015 14:59:26 GMT
Repository: yetus
Updated Branches:
  refs/heads/master d1a27cc41 -> 417c3564a


YETUS-77. add bugzilla support

Signed-off-by: Allen Wittenauer <aw@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/yetus/repo
Commit: http://git-wip-us.apache.org/repos/asf/yetus/commit/417c3564
Tree: http://git-wip-us.apache.org/repos/asf/yetus/tree/417c3564
Diff: http://git-wip-us.apache.org/repos/asf/yetus/diff/417c3564

Branch: refs/heads/master
Commit: 417c3564a4326d192d9f96aa4353cc82675b1284
Parents: d1a27cc
Author: Allen Wittenauer <aw@apache.org>
Authored: Thu Oct 15 10:17:49 2015 -0700
Committer: Allen Wittenauer <aw@apache.org>
Committed: Thu Oct 29 07:59:09 2015 -0700

----------------------------------------------------------------------
 .../latest/precommit-bugsystems.md              |  36 +++++
 precommit/test-patch.d/bugzilla.sh              | 154 +++++++++++++++++++
 2 files changed, 190 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/yetus/blob/417c3564/asf-site-src/source/documentation/latest/precommit-bugsystems.md
----------------------------------------------------------------------
diff --git a/asf-site-src/source/documentation/latest/precommit-bugsystems.md b/asf-site-src/source/documentation/latest/precommit-bugsystems.md
index 46f5111..823dce6 100644
--- a/asf-site-src/source/documentation/latest/precommit-bugsystems.md
+++ b/asf-site-src/source/documentation/latest/precommit-bugsystems.md
@@ -49,3 +49,39 @@ add_bugsystem <pluginname>
 * pluginname\_finalreport
 
     - Write the final result table to the bug system.
+
+# Bugzilla Specific
+
+Currently, Bugzilla support is read-only.  To use it, the Bug ID must be preferenced with
'BZ:'.  For example:
+
+```bash
+$ test-patch.sh (other options) BZ:4
+```
+
+... will pull down Bugzilla ID #4.
+
+Using the `--bugzilla-base-url` on the command line or BUGZILLA\_BASE\_URL in a project's
personality will define the location of the Bugzilla instance.  By default, it is https://bz.apache.org/bugzilla
.
+
+# GitHub Specific
+
+GitHub supports the full range of functionality, including putting comments on individual
lines.  Be aware, however, that test-patch.sh will require that GitHub PRs be fully rebased
(i.e., a single commit) in many circumstances.
+
+By default, the GitHub plug-in assumes that https://github.com is the base URL for GitHub.
 Enterprise users may override this with the `--github-base-url` for the normal web user interface
and `--github-api-url` for the API URL.  Personalities may use GITHUB\_API\_URL and GITHUB\_BASE\_URL.
+
+The specific repository on GitHub is defined with either `--github-repo` on the command line
or GITHUB\_REPO in a personality.  It should take the form of "user/repo".
+
+In order to comment on issues or, depending upon the security setup of the repo, authentication
credentials.  The GitHub plug-in supports two types:
+
+  * Token-based:  `--github-token` or GITHUB\_TOKEN
+
+  * Username/password: `--github-user`/ GITHUB\_USER , `--github-password` / GITHUB\_PASSWD
+
+Pull requests that are made off of a specific branch will switch the test repo to that branch,
if permitted.  If the pull request references a JIRA issue that matches the given JIRA issue
regexp in the Subject, the JIRA plug-in will also be invoked as needed.
+
+# JIRA Specific
+
+JIRA support allows both patch downloads and summary writes.  It also supports branch detection-based
upon the name of the attached patch file.
+
+JIRA issues are invoked by matching the command line option to a specific regular expression
as given by the `--jira-issue-re` option or via the JIRA\_ISSUE\_RE personality variable.
 By default, the plug-in uses https://issues.apache.org/jira as the JIRA instance to use.
 However that may be overwritten via the `--jira-base-url` option or personalities may define
via JIRA\_URL.
+
+In order to write information on the issue, JIRA requires username and password authentication
using the `--jira-user`/`--jira-password` options or the JIRA\_USER and JIRA\_PASSWORD variables
in a personality.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/yetus/blob/417c3564/precommit/test-patch.d/bugzilla.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.d/bugzilla.sh b/precommit/test-patch.d/bugzilla.sh
new file mode 100755
index 0000000..2ca4395
--- /dev/null
+++ b/precommit/test-patch.d/bugzilla.sh
@@ -0,0 +1,154 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+add_bugsystem bugzilla
+
+# personalities can override the following settings:
+BUGZILLA_BASE_URL="https://bz.apache.org/bugzilla"
+
+function bugzilla_usage
+{
+  echo "Bugzilla Options:"
+  echo "--bugzilla-base-url=<url>  The URL of the bugzilla server"
+}
+
+function bugzilla_parse_args
+{
+  declare i
+
+  for i in "$@"; do
+    case ${i} in
+      --bugzilla-base-url=*)
+        BUGZILLA_BASE_URL=${i#*=}
+      ;;
+    esac
+  done
+}
+
+function bugzilla_determine_issue
+{
+  declare input=$1
+  declare patchnamechunk
+  declare maybeissue
+
+  if [[ ! "${input}" =~ ^BZ: ]]; then
+    return 1
+  fi
+
+  if [[ -n "${BUGZILLA_ISSUE}" ]]; then
+    return 0
+  fi
+
+  # shellcheck disable=SC2016
+  BUGZILLA_ISSUE=$(echo "${input}" | cut -f2 -d: )
+
+  # shellcheck disable=SC2034
+  ISSUE=${input}
+  add_footer_table "Bugzilla Issue" "${BUGZILLA_ISSUE}"
+  return 0
+}
+
+## @description  Try to guess the branch being tested using a variety of heuristics
+## @audience     private
+## @stability    evolving
+## @replaceable  no
+## @return       0 on success, with PATCH_BRANCH updated appropriately
+## @return       1 on failure
+function bugzilla_determine_branch
+{
+  return 1
+}
+
+function bugzilla_http_fetch
+{
+  declare input=$1
+  declare output=$2
+
+  if [[ -z "${BUGZILLA_BASE_URL}" ]]; then
+    return 1
+  fi
+
+  ${CURL} --silent --fail \
+          --output "${output}" \
+          --location \
+         "${BUGZILLA_BASE_URL}/${input}"
+}
+
+
+function bugzilla_locate_patch
+{
+  declare input=$1
+  declare fileloc=$2
+  declare relativeurl
+
+  if [[ -z "${BUGZILLA_BASE_URL}" ]]; then
+    return 1
+  fi
+
+  bugzilla_determine_issue "${input}"
+  if [[ $? != 0 || -z "${BUGZILLA_ISSUE}" ]]; then
+    return 1
+  fi
+
+  yetus_debug "bugzilla_locate_patch: trying ${BUGZILLA_BASE_URL}/show_bug.cgi?id=${BUGZILLA_ISSUE}"
+
+  if [[ "${OFFLINE}" == true ]]; then
+    yetus_debug "bugzilla_locate_patch: offline, skipping"
+    return 1
+  fi
+
+  bugzilla_http_fetch "show_bug.cgi?id=${BUGZILLA_ISSUE}" "${PATCH_DIR}/bugzilla"
+
+  if [[ $? != 0 ]]; then
+    yetus_debug "bugzilla_locate_patch: not a Bugzilla."
+    return 1
+  fi
+
+  #shellcheck disable=SC2016
+  relativeurl=$(${AWK} '/action=diff/ && match($0,"attachment\.cgi.id=[0-9]*"){print
substr($0,RSTART,RLENGTH)}' \
+           "${PATCH_DIR}/bugzilla" | \
+        tail -1)
+  PATCHURL="${BUGZILLA_BASE_URL}${relativeurl}"
+  #relativeurl="${relativeurl}&action=diff&context=patch&collapsed=&headers=1&format=raw"
+  echo "${input} patch is being downloaded at $(date) from"
+  echo "${PATCHURL}"
+  add_footer_table "Bugzilla Patch URL" "${PATCHURL}"
+  bugzilla_http_fetch "${relativeurl}" "${fileloc}"
+  if [[ $? != 0 ]];then
+    yetus_error "ERROR: ${input}/${PATCHURL} could not be downloaded."
+    cleanup_and_exit 1
+  fi
+  return 0
+}
+
+## @description Write the contents of a file to Bugzilla
+## @params filename
+## @stability stable
+## @audience public
+function bugzilla_write_comment
+{
+  return 0
+}
+
+## @description  Print out the finished details to Bugzilla
+## @audience     private
+## @stability    evolving
+## @replaceable  no
+## @param        runresult
+function bugzilla_finalreport
+{
+  return 0
+}


Mime
View raw message