[ci] Create regression-tester.sh
This commit is contained in:
@ -5,24 +5,7 @@ source .travis/logger.sh
|
||||
source .travis/common-functions.sh
|
||||
source .travis/github-releases-api.sh
|
||||
source .travis/sourceforge-api.sh
|
||||
|
||||
function upload_baseline() {
|
||||
log_info "Generating and uploading baseline for pmdtester..."
|
||||
cd ..
|
||||
bundle config --local gemfile pmd/Gemfile
|
||||
pmd/.travis/travis_wait "bundle exec pmdtester -m single -r ./pmd -p ${TRAVIS_BRANCH} -pc ./pmd/.travis/all-java.xml -l ./pmd/.travis/project-list.xml -f"
|
||||
cd target/reports
|
||||
BRANCH_FILENAME="${TRAVIS_BRANCH/\//_}"
|
||||
zip -q -r ${BRANCH_FILENAME}-baseline.zip ${BRANCH_FILENAME}/
|
||||
../../pmd/.travis/travis_wait "rsync -avh ${BRANCH_FILENAME}-baseline.zip ${PMD_SF_USER}@web.sourceforge.net:/home/frs/project/pmd/pmd-regression-tester/"
|
||||
if [ $? -ne 0 ]; then
|
||||
log_error "Error while uploading ${BRANCH_FILENAME}-baseline.zip to sourceforge!"
|
||||
log_error "Please upload manually: https://sourceforge.net/projects/pmd/files/pmd-regression-tester/"
|
||||
exit 1
|
||||
else
|
||||
log_success "Successfully uploaded ${BRANCH_FILENAME}-baseline.zip to sourceforge"
|
||||
fi
|
||||
}
|
||||
source .travis/regression-tester.sh
|
||||
|
||||
VERSION=$(./mvnw -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.5.0:exec)
|
||||
log_info "Building PMD ${VERSION} on branch ${TRAVIS_BRANCH}"
|
||||
@ -43,16 +26,8 @@ elif travis_isPullRequest; then
|
||||
|
||||
log_info "This is a pull-request build"
|
||||
./mvnw verify $MVN_BUILD_FLAGS
|
||||
(
|
||||
set +e
|
||||
# Create a corresponding remote branch locally
|
||||
if ! git show-ref --verify --quiet refs/heads/${TRAVIS_BRANCH}; then
|
||||
git fetch --no-tags origin +refs/heads/${TRAVIS_BRANCH}:refs/remotes/origin/${TRAVIS_BRANCH}
|
||||
git branch ${TRAVIS_BRANCH} origin/${TRAVIS_BRANCH}
|
||||
fi
|
||||
log_info "Running danger"
|
||||
bundle exec danger --verbose
|
||||
)
|
||||
|
||||
regression-tester_executeDanger
|
||||
|
||||
elif travis_isPush; then
|
||||
|
||||
@ -78,6 +53,8 @@ elif travis_isPush; then
|
||||
sourceforge_uploadFile "${VERSION}" "pmd-dist/target/pmd-src-${VERSION}.zip"
|
||||
sourceforge_selectDefault "${VERSION}"
|
||||
|
||||
regression-tester_uploadBaseline
|
||||
|
||||
elif [[ "${VERSION}" == *-SNAPSHOT ]]; then
|
||||
log_info "This is a snapshot build"
|
||||
./mvnw deploy -Possrh,sign $MVN_BUILD_FLAGS
|
||||
@ -86,6 +63,8 @@ elif travis_isPush; then
|
||||
sourceforge_uploadFile "${VERSION}" "pmd-dist/target/pmd-bin-${VERSION}.zip"
|
||||
sourceforge_uploadFile "${VERSION}" "pmd-dist/target/pmd-src-${VERSION}.zip"
|
||||
|
||||
regression-tester_uploadBaseline
|
||||
|
||||
else
|
||||
# other build. Can happen during release: the commit with a non snapshot version is built, but not from the tag.
|
||||
log_info "This is some other build, probably during release: commit with a non-snapshot version on branch master..."
|
||||
@ -94,13 +73,6 @@ elif travis_isPush; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
(
|
||||
# disable fast fail, exit immediately, in this subshell
|
||||
set +e
|
||||
|
||||
upload_baseline
|
||||
)
|
||||
|
||||
else
|
||||
log_info "This is neither a pull request nor a push. Not executing any build."
|
||||
exit 1
|
||||
|
79
.travis/regression-tester.sh
Normal file
79
.travis/regression-tester.sh
Normal file
@ -0,0 +1,79 @@
|
||||
#
|
||||
# The functions here require the following scripts:
|
||||
# .travis/logger.sh
|
||||
#
|
||||
# The functions here require the following environment variables:
|
||||
# PMD_SF_USER
|
||||
|
||||
#
|
||||
# Generate a new baseline and upload it to sourceforge
|
||||
#
|
||||
# Note: this function always succeeds, even if the upload fails.
|
||||
# In that case, just a error logging is provided.
|
||||
#
|
||||
function regression-tester_uploadBaseline() {
|
||||
log_debug "$FUNCNAME branch=${TRAVIS_BRANCH}"
|
||||
local targetUrl="https://sourceforge.net/projects/pmd/files/pmd-regression-tester/"
|
||||
|
||||
local errexitstate="$(shopt -po errexit)"
|
||||
set +e # disable errexit
|
||||
(
|
||||
# This handler is called if any command fails
|
||||
function upload_failed() {
|
||||
log_error "Error while uploading ${BRANCH_FILENAME}-baseline.zip to sourceforge!"
|
||||
log_error "Please upload manually: ${targetUrl}"
|
||||
}
|
||||
|
||||
# exit subshell after trap
|
||||
set -e
|
||||
trap upload_failed ERR
|
||||
|
||||
log_info "Generating and uploading baseline for pmdtester..."
|
||||
cd ..
|
||||
bundle config --local gemfile pmd/Gemfile
|
||||
pmd/.travis/travis_wait "bundle exec pmdtester -m single -r ./pmd -p ${TRAVIS_BRANCH} -pc ./pmd/.travis/all-java.xml -l ./pmd/.travis/project-list.xml -f"
|
||||
cd target/reports
|
||||
BRANCH_FILENAME="${TRAVIS_BRANCH/\//_}"
|
||||
zip -q -r ${BRANCH_FILENAME}-baseline.zip ${BRANCH_FILENAME}/
|
||||
../../pmd/.travis/travis_wait "rsync -avh ${BRANCH_FILENAME}-baseline.zip ${PMD_SF_USER}@web.sourceforge.net:/home/frs/project/pmd/pmd-regression-tester/"
|
||||
log_success "Successfully uploaded ${BRANCH_FILENAME}-baseline.zip to ${targetUrl}"
|
||||
)
|
||||
# restore errexit state
|
||||
eval "$errexitstate"
|
||||
}
|
||||
|
||||
#
|
||||
# Execute danger, which executes pmd-regression-tester (via Dangerfile).
|
||||
#
|
||||
# Note: this function always succeeds, even if the danger fails.
|
||||
# In that case, just a error logging is provided.
|
||||
#
|
||||
function regression-tester_executeDanger() {
|
||||
log_debug "$FUNCNAME"
|
||||
|
||||
local errexitstate="$(shopt -po errexit)"
|
||||
set +e # disable errexit
|
||||
(
|
||||
# This handler is called if any command fails
|
||||
function danger_failed() {
|
||||
log_error "Error while executing danger/pmd-regression-tester"
|
||||
}
|
||||
|
||||
# exit subshell after trap
|
||||
set -e
|
||||
trap danger_failed ERR
|
||||
|
||||
# Create a corresponding remote branch locally
|
||||
if ! git show-ref --verify --quiet refs/heads/${TRAVIS_BRANCH}; then
|
||||
git fetch --no-tags origin +refs/heads/${TRAVIS_BRANCH}:refs/remotes/origin/${TRAVIS_BRANCH}
|
||||
git branch ${TRAVIS_BRANCH} origin/${TRAVIS_BRANCH}
|
||||
log_debug "Created local branch ${TRAVIS_BRANCH}"
|
||||
fi
|
||||
|
||||
log_info "Running danger on branch ${TRAVIS_BRANCH}"
|
||||
bundle exec danger --verbose
|
||||
log_success "Executing danger successfully"
|
||||
)
|
||||
# restore errexit state
|
||||
eval "$errexitstate"
|
||||
}
|
Reference in New Issue
Block a user