Skip to content

Commit

Permalink
RATIS-1819. Use Maven Wrapper in CI workflows (#859)
Browse files Browse the repository at this point in the history
  • Loading branch information
tisonkun authored Mar 21, 2023
1 parent 050dc44 commit 5a8bdef
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 17 deletions.
2 changes: 1 addition & 1 deletion dev-support/checks/_mvn_unit_report.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ for failed_test in $(< ${REPORT_DIR}/summary.txt); do
done

## Check if Maven was killed
if grep -q 'Killed.* mvn .* test ' "${REPORT_DIR}/output.log"; then
if grep -q "Killed.* ${MVN} .* test " "${REPORT_DIR}/output.log"; then
echo 'Maven test run was killed' >> "${REPORT_DIR}/summary.txt"
fi

Expand Down
4 changes: 3 additions & 1 deletion dev-support/checks/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd "$DIR/../.." || exit 1

source "${DIR}/../find_maven.sh"

export MAVEN_OPTS="-Xmx4096m"
mvn -V -B -Dmaven.javadoc.skip=true -DskipTests clean install "$@"
${MVN} -V -B -Dmaven.javadoc.skip=true -DskipTests clean install "$@"
exit $?
6 changes: 4 additions & 2 deletions dev-support/checks/checkstyle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd "$DIR/../.." || exit 1

source "${DIR}/../find_maven.sh"

BASE_DIR="$(pwd -P)"
REPORT_DIR=${OUTPUT_DIR:-"$DIR/../../target/checkstyle"}
mkdir -p "$REPORT_DIR"
Expand All @@ -24,10 +26,10 @@ REPORT_FILE="$REPORT_DIR/summary.txt"
MAVEN_OPTIONS='-B -fae -Dcheckstyle.failOnViolation=false'

declare -i rc
mvn ${MAVEN_OPTIONS} checkstyle:check | tee "${REPORT_DIR}/output.log"
${MVN} ${MAVEN_OPTIONS} checkstyle:check | tee "${REPORT_DIR}/output.log"
rc=$?
if [[ ${rc} -ne 0 ]]; then
mvn ${MAVEN_OPTIONS} clean test-compile checkstyle:check
${MVN} ${MAVEN_OPTIONS} clean test-compile checkstyle:check
rc=$?
mkdir -p "$REPORT_DIR" # removed by mvn clean
else
Expand Down
6 changes: 4 additions & 2 deletions dev-support/checks/findbugs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd "$DIR/../.." || exit 1

source "${DIR}/../find_maven.sh"

MAVEN_OPTIONS='-B -fae'

if ! type unionBugs >/dev/null 2>&1 || ! type convertXmlToText >/dev/null 2>&1; then
#shellcheck disable=SC2086
mvn ${MAVEN_OPTIONS} test-compile spotbugs:check
${MVN} ${MAVEN_OPTIONS} test-compile spotbugs:check
exit $?
fi

#shellcheck disable=SC2086
mvn ${MAVEN_OPTIONS} test-compile spotbugs:spotbugs
${MVN} ${MAVEN_OPTIONS} test-compile spotbugs:spotbugs
rc=$?

REPORT_DIR=${OUTPUT_DIR:-"$DIR/../../target/findbugs"}
Expand Down
4 changes: 3 additions & 1 deletion dev-support/checks/rat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd "$DIR/../.." || exit 1

source "${DIR}/../find_maven.sh"

REPORT_DIR=${OUTPUT_DIR:-"$DIR/../../target/rat"}
mkdir -p "$REPORT_DIR"

REPORT_FILE="$REPORT_DIR/summary.txt"

mvn -B -fn org.apache.rat:apache-rat-plugin:0.13:check
${MVN} -B -fn org.apache.rat:apache-rat-plugin:0.13:check

cd "$DIR/../.." || exit 1

Expand Down
5 changes: 4 additions & 1 deletion dev-support/checks/sonar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
cd "$DIR/../.." || exit 1

source "${DIR}/../find_maven.sh"

if [ ! "$SONAR_TOKEN" ]; then
echo "SONAR_TOKEN environment variable should be set"
exit 1
fi
mvn -B verify -DskipShade -DskipTests org.sonarsource.scanner.maven:sonar-maven-plugin:3.6.0.1398:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=apache -Dsonar.projectKey=apache-ratis

${MVN} -B verify -DskipShade -DskipTests org.sonarsource.scanner.maven:sonar-maven-plugin:3.6.0.1398:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=apache -Dsonar.projectKey=apache-ratis
4 changes: 3 additions & 1 deletion dev-support/checks/unit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ set -o pipefail
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd "$DIR/../.." || exit 1

source "${DIR}/../find_maven.sh"

: ${ITERATIONS:="1"}

declare -i ITERATIONS
Expand All @@ -39,7 +41,7 @@ for i in $(seq 1 ${ITERATIONS}); do
mkdir -p "${REPORT_DIR}"
fi

mvn -B -fae test "$@" \
${MVN} -B -fae test "$@" \
| tee "${REPORT_DIR}/output.log"
irc=$?

Expand Down
30 changes: 30 additions & 0 deletions dev-support/find_maven.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/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.

function find_maven() {
if [ "$MAVEN" != "" ]; then
echo "${MAVEN}"
else
local DIR
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
( cd "$DIR/.." || exit 1 ; echo "$( pwd -P )/mvnw" )
fi
}

MVN="$( find_maven )"
export MVN
10 changes: 4 additions & 6 deletions dev-support/make_rc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,15 @@
# Presumes your settings.xml all set up so can sign artifacts published to mvn, etc.
set -e
# Set mvn and mvnopts
mvn=mvn
if [ "$MAVEN" != "" ]; then
mvn="${MAVEN}"
fi
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
source "${DIR}/find_maven.sh"
mvnopts="-Xmx1g"
if [ "$MAVEN_OPTS" != "" ]; then
mvnopts="${MAVEN_OPTS}"
fi

mvnGet() {
${mvn} -q -Dexec.executable="echo" -Dexec.args="\${${1}}" --non-recursive \
${MVN} -q -Dexec.executable="echo" -Dexec.args="\${${1}}" --non-recursive \
org.codehaus.mojo:exec-maven-plugin:1.6.0:exec 2>/dev/null
}

Expand Down Expand Up @@ -90,7 +88,7 @@ fi


mvnFun() {
MAVEN_OPTS="${mvnopts}" ${mvn} -Dmaven.repo.local="${repodir}" "$@"
MAVEN_OPTS="${mvnopts}" ${MVN} -Dmaven.repo.local="${repodir}" "$@"
}

prepare-src() {
Expand Down
6 changes: 4 additions & 2 deletions dev-support/run-test-repeatedly.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ fi
TEST_PATTERN=$1
TEST_NAME=`echo ${TEST_PATTERN} | cut -d# -f 1`

MVN="mvn"
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
source "${DIR}/find_maven.sh"

set -ex

mvn clean
${MVN} clean

for i in `seq 1 99`;
do
Expand Down

0 comments on commit 5a8bdef

Please sign in to comment.