1*12372530SSteve Rowe#!/usr/bin/env bash 2*12372530SSteve Rowe# Licensed to the Apache Software Foundation (ASF) under one or more 3*12372530SSteve Rowe# contributor license agreements. See the NOTICE file distributed with 4*12372530SSteve Rowe# this work for additional information regarding copyright ownership. 5*12372530SSteve Rowe# The ASF licenses this file to You under the Apache License, Version 2.0 6*12372530SSteve Rowe# (the "License"); you may not use this file except in compliance with 7*12372530SSteve Rowe# the License. You may obtain a copy of the License at 8*12372530SSteve Rowe# 9*12372530SSteve Rowe# http://www.apache.org/licenses/LICENSE-2.0 10*12372530SSteve Rowe# 11*12372530SSteve Rowe# Unless required by applicable law or agreed to in writing, software 12*12372530SSteve Rowe# distributed under the License is distributed on an "AS IS" BASIS, 13*12372530SSteve Rowe# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14*12372530SSteve Rowe# See the License for the specific language governing permissions and 15*12372530SSteve Rowe# limitations under the License. 16*12372530SSteve Rowe 17*12372530SSteve Rowe 18*12372530SSteve Rowe# Invoke Yetus locally to validate a patch against Lucene/Solr, and 19*12372530SSteve Rowe# (optionally) post a validation report comment on the passed-in JIRA issue 20*12372530SSteve Rowe# from which the patch was downloaded. 21*12372530SSteve Rowe# 22*12372530SSteve Rowe# NB 1: The Lucene/Solr Yetus personality currently performs the equivalent 23*12372530SSteve Rowe# of "ant precommit" and "ant test" in modified modules; instead of using 24*12372530SSteve Rowe# this script to test your changes, please consider invoking those targets 25*12372530SSteve Rowe# directly. 26*12372530SSteve Rowe# 27*12372530SSteve Rowe# NB 2: The Jenkins job "PreCommit-Admin" automatically detects new patches 28*12372530SSteve Rowe# posted to LUCENE and SOLR JIRA issues that are in the "Patch Available" 29*12372530SSteve Rowe# state, and then queues the appropriate "PreCommit-LUCENE-Build" or 30*12372530SSteve Rowe# "PreCommit-SOLR-Build" job pointing to the JIRA hosting the new patch. 31*12372530SSteve Rowe# Those jobs perform the same checks as this script, and like this script, 32*12372530SSteve Rowe# will post a comment on the JIRA issue. As a result, manual invocation 33*12372530SSteve Rowe# (e.g. via this script) should ordinarily not be necessary. 34*12372530SSteve Rowe# 35*12372530SSteve Rowe# Environment variable ${YETUS_HOME} must point to the separately installed 36*12372530SSteve Rowe# Yetus home directory, e.g. the "rel/0.7.0" tag checked out from a local 37*12372530SSteve Rowe# Yetus Git repository. 38*12372530SSteve Rowe# 39*12372530SSteve Rowe# Environment variable ${PROJECT_DIR} must point to a local Lucene/Solr git 40*12372530SSteve Rowe# workspace dir. 41*12372530SSteve Rowe# 42*12372530SSteve Rowe# The sole cmdline param can be a JIRA issue, a local patch file, 43*12372530SSteve Rowe# or a URL to a patch file. 44*12372530SSteve Rowe# 45*12372530SSteve Rowe# If the cmdline param is a JIRA issue, the patch to download and validate 46*12372530SSteve Rowe# will be the most recently uploaded patch on the issue. See the patch 47*12372530SSteve Rowe# naming schema that Yetus recognizes: 48*12372530SSteve Rowe# https://yetus.apache.org/documentation/in-progress/precommit-patchnames/ 49*12372530SSteve Rowe# 50*12372530SSteve Rowe# If the cmdline param is a JIRA issue and you provide JIRA user/password via 51*12372530SSteve Rowe# environment variables ${JIRA_USER} and ${JIRA_PASSWORD}, a patch validation 52*12372530SSteve Rowe# report will be posted as a comment on the JIRA issue. 53*12372530SSteve Rowe 54*12372530SSteve Rowehelp () { 55*12372530SSteve Rowe echo "Usage 1: [ JIRA_USER=xxx JIRA_PASSWORD=yyy ] PROJECT_DIR=/path/to/lucene-solr YETUS_HOME=/path/to/yetus $0 SOLR-12345" 56*12372530SSteve Rowe echo "Usage 2: [ JIRA_USER=xxx JIRA_PASSWORD=yyy ] PROJECT_DIR=/path/to/lucene-solr YETUS_HOME=/path/to/yetus $0 LUCENE-12345" 57*12372530SSteve Rowe echo "Usage 3: PROJECT_DIR=/path/to/lucene-solr YETUS_HOME=/path/to/yetus $0 ../local.patch" 58*12372530SSteve Rowe echo "Usage 4: PROJECT_DIR=/path/to/lucene-solr YETUS_HOME=/path/to/yetus $0 http://example.com/remote.patch" 59*12372530SSteve Rowe} 60*12372530SSteve Rowe 61*12372530SSteve Roweif [[ -z "${PROJECT_DIR}" || -z "${YETUS_HOME}" || -z "${1}" || "${1}" =~ ^-(-?h(elp)?|\?)$ ]] ; then 62*12372530SSteve Rowe help 63*12372530SSteve Rowe exit 1 64*12372530SSteve Rowefi 65*12372530SSteve Rowe 66*12372530SSteve RowePATCH_REF=${1} 67*12372530SSteve RoweTEST_PATCH_BIN="${YETUS_HOME}/precommit/test-patch.sh" 68*12372530SSteve RoweSCRIPT_DIR="$( cd "$( dirname "${0}" )" && pwd )" 69*12372530SSteve Rowedeclare -a YETUS_ARGS 70*12372530SSteve Rowe 71*12372530SSteve Roweif [[ ${PATCH_REF} =~ ^(LUCENE|SOLR)- ]]; then 72*12372530SSteve Rowe JIRA_PROJECT=${BASH_REMATCH[0]} 73*12372530SSteve Rowe YETUS_ARGS+=("--project=${JIRA_PROJECT}") 74*12372530SSteve Rowe 75*12372530SSteve Rowe if [[ -n "${JIRA_USER}" ]] && [[ -n "${JIRA_PASSWORD}" ]] ; then 76*12372530SSteve Rowe YETUS_ARGS+=("--jira-user=${JIRA_USER}") 77*12372530SSteve Rowe YETUS_ARGS+=("--jira-password=${JIRA_PASSWORD}") 78*12372530SSteve Rowe YETUS_ARGS+=("--bugcomments=jira") 79*12372530SSteve Rowe fi 80*12372530SSteve Rowefi 81*12372530SSteve Rowe 82*12372530SSteve RoweYETUS_ARGS+=("--basedir=${PROJECT_DIR}") 83*12372530SSteve RoweYETUS_ARGS+=("--personality=${SCRIPT_DIR}/lucene-solr-yetus-personality.sh") 84*12372530SSteve RoweYETUS_ARGS+=("--skip-dirs=dev-tools") 85*12372530SSteve RoweYETUS_ARGS+=("--resetrepo") 86*12372530SSteve RoweYETUS_ARGS+=("--run-tests") 87*12372530SSteve RoweYETUS_ARGS+=("--debug") 88*12372530SSteve RoweYETUS_ARGS+=("--robot") 89*12372530SSteve RoweYETUS_ARGS+=("${PATCH_REF}") 90*12372530SSteve Rowe 91*12372530SSteve Rowe/bin/bash ${TEST_PATCH_BIN} "${YETUS_ARGS[@]}" 92