Return-Path: X-Original-To: apmail-accumulo-notifications-archive@minotaur.apache.org Delivered-To: apmail-accumulo-notifications-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6D56B18440 for ; Thu, 21 Jan 2016 23:17:40 +0000 (UTC) Received: (qmail 52901 invoked by uid 500); 21 Jan 2016 23:17:40 -0000 Delivered-To: apmail-accumulo-notifications-archive@accumulo.apache.org Received: (qmail 52852 invoked by uid 500); 21 Jan 2016 23:17:40 -0000 Mailing-List: contact notifications-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jira@apache.org Delivered-To: mailing list notifications@accumulo.apache.org Received: (qmail 52839 invoked by uid 99); 21 Jan 2016 23:17:40 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 21 Jan 2016 23:17:40 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id ED12B2C1F55 for ; Thu, 21 Jan 2016 23:17:39 +0000 (UTC) Date: Thu, 21 Jan 2016 23:17:39 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: notifications@accumulo.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (ACCUMULO-4109) Make build.sh create branches MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/ACCUMULO-4109?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15111584#comment-15111584 ] ASF GitHub Bot commented on ACCUMULO-4109: ------------------------------------------ Github user ctubbsii commented on a diff in the pull request: https://github.com/apache/accumulo/pull/64#discussion_r50480577 --- Diff: assemble/build.sh --- @@ -15,134 +15,266 @@ # See the License for the specific language governing permissions and # limitations under the License. -loc=`dirname "$0"` -loc=`cd "$loc/.."; pwd` +cd "$(dirname "$0")/.." +scriptname=$(basename "$0") -cd "$loc" - -fail() { - echo ' ' $@ - exit 1 +# check if running in a color terminal +terminalSupportsColor() { + local c; c=$(tput colors 2>/dev/null) || c=-1 + [[ -t 1 ]] && [[ $c -ge 8 ]] } +terminalSupportsColor && doColor=1 || doColor=0 -run() { - echo $@ - eval $@ - if [ $? -ne 0 ] - then - fail $@ fails - fi -} +color() { local c; c=$1; shift; [[ $doColor -eq 1 ]] && echo -e '\e[0;'$c'm'$@'\e[0m' || echo $@; } +red() { color 31 $@; } +green() { color 32 $@; } +yellow() { color 33 $@; } -runAt() { - ( cd $1 ; echo in `pwd`; shift ; run $@ ) || fail -} +fail() { echo -e ' ' $@; exit 1; } +runLog() { local o; o=$1 && shift && echo $(green Running) $(yellow $@ '>>' $o) && echo Running $@ >> $o && eval $@ >> $o; } +run() { echo $(green Running) $(yellow $@) && eval $@; } +runOrFail() { run $@ || fail $(yellow $@) $(red failed); } + +currentBranch() { local b; b=$(git symbolic-ref -q HEAD) && echo ${b##refs/heads/}; } cacheGPG() { # make sure gpg agent has key cached # TODO prompt for key instead of using default? - TESTFILE="/tmp/${USER}-gpgTestFile-$(date -u +%s).txt" - touch "${TESTFILE}" && gpg --sign "${TESTFILE}" && rm -f "${TESTFILE}" "${TESTFILE}.gpg" + local TESTFILE; TESTFILE="/tmp/${USER}-gpgTestFile-$(date -u +%s).txt" + touch "${TESTFILE}" && gpg2 --sign "${TESTFILE}" && rm -f "${TESTFILE}" "${TESTFILE}.gpg" } +prompter() { + # $1 description; $2 pattern to validate against + local x + read -p "Enter the $1: " x + until eval "[[ \$x =~ ^$2\$ ]]"; do + echo ' ' $(red $x) is not a proper $1 1>&2 + read -p "Enter the $1: " x + done + echo $x +} + +pretty() { local f; f=$1; shift; git log --pretty=format:$f $@; } +gitCommits() { pretty %H $@; } +gitCommit() { gitCommits -n1 $@; } +gitSubject() { pretty %s $@; } + createEmail() { - read -p 'Enter the staging repository number: ' stagingrepo - read -p 'Enter the version to be released (eg. x.y.z): ' tag - read -p 'Enter the release candidate number (eg. 1, 2, etc.): ' rc + local stagingrepo; [[ -n $1 ]] && stagingrepo=$1 || stagingrepo=$(prompter 'staging repository number' '[0-9]+') + local ver; [[ -n $2 ]] && ver=$2 || ver=$(prompter 'version to be released (eg. x.y.z)' '[0-9]+[.][0-9]+[.][0-9]+') + local rc; [[ -n $3 ]] && rc=$3 || rc=$(prompter 'release candidate number (eg. 1, 2, etc.)' '[0-9]+') - commit=$(git show $tag -n1 --pretty=raw --no-color | head -1 | awk '{print $2}') - branch=$tag-rc$rc + local commit; commit=$(gitCommit $ver) + local branch; branch=$ver-rc$rc + local tag; tag=rel/$ver echo - echo "IMPORTANT!! IMPORTANT!! IMPORTANT!! IMPORTANT!! IMPORTANT!! IMPORTANT!!" + yellow "IMPORTANT!! IMPORTANT!! IMPORTANT!! IMPORTANT!! IMPORTANT!! IMPORTANT!!" echo - echo " Don't forget to push a branch named $branch with" - echo " its head at ${commit:0:7} so people can review!" + echo " Don't forget to push a branch named $(green $branch) with" + echo " its head at $(green ${commit:0:7}) so others can review using:" + echo " $(green git push origin ${commit:0:7}:refs/heads/$branch)" echo - echo " However, do *NOT* push the $tag tag until after the vote" - echo " passes and the tag is re-made with a gpg signature using" - echo " \`git tag -f -m 'Apache Accumulo $tag' -s rel/$tag ${commit:0:7}\`" + echo " Remember, $(red DO NOT PUSH) the $(red $tag) tag until after the vote" + echo " passes and the tag is re-made with a gpg signature using:" + echo " $(red git tag -f -m \'Apache Accumulo $ver\' -s $tag ${commit:0:7})" echo - echo "IMPORTANT!! IMPORTANT!! IMPORTANT!! IMPORTANT!! IMPORTANT!! IMPORTANT!!" + yellow "IMPORTANT!! IMPORTANT!! IMPORTANT!! IMPORTANT!! IMPORTANT!! IMPORTANT!!" echo - read -p 'Press Enter to generate the [VOTE] email...' rc + local ignore + read -s -p 'Press Enter to generate the [VOTE] email...' ignore + echo 1>&2 # compute the date with a buffer of 30 minutes - votedate=$(date -d "+3 days 30 minutes" "+%s") + local votedate; votedate=$(date -d "+3 days 30 minutes" "+%s") # round back to the previous half-hour - halfhour=$(($votedate - ($votedate % 1800))) + local halfhour; halfhour=$(($votedate - ($votedate % 1800))) votedate=$(date -u -d"1970-01-01 $halfhour seconds UTC") export TZ="America/New_York" - edtvotedate=$(date -d"1970-01-01 $halfhour seconds UTC") + local edtvotedate; edtvotedate=$(date -d"1970-01-01 $halfhour seconds UTC") export TZ="America/Los_Angeles" - pdtvotedate=$(date -d"1970-01-01 $halfhour seconds UTC") + local pdtvotedate; pdtvotedate=$(date -d"1970-01-01 $halfhour seconds UTC") cat <&2 + + local cBranch + cBranch=$(currentBranch) || fail $(red Failure) to get current branch from git + cacheGPG || fail "Unable to cache GPG credentials into gpg-agent" + + local rc; rc=$(prompter 'release candidate number (eg. 1, 2, etc.)' '[0-9]+') + local rcBranch; rcBranch=$ver-rc$rc + local nBranch; nBranch=$cBranch-$rcBranch-next + + # create working branch + run git branch $nBranch $cBranch && \ + run git checkout $nBranch || + fail "Unable to create working branch $(red $nBranch) from $(red $cBranch)!" + # create a release candidate from a branch - run mvn clean release:clean release:prepare release:perform + local oFile; oFile=/tmp/accumulo-build-$rcBranch.log + rm -f $oFile && \ + runLog $oFile mvn clean release:clean || \ + cleanUpAndFail 'mvn clean release:clean' $oFile $cBranch $nBranch + runLog $oFile mvn -B release:prepare || \ + cleanUpAndFail 'mvn release:prepare' $oFile $cBranch $nBranch + runLog $oFile mvn release:perform || \ + cleanUpAndFail 'mvn release:perform' $oFile $cBranch $nBranch + + # verify the next branch contains both expected log messages and no more + [[ $(gitCommits ${cBranch}..${nBranch} | wc -l) -eq 2 ]] && \ + [[ $(gitCommit ${nBranch}~2) = $(gitCommit ${cBranch}) ]] && \ + [[ $(gitSubject ${nBranch}) =~ ^\[maven-release-plugin\]\ prepare\ for\ next ]] && \ + [[ $(gitSubject ${nBranch}~1) =~ ^\[maven-release-plugin\]\ prepare\ release\ $ver ]] || \ + cleanUpAndFail "verifying that $nBranch contains only logs from release plugin" + + # verify the tag is one behind $nBranch and one ahead of $cBranch + [[ $(gitCommit ${nBranch}~1) = $(gitCommit refs/tags/rel/$ver) ]] || \ + cleanUpAndFail "verifying that ${nBranch}~1 == refs/tags/rel/$ver" + + # remove tag which was created + run git tag -d rel/$ver || \ + cleanUpAndFail "removing unused git tag rel/$ver" + + # create release candidate branch to vote on + run git branch $rcBranch ${nBranch}~1 || \ + cleanUpAndFail "creating branch $rcBranch" + + # push branches (ask first) + local origin; origin=$(git remote -v | grep ^origin | grep push | awk '{print $2}') + echo "Do you wish to push the following branches to origin ($(yellow $origin))?" + echo " $nBranch" + echo " $rcBranch" + local a; a=$(prompter "letter 'y' or 'n'" '[yn]') + [[ $a == 'y' ]] && \ + run git push origin refs/heads/$nBranch refs/heads/$rcBranch || \ + red "Did not push branches; you'll need to perform this step manually." + + # continue to creating email notification + local stagingrepo + stagingrepo=$(<$oFile grep -o 'repository[.]apache[.]org/content/repositories/orgapacheaccumulo-[0-9]*' | tail -1) + stagingrepo=${stagingrepo##*-} + echo $(red Running) $(yellow $scriptname --create-email $stagingrepo $ver $rc) + createEmail $stagingrepo $ver $rc +} + +if [[ $1 = '--create-release-candidate' ]]; then --- End diff -- Maybe. I'll leave the prerequisite checking for a future ticket... there might be others we'd want to encapsulate in that (pdflatex, thrift, etc.). I don't want to wrap maven with a build.sh, which is further wrapped by a ./configure script... getting a bit deep here. (Note: on CentOS/Fedora/RedHat, xmllint is provided by a package, libxml2, that is required for YUM/DNF, so it can't be uninstalled) > Make build.sh create branches > ----------------------------- > > Key: ACCUMULO-4109 > URL: https://issues.apache.org/jira/browse/ACCUMULO-4109 > Project: Accumulo > Issue Type: Task > Components: build > Reporter: Christopher Tubbs > Assignee: Christopher Tubbs > Fix For: 1.6.5, 1.7.1, 1.8.0 > > > To make generating release candidates even easier, the {{build.sh}} script could be improved to automatically create and push branches to vote on (and to delete the local rel/version tag so it doesn't accidentally get pushed). -- This message was sent by Atlassian JIRA (v6.3.4#6332)