|
| 1 | +#!/bin/bash -e |
| 2 | +# -------------------------------------------------------------------------------- |
| 3 | +# Package : alerting |
| 4 | +# -------------------------------------------------------------------------------- |
| 5 | +# Version : 3.5.0.0 |
| 6 | +# Source repo : https://github.com/opensearch-project/alerting |
| 7 | +# Tested on : UBI 9.6 |
| 8 | +# Language : Java |
| 9 | +# Ci-Check : True |
| 10 | +# Script License : Apache License, Version 2 or later |
| 11 | +# Maintainer : Shubhada Salunkhe <Shubhada.salunkhe@ibm.com> |
| 12 | +# |
| 13 | +# Disclaimer : This script has been tested in root mode on given |
| 14 | +# ========== platform using the mentioned version of the package. |
| 15 | +# It may not work as expected with newer versions of the |
| 16 | +# package and/or distribution. In such case, please |
| 17 | +# contact "Maintainer" of this script. |
| 18 | +# -------------------------------------------------------------------------------- |
| 19 | + |
| 20 | +# --------------------------- |
| 21 | +# Configuration |
| 22 | +# --------------------------- |
| 23 | +PACKAGE_NAME="alerting" |
| 24 | +PACKAGE_ORG="opensearch-project" |
| 25 | +PACKAGE_VERSION="3.5.0.0" |
| 26 | +PACKAGE_URL="https://github.com/${PACKAGE_ORG}/${PACKAGE_NAME}.git" |
| 27 | +SCRIPT_PATH=$(dirname $(realpath $0)) |
| 28 | +RUNTESTS=1 |
| 29 | +BUILD_HOME="$(pwd)" |
| 30 | + |
| 31 | +# ------------------- |
| 32 | +# Parse CLI Arguments |
| 33 | +# ------------------- |
| 34 | +for i in "$@"; do |
| 35 | + case $i in |
| 36 | + --skip-tests) |
| 37 | + RUNTESTS=0 |
| 38 | + echo "Skipping tests" |
| 39 | + shift |
| 40 | + ;; |
| 41 | + -*|--*) |
| 42 | + echo "Unknown option $i" |
| 43 | + exit 3 |
| 44 | + ;; |
| 45 | + *) |
| 46 | + PACKAGE_VERSION=$i |
| 47 | + echo "Building ${PACKAGE_NAME} ${PACKAGE_VERSION}" |
| 48 | + ;; |
| 49 | + esac |
| 50 | +done |
| 51 | + |
| 52 | + |
| 53 | +# --------------------------- |
| 54 | +# Dependency Installation |
| 55 | +# --------------------------- |
| 56 | +sudo yum install -y git wget gcc gcc-c++ make cmake \ |
| 57 | + python3 python3-devel \ |
| 58 | + openssl-devel bzip2-devel zlib-devel \ |
| 59 | + java-25-openjdk-devel |
| 60 | + |
| 61 | +export JAVA_HOME=/usr/lib/jvm/java-25-openjdk |
| 62 | +export PATH=$JAVA_HOME/bin:$PATH |
| 63 | + |
| 64 | +sudo chown -R test_user:test_user /home/tester |
| 65 | + |
| 66 | +# --------------------------- |
| 67 | +# Clone and Prepare Repository |
| 68 | +# --------------------------- |
| 69 | +cd "${BUILD_HOME}" |
| 70 | +git clone "${PACKAGE_URL}" |
| 71 | +cd "${PACKAGE_NAME}" |
| 72 | +git checkout "${PACKAGE_VERSION}" |
| 73 | + |
| 74 | +git apply ${SCRIPT_PATH}/${PACKAGE_ORG}-${PACKAGE_NAME}_${PACKAGE_VERSION}.patch |
| 75 | + |
| 76 | +# -------- |
| 77 | +# Build |
| 78 | +# -------- |
| 79 | +ret=0 |
| 80 | +./gradlew clean assemble || ret=$? |
| 81 | +if [ $ret -ne 0 ]; then |
| 82 | + set +ex |
| 83 | + echo "------------------ ${PACKAGE_NAME}: Build Failed ------------------" |
| 84 | + echo "$PACKAGE_NAME | $PACKAGE_URL | $PACKAGE_VERSION | $OS_NAME | GitHub | Fail | Build_Fails" |
| 85 | + exit 1 |
| 86 | +fi |
| 87 | + |
| 88 | +export OPENSEARCH_ALERTING_ZIP=${BUILD_HOME}/${PACKAGE_NAME}/alerting/build/distributions/opensearch-alerting-3.5.0.0-SNAPSHOT.zip |
| 89 | + |
| 90 | +# --------------------------- |
| 91 | +# Skip Tests? |
| 92 | +# --------------------------- |
| 93 | +if [ "$RUNTESTS" -eq 0 ]; then |
| 94 | + set +ex |
| 95 | + echo "------------------ Complete: Build successful! Tests skipped ------------------" |
| 96 | + exit 0 |
| 97 | +fi |
| 98 | + |
| 99 | +# ---------- |
| 100 | +# Unit Test |
| 101 | +# ---------- |
| 102 | +ret=0 |
| 103 | +env -i PATH=/usr/bin:/bin JAVA_HOME=$JAVA_HOME ./gradlew test \ |
| 104 | + -x :alerting:compileKotlin \ |
| 105 | + -x :alerting:compileTestKotlin || ret=$? |
| 106 | + |
| 107 | +if [ $ret -ne 0 ]; then |
| 108 | + set +ex |
| 109 | + echo "------------------ ${PACKAGE_NAME}: Unit Test Failed ------------------" |
| 110 | + echo "$PACKAGE_NAME | $PACKAGE_URL | $PACKAGE_VERSION | $OS_NAME | GitHub | Fail | Unit_Test_Fails" |
| 111 | + exit 2 |
| 112 | +fi |
| 113 | + |
| 114 | + |
| 115 | +# --------------------------- |
| 116 | +# Success |
| 117 | +# --------------------------- |
| 118 | +set +ex |
| 119 | +echo "Complete: Build and Tests successful!" |
| 120 | +echo "$PACKAGE_NAME | $PACKAGE_URL | $PACKAGE_VERSION | $OS_NAME | GitHub | Pass | Both_Install_and_Test_Success" |
| 121 | +echo "Plugin zip available at [${OPENSEARCH_ALERTING_ZIP}]" |
| 122 | + |
0 commit comments