From 958c5092091db1f50aff84f95c5223decfa8d994 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Tue, 22 May 2018 19:29:35 +0200 Subject: [PATCH 1/6] [ci] Upload the generated documentation to pmd.sourceforge.net as well --- .travis/release.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis/release.sh b/.travis/release.sh index ef99737da7..6d543c4c00 100755 --- a/.travis/release.sh +++ b/.travis/release.sh @@ -76,5 +76,9 @@ mkdir pmd.github.io git push origin master ) +echo -e "\n\nUploading the new release to pmd.sourceforge.net which serves as an archive...\n\n" +travis_wait rsync -ah --stats pmd-doc-${VERSION}/ ${PMD_SF_USER}@web.sourceforge.net:/home/project-web/pmd/htdocs/pmd-${VERSION}/ + + fi From ac9f0ac1d4e54d16f76bc3ec521f1d01ba17f52f Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Tue, 22 May 2018 20:29:13 +0200 Subject: [PATCH 2/6] [ci] Add colors, don't fail the build/release if upload to sourceforge fails --- .travis/build-coveralls.sh | 19 ++++++++++++--- .travis/build-deploy.sh | 45 ++++++++++++++++++++++++---------- .travis/build-doc.sh | 48 ++++++++++++++++++++++++++----------- .travis/build-sonar.sh | 19 ++++++++++++--- .travis/colors.sh | 18 ++++++++++++++ .travis/release.sh | 49 +++++++++++++++++++++++++++++++------- 6 files changed, 157 insertions(+), 41 deletions(-) create mode 100644 .travis/colors.sh diff --git a/.travis/build-coveralls.sh b/.travis/build-coveralls.sh index 674918d9c3..a0819f1262 100755 --- a/.travis/build-coveralls.sh +++ b/.travis/build-coveralls.sh @@ -2,9 +2,10 @@ set -e source .travis/common-functions.sh +source .travis/colors.sh VERSION=$(./mvnw -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.5.0:exec | tail -1) -echo "Building PMD Coveralls.io report ${VERSION} on branch ${TRAVIS_BRANCH}" +echo_yellow "[ INFO] Building PMD Coveralls.io report ${VERSION} on branch ${TRAVIS_BRANCH}" if ! travis_isPush; then echo "Not proceeding, since this is not a push!" @@ -16,5 +17,17 @@ fi # coveralls plugin seems to need java.xml.bind module echo "MAVEN_OPTS='-Xms1g -Xmx1g --add-modules java.se.ee'" > ${HOME}/.mavenrc -./mvnw clean install -DskipTests=true -Dmaven.javadoc.skip=true -B -V -./mvnw test jacoco:report coveralls:report -Pcoveralls -B -V +( + # disable fast fail, exit immediately, in this subshell + set +e + + ./mvnw clean install -DskipTests=true -Dmaven.javadoc.skip=true -B -V + ./mvnw test jacoco:report coveralls:report -Pcoveralls -B -V + + if [ $? -ne 0 ]; then + echo_red "[ERROR] Error creating coveralls report" + else + echo_green "[ INFO] New coveralls result: https://coveralls.io/github/pmd/pmd" + fi + true +) diff --git a/.travis/build-deploy.sh b/.travis/build-deploy.sh index babe7ed903..8c7e047c71 100755 --- a/.travis/build-deploy.sh +++ b/.travis/build-deploy.sh @@ -2,12 +2,13 @@ set -e source .travis/common-functions.sh +source .travis/colors.sh function push_docs() { if git diff --quiet docs; then - echo "No changes in docs..." + echo_yellow "[ INFO] No changes in docs..." else - echo "Found changes in docs..." + echo_yellow "[ INFO] Found changes in docs..." if [ "$TRAVIS_BRANCH" == "master" ]; then git config user.name "Travis CI (pmd-bot)" @@ -15,45 +16,63 @@ function push_docs() { git add -A docs git commit -m "Update documentation" git push git@github.com:pmd/pmd.git HEAD:master + echo_green "[ INFO] Successfully pushed docs update" else - echo "Not on master branch, won't commit+push" + echo_yellow "[ INFO] Not on master branch, won't commit+push" fi fi } VERSION=$(./mvnw -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.5.0:exec | tail -1) -echo "Building PMD ${VERSION} on branch ${TRAVIS_BRANCH}" +echo_yellow "[ INFO] Building PMD ${VERSION} on branch ${TRAVIS_BRANCH}" MVN_BUILD_FLAGS="-B -V" if travis_isPullRequest; then - echo "This is a pull-request build" + echo_yellow "[ INFO] This is a pull-request build" ./mvnw verify $MVN_BUILD_FLAGS elif travis_isPush; then if [[ "${VERSION}" != *-SNAPSHOT && "${TRAVIS_TAG}" != "" ]]; then - echo "This is a release build for tag ${TRAVIS_TAG}" + echo -e "\n\n" + echo_green "[ INFO] This is a release build for tag ${TRAVIS_TAG}" + echo -e "\n\n" ./mvnw deploy -Possrh,pmd-release $MVN_BUILD_FLAGS elif [[ "${VERSION}" == *-SNAPSHOT ]]; then - echo "This is a snapshot build" + echo_yellow "[ INFO] This is a snapshot build" ./mvnw deploy -Possrh $MVN_BUILD_FLAGS push_docs else # other build. Can happen during release: the commit with a non snapshot version is built, but not from the tag. - echo "This is some other build, probably during release: commit with a non-snapshot version on branch master..." - ./mvnw verify -Possrh $MVN_BUILD_FLAGS + echo_yellow "[ INFO] This is some other build, probably during release: commit with a non-snapshot version on branch master..." + ./mvnw verify $MVN_BUILD_FLAGS # we stop here - no need to execute further steps exit 0 fi - # Uploading pmd distribution to sourceforge - rsync -avh pmd-dist/target/pmd-*-${VERSION}.zip ${PMD_SF_USER}@web.sourceforge.net:/home/frs/project/pmd/pmd/${VERSION}/ - rsync -avh docs/pages/release_notes.md ${PMD_SF_USER}@web.sourceforge.net:/home/frs/project/pmd/pmd/${VERSION}/ReadMe.md + ( + # disable fast fail, exit immediately, in this subshell + set +e + + echo -e "\n\n" + echo_yellow "[ INFO] Uploading pmd distribution to sourceforge..." + rsync -avh pmd-dist/target/pmd-*-${VERSION}.zip ${PMD_SF_USER}@web.sourceforge.net:/home/frs/project/pmd/pmd/${VERSION}/ + if [ $? -ne 0 ]; then + echo_red "[ERROR] Error while uploading pmd-*-${VERSION}.zip to sourceforge!" + echo_red "[ERROR] Please upload manually: https://sourceforge.net/projects/pmd/files/pmd/" + fi + rsync -avh docs/pages/release_notes.md ${PMD_SF_USER}@web.sourceforge.net:/home/frs/project/pmd/pmd/${VERSION}/ReadMe.md + if [ $? -ne 0 ]; then + echo_red "[ERROR] Error while uploading release_notes.md as ReadMe.md to sourceforge!" + echo_red "[ERROR] Please upload manually: https://sourceforge.net/projects/pmd/files/pmd/" + fi + true + ) else - echo "This is neither a pull request nor a push!" + echo_yellow "[ INFO] This is neither a pull request nor a push. Not executing any build." exit 1 fi diff --git a/.travis/build-doc.sh b/.travis/build-doc.sh index 447f7c63fa..bcd44752e4 100755 --- a/.travis/build-doc.sh +++ b/.travis/build-doc.sh @@ -2,38 +2,58 @@ set -e source .travis/common-functions.sh +source .travis/colors.sh VERSION=$(./mvnw -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.5.0:exec | tail -1) -echo "Building PMD Documentation ${VERSION} on branch ${TRAVIS_BRANCH}" +echo_yellow "[ INFO] Building PMD Documentation ${VERSION} on branch ${TRAVIS_BRANCH}" if ! travis_isPush; then - echo "Not building site, since this is not a push!" + echo_yellow "[ INFO] Not building site, since this is not a push!" exit 0 fi pushd docs # run jekyll -echo -e "\n\nBuilding documentation using jekyll...\n\n" +echo -e "\n\n" +echo_yellow "[ INFO] Building documentation using jekyll..." bundle install bundle exec jekyll build # create pmd-doc archive -echo -e "\n\nCreating pmd-doc archive...\n\n" +echo -e "\n\n" +echo_yellow "[ INFO] Creating pmd-doc archive..." mv _site pmd-doc-${VERSION} zip -qr pmd-doc-${VERSION}.zip pmd-doc-${VERSION}/ +( + # disable fast fail, exit immediately, in this subshell + set +e -# Uploading pmd doc distribution to sourceforge -if [[ "${TRAVIS_TAG}" != "" || "${VERSION}" == *-SNAPSHOT ]]; then - echo -e "\n\nUploading pmd-doc archive to sourceforge...\n\n" - rsync -avh pmd-doc-${VERSION}.zip ${PMD_SF_USER}@web.sourceforge.net:/home/frs/project/pmd/pmd/${VERSION}/ -fi + if [[ "${TRAVIS_TAG}" != "" || "${VERSION}" == *-SNAPSHOT ]]; then + echo -e "\n\n" + echo_yellow "[ INFO] Uploading pmd doc distribution to sourceforge..." + rsync -avh pmd-doc-${VERSION}.zip ${PMD_SF_USER}@web.sourceforge.net:/home/frs/project/pmd/pmd/${VERSION}/ + if [ $? -ne 0 ]; then + echo_red "[ERROR] Couldn't upload pmd-doc-${VERSION}.zip!" + echo_red "[ERROR] Please upload manually: https://sourceforge.net/projects/pmd/files/pmd/" + fi + fi + + # rsync site to pmd.sourceforge.net/snapshot + if [[ "${VERSION}" == *-SNAPSHOT && "${TRAVIS_BRANCH}" == "master" ]]; then + echo -e "\n\n" + echo_yellow "[ INFO] Uploading snapshot site to pmd.sourceforge.net/snapshot..." + travis_wait rsync -ah --stats --delete pmd-doc-${VERSION}/ ${PMD_SF_USER}@web.sourceforge.net:/home/project-web/pmd/htdocs/snapshot/ + if [ $? -ne 0 ]; then + echo_red "[ERROR] Couldn't upload the snapshot documentation. It won't be current on http://pmd.sourceforge.net/snapshot/" + else + echo_green "[ INFO] Successfully uploaded snapshot documentation: http://pmd.sourceforge.net/snapshot/" + fi + fi + + true +) -# rsync site to pmd.sourceforge.net/snapshot -if [[ "${VERSION}" == *-SNAPSHOT && "${TRAVIS_BRANCH}" == "master" ]]; then - echo -e "\n\nUploading snapshot site...\n\n" - travis_wait rsync -ah --stats --delete pmd-doc-${VERSION}/ ${PMD_SF_USER}@web.sourceforge.net:/home/project-web/pmd/htdocs/snapshot/ -fi popd diff --git a/.travis/build-sonar.sh b/.travis/build-sonar.sh index 8faf4ca260..a16e90f68b 100755 --- a/.travis/build-sonar.sh +++ b/.travis/build-sonar.sh @@ -2,9 +2,10 @@ set -e source .travis/common-functions.sh +source .travis/colors.sh VERSION=$(./mvnw -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.5.0:exec | tail -1) -echo "Building PMD Sonar ${VERSION} on branch ${TRAVIS_BRANCH}" +echo_yellow "[ INFO] Building PMD Sonar ${VERSION} on branch ${TRAVIS_BRANCH}" if ! travis_isPush; then echo "Not updating sonar, since this is not a push!" @@ -16,5 +17,17 @@ fi # sonar plugin seems to need java.xml.bind module echo "MAVEN_OPTS='-Xms1g -Xmx1g --add-modules java.se.ee'" > ${HOME}/.mavenrc -# Run the build, truncate output due to Travis log limits -./mvnw clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=${SONAR_TOKEN} -B -V +( + # disable fast fail, exit immediately, in this subshell + set +e + + # Run the build + ./mvnw clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=${SONAR_TOKEN} -B -V + + if [ $? -ne 0 ]; then + echo_red "[ERROR] Error updating sonar..." + else + echo_green "[ INFO] New sonar results: https://sonarcloud.io/dashboard?id=net.sourceforge.pmd%3Apmd" + fi + true +) diff --git a/.travis/colors.sh b/.travis/colors.sh new file mode 100644 index 0000000000..7cfb7f8a15 --- /dev/null +++ b/.travis/colors.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +COL_GREEN="\e[32m" +COL_RED="\e[31m" +COL_RESET="\e[0m" +COL_YELLOW="\e[33;1m" + +function echo_red() { + echo -e "${COL_RED}$*${COL_RESET}" +} + +function echo_yellow() { + echo -e "${COL_YELLOW}$*${COL_RESET}" +} + +function echo_green() { + echo -e "${COL_GREEN}$*${COL_RESET}" +} diff --git a/.travis/release.sh b/.travis/release.sh index 6d543c4c00..78e55e17fa 100755 --- a/.travis/release.sh +++ b/.travis/release.sh @@ -1,6 +1,8 @@ #!/bin/bash set -e +source .travis/colors.sh + echo "BUILD: $BUILD" RELEASE_VERSION=$(./mvnw -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.5.0:exec | tail -1) echo "RELEASE_VERSION: $RELEASE_VERSION" @@ -9,10 +11,22 @@ if [ "${BUILD}" = "deploy" ]; then # Deploy to ossrh has already been done with the usual build. See build-deploy.sh -# The site has been built before, the files have already been uploaded to sourceforge. -# Since this is a release, making the binary the new default file... -curl -H "Accept: application/json" -X PUT -d "default=windows&default=mac&default=linux&default=bsd&default=solaris&default=others" \ - -d "api_key=${PMD_SF_APIKEY}" https://sourceforge.net/projects/pmd/files/pmd/${RELEASE_VERSION}/pmd-bin-${RELEASE_VERSION}.zip +( + # disable fast fail, exit immediately, in this subshell + set +e + + # The site has been built before, the files have already been uploaded to sourceforge. + # Since this is a release, making the binary the new default file... + echo_yellow "[ INFO] Selecting pmd-bin-${RELEASE_VERSION} as default on sourceforge.net..." + curl -H "Accept: application/json" -X PUT -d "default=windows&default=mac&default=linux&default=bsd&default=solaris&default=others" \ + -d "api_key=${PMD_SF_APIKEY}" https://sourceforge.net/projects/pmd/files/pmd/${RELEASE_VERSION}/pmd-bin-${RELEASE_VERSION}.zip + if [ $? -ne 0 ]; then + echo_red "[ERROR] Couldn't select latest binary as default on sourceforge.net" + else + echo_green "[ INFO] pmd-bin-${RELEASE_VERSION} is now the default download option." + fi + true +) # Assumes, the release has already been created by travis github releases provider @@ -29,7 +43,7 @@ cat > release-edit-request.json < Date: Tue, 22 May 2018 20:31:45 +0200 Subject: [PATCH 3/6] Update default snapshot documentation url, use github --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a9fca2489d..5226258133 100644 --- a/pom.xml +++ b/pom.xml @@ -270,7 +270,7 @@ Additionally it includes CPD, the copy-paste-detector. CPD finds duplicated code UTF-8 UTF-8 - http://pmd.sourceforge.net/snapshot + https://pmd.github.io/pmd -Xmx512m -Dfile.encoding=${project.build.sourceEncoding} From fef93eec6414472015bce325d38296be130a2d58 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Tue, 22 May 2018 20:40:37 +0200 Subject: [PATCH 4/6] [ci] Add webhooks build notification for gitter --- .travis.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7cd272880c..addd0aa81b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -52,11 +52,17 @@ deploy: after_deploy: bash .travis/release.sh notifications: + webhooks: + urls: + - https://webhooks.gitter.im/e/0e6dd310db54b96c2653 + - https://webhooks.gitter.im/e/65efc1ea65175ad23ab6 + on_success: always # options: [always|never|change] default: always + on_failure: always # options: [always|never|change] default: always + on_start: never # options: [always|never|change] default: always email: recipients: - andreas.dangel@adangel.org - - pmd-commits@lists.sourceforge.net - on_success: always + on_success: change on_failure: always cache: directories: From 281f1511970a6f2c63e8e3985a9a3b902463ac2d Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 24 May 2018 19:18:57 +0200 Subject: [PATCH 5/6] Use log_info, log_error, log_success functions instead of the colors --- .travis/build-coveralls.sh | 6 +++--- .travis/build-deploy.sh | 30 +++++++++++++++--------------- .travis/build-doc.sh | 20 ++++++++++---------- .travis/build-sonar.sh | 6 +++--- .travis/colors.sh | 12 ++++++------ .travis/release.sh | 18 +++++++++--------- 6 files changed, 46 insertions(+), 46 deletions(-) diff --git a/.travis/build-coveralls.sh b/.travis/build-coveralls.sh index a0819f1262..702908533f 100755 --- a/.travis/build-coveralls.sh +++ b/.travis/build-coveralls.sh @@ -5,7 +5,7 @@ source .travis/common-functions.sh source .travis/colors.sh VERSION=$(./mvnw -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.5.0:exec | tail -1) -echo_yellow "[ INFO] Building PMD Coveralls.io report ${VERSION} on branch ${TRAVIS_BRANCH}" +log_info "Building PMD Coveralls.io report ${VERSION} on branch ${TRAVIS_BRANCH}" if ! travis_isPush; then echo "Not proceeding, since this is not a push!" @@ -25,9 +25,9 @@ echo "MAVEN_OPTS='-Xms1g -Xmx1g --add-modules java.se.ee'" > ${HOME}/.mavenrc ./mvnw test jacoco:report coveralls:report -Pcoveralls -B -V if [ $? -ne 0 ]; then - echo_red "[ERROR] Error creating coveralls report" + log_error "Error creating coveralls report" else - echo_green "[ INFO] New coveralls result: https://coveralls.io/github/pmd/pmd" + log_success "New coveralls result: https://coveralls.io/github/pmd/pmd" fi true ) diff --git a/.travis/build-deploy.sh b/.travis/build-deploy.sh index 8c7e047c71..c32d86acda 100755 --- a/.travis/build-deploy.sh +++ b/.travis/build-deploy.sh @@ -6,9 +6,9 @@ source .travis/colors.sh function push_docs() { if git diff --quiet docs; then - echo_yellow "[ INFO] No changes in docs..." + log_info "No changes in docs..." else - echo_yellow "[ INFO] Found changes in docs..." + log_info "Found changes in docs..." if [ "$TRAVIS_BRANCH" == "master" ]; then git config user.name "Travis CI (pmd-bot)" @@ -16,38 +16,38 @@ function push_docs() { git add -A docs git commit -m "Update documentation" git push git@github.com:pmd/pmd.git HEAD:master - echo_green "[ INFO] Successfully pushed docs update" + log_success "Successfully pushed docs update" else - echo_yellow "[ INFO] Not on master branch, won't commit+push" + log_info "Not on master branch, won't commit+push" fi fi } VERSION=$(./mvnw -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.5.0:exec | tail -1) -echo_yellow "[ INFO] Building PMD ${VERSION} on branch ${TRAVIS_BRANCH}" +log_info "Building PMD ${VERSION} on branch ${TRAVIS_BRANCH}" MVN_BUILD_FLAGS="-B -V" if travis_isPullRequest; then - echo_yellow "[ INFO] This is a pull-request build" + log_info "This is a pull-request build" ./mvnw verify $MVN_BUILD_FLAGS elif travis_isPush; then if [[ "${VERSION}" != *-SNAPSHOT && "${TRAVIS_TAG}" != "" ]]; then echo -e "\n\n" - echo_green "[ INFO] This is a release build for tag ${TRAVIS_TAG}" + log_info "This is a release build for tag ${TRAVIS_TAG}" echo -e "\n\n" ./mvnw deploy -Possrh,pmd-release $MVN_BUILD_FLAGS elif [[ "${VERSION}" == *-SNAPSHOT ]]; then - echo_yellow "[ INFO] This is a snapshot build" + log_info "This is a snapshot build" ./mvnw deploy -Possrh $MVN_BUILD_FLAGS push_docs else # other build. Can happen during release: the commit with a non snapshot version is built, but not from the tag. - echo_yellow "[ INFO] This is some other build, probably during release: commit with a non-snapshot version on branch master..." + log_info "This is some other build, probably during release: commit with a non-snapshot version on branch master..." ./mvnw verify $MVN_BUILD_FLAGS # we stop here - no need to execute further steps exit 0 @@ -58,21 +58,21 @@ elif travis_isPush; then set +e echo -e "\n\n" - echo_yellow "[ INFO] Uploading pmd distribution to sourceforge..." + log_info "Uploading pmd distribution to sourceforge..." rsync -avh pmd-dist/target/pmd-*-${VERSION}.zip ${PMD_SF_USER}@web.sourceforge.net:/home/frs/project/pmd/pmd/${VERSION}/ if [ $? -ne 0 ]; then - echo_red "[ERROR] Error while uploading pmd-*-${VERSION}.zip to sourceforge!" - echo_red "[ERROR] Please upload manually: https://sourceforge.net/projects/pmd/files/pmd/" + log_error "Error while uploading pmd-*-${VERSION}.zip to sourceforge!" + log_error "Please upload manually: https://sourceforge.net/projects/pmd/files/pmd/" fi rsync -avh docs/pages/release_notes.md ${PMD_SF_USER}@web.sourceforge.net:/home/frs/project/pmd/pmd/${VERSION}/ReadMe.md if [ $? -ne 0 ]; then - echo_red "[ERROR] Error while uploading release_notes.md as ReadMe.md to sourceforge!" - echo_red "[ERROR] Please upload manually: https://sourceforge.net/projects/pmd/files/pmd/" + log_error "Error while uploading release_notes.md as ReadMe.md to sourceforge!" + log_error "Please upload manually: https://sourceforge.net/projects/pmd/files/pmd/" fi true ) else - echo_yellow "[ INFO] This is neither a pull request nor a push. Not executing any build." + log_info "This is neither a pull request nor a push. Not executing any build." exit 1 fi diff --git a/.travis/build-doc.sh b/.travis/build-doc.sh index bcd44752e4..e425ac975e 100755 --- a/.travis/build-doc.sh +++ b/.travis/build-doc.sh @@ -5,10 +5,10 @@ source .travis/common-functions.sh source .travis/colors.sh VERSION=$(./mvnw -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.5.0:exec | tail -1) -echo_yellow "[ INFO] Building PMD Documentation ${VERSION} on branch ${TRAVIS_BRANCH}" +log_info "Building PMD Documentation ${VERSION} on branch ${TRAVIS_BRANCH}" if ! travis_isPush; then - echo_yellow "[ INFO] Not building site, since this is not a push!" + log_info "Not building site, since this is not a push!" exit 0 fi @@ -16,13 +16,13 @@ pushd docs # run jekyll echo -e "\n\n" -echo_yellow "[ INFO] Building documentation using jekyll..." +log_info "Building documentation using jekyll..." bundle install bundle exec jekyll build # create pmd-doc archive echo -e "\n\n" -echo_yellow "[ INFO] Creating pmd-doc archive..." +log_info "Creating pmd-doc archive..." mv _site pmd-doc-${VERSION} zip -qr pmd-doc-${VERSION}.zip pmd-doc-${VERSION}/ @@ -32,23 +32,23 @@ zip -qr pmd-doc-${VERSION}.zip pmd-doc-${VERSION}/ if [[ "${TRAVIS_TAG}" != "" || "${VERSION}" == *-SNAPSHOT ]]; then echo -e "\n\n" - echo_yellow "[ INFO] Uploading pmd doc distribution to sourceforge..." + log_info "Uploading pmd doc distribution to sourceforge..." rsync -avh pmd-doc-${VERSION}.zip ${PMD_SF_USER}@web.sourceforge.net:/home/frs/project/pmd/pmd/${VERSION}/ if [ $? -ne 0 ]; then - echo_red "[ERROR] Couldn't upload pmd-doc-${VERSION}.zip!" - echo_red "[ERROR] Please upload manually: https://sourceforge.net/projects/pmd/files/pmd/" + log_error "Couldn't upload pmd-doc-${VERSION}.zip!" + log_error "Please upload manually: https://sourceforge.net/projects/pmd/files/pmd/" fi fi # rsync site to pmd.sourceforge.net/snapshot if [[ "${VERSION}" == *-SNAPSHOT && "${TRAVIS_BRANCH}" == "master" ]]; then echo -e "\n\n" - echo_yellow "[ INFO] Uploading snapshot site to pmd.sourceforge.net/snapshot..." + log_info "Uploading snapshot site to pmd.sourceforge.net/snapshot..." travis_wait rsync -ah --stats --delete pmd-doc-${VERSION}/ ${PMD_SF_USER}@web.sourceforge.net:/home/project-web/pmd/htdocs/snapshot/ if [ $? -ne 0 ]; then - echo_red "[ERROR] Couldn't upload the snapshot documentation. It won't be current on http://pmd.sourceforge.net/snapshot/" + log_error "Couldn't upload the snapshot documentation. It won't be current on http://pmd.sourceforge.net/snapshot/" else - echo_green "[ INFO] Successfully uploaded snapshot documentation: http://pmd.sourceforge.net/snapshot/" + log_success "Successfully uploaded snapshot documentation: http://pmd.sourceforge.net/snapshot/" fi fi diff --git a/.travis/build-sonar.sh b/.travis/build-sonar.sh index a16e90f68b..2458165df1 100755 --- a/.travis/build-sonar.sh +++ b/.travis/build-sonar.sh @@ -5,7 +5,7 @@ source .travis/common-functions.sh source .travis/colors.sh VERSION=$(./mvnw -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.5.0:exec | tail -1) -echo_yellow "[ INFO] Building PMD Sonar ${VERSION} on branch ${TRAVIS_BRANCH}" +log_info "Building PMD Sonar ${VERSION} on branch ${TRAVIS_BRANCH}" if ! travis_isPush; then echo "Not updating sonar, since this is not a push!" @@ -25,9 +25,9 @@ echo "MAVEN_OPTS='-Xms1g -Xmx1g --add-modules java.se.ee'" > ${HOME}/.mavenrc ./mvnw clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=${SONAR_TOKEN} -B -V if [ $? -ne 0 ]; then - echo_red "[ERROR] Error updating sonar..." + log_error "Error updating sonar..." else - echo_green "[ INFO] New sonar results: https://sonarcloud.io/dashboard?id=net.sourceforge.pmd%3Apmd" + log_success "New sonar results: https://sonarcloud.io/dashboard?id=net.sourceforge.pmd%3Apmd" fi true ) diff --git a/.travis/colors.sh b/.travis/colors.sh index 7cfb7f8a15..1c88df9413 100644 --- a/.travis/colors.sh +++ b/.travis/colors.sh @@ -5,14 +5,14 @@ COL_RED="\e[31m" COL_RESET="\e[0m" COL_YELLOW="\e[33;1m" -function echo_red() { - echo -e "${COL_RED}$*${COL_RESET}" +function log_error() { + echo -e "${COL_RED}[ERROR] $*${COL_RESET}" } -function echo_yellow() { - echo -e "${COL_YELLOW}$*${COL_RESET}" +function log_info() { + echo -e "${COL_YELLOW}[INFO] $*${COL_RESET}" } -function echo_green() { - echo -e "${COL_GREEN}$*${COL_RESET}" +function log_success() { + echo -e "${COL_GREEN}[SUCCESS] $*${COL_RESET}" } diff --git a/.travis/release.sh b/.travis/release.sh index 78e55e17fa..fbf96eec1c 100755 --- a/.travis/release.sh +++ b/.travis/release.sh @@ -17,13 +17,13 @@ if [ "${BUILD}" = "deploy" ]; then # The site has been built before, the files have already been uploaded to sourceforge. # Since this is a release, making the binary the new default file... - echo_yellow "[ INFO] Selecting pmd-bin-${RELEASE_VERSION} as default on sourceforge.net..." + log_info "Selecting pmd-bin-${RELEASE_VERSION} as default on sourceforge.net..." curl -H "Accept: application/json" -X PUT -d "default=windows&default=mac&default=linux&default=bsd&default=solaris&default=others" \ -d "api_key=${PMD_SF_APIKEY}" https://sourceforge.net/projects/pmd/files/pmd/${RELEASE_VERSION}/pmd-bin-${RELEASE_VERSION}.zip if [ $? -ne 0 ]; then - echo_red "[ERROR] Couldn't select latest binary as default on sourceforge.net" + log_error "Couldn't select latest binary as default on sourceforge.net" else - echo_green "[ INFO] pmd-bin-${RELEASE_VERSION} is now the default download option." + log_info "pmd-bin-${RELEASE_VERSION} is now the default download option." fi true ) @@ -43,7 +43,7 @@ cat > release-edit-request.json < Date: Thu, 24 May 2018 19:20:12 +0200 Subject: [PATCH 6/6] Rename colors.sh -> logger.sh --- .travis/build-coveralls.sh | 2 +- .travis/build-deploy.sh | 2 +- .travis/build-doc.sh | 2 +- .travis/build-sonar.sh | 2 +- .travis/{colors.sh => logger.sh} | 0 .travis/release.sh | 2 +- 6 files changed, 5 insertions(+), 5 deletions(-) rename .travis/{colors.sh => logger.sh} (100%) diff --git a/.travis/build-coveralls.sh b/.travis/build-coveralls.sh index 702908533f..9cdcd3411f 100755 --- a/.travis/build-coveralls.sh +++ b/.travis/build-coveralls.sh @@ -2,7 +2,7 @@ set -e source .travis/common-functions.sh -source .travis/colors.sh +source .travis/logger.sh VERSION=$(./mvnw -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.5.0:exec | tail -1) log_info "Building PMD Coveralls.io report ${VERSION} on branch ${TRAVIS_BRANCH}" diff --git a/.travis/build-deploy.sh b/.travis/build-deploy.sh index c32d86acda..8027b3ec70 100755 --- a/.travis/build-deploy.sh +++ b/.travis/build-deploy.sh @@ -2,7 +2,7 @@ set -e source .travis/common-functions.sh -source .travis/colors.sh +source .travis/logger.sh function push_docs() { if git diff --quiet docs; then diff --git a/.travis/build-doc.sh b/.travis/build-doc.sh index e425ac975e..961ffe56db 100755 --- a/.travis/build-doc.sh +++ b/.travis/build-doc.sh @@ -2,7 +2,7 @@ set -e source .travis/common-functions.sh -source .travis/colors.sh +source .travis/logger.sh VERSION=$(./mvnw -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.5.0:exec | tail -1) log_info "Building PMD Documentation ${VERSION} on branch ${TRAVIS_BRANCH}" diff --git a/.travis/build-sonar.sh b/.travis/build-sonar.sh index 2458165df1..e385da85af 100755 --- a/.travis/build-sonar.sh +++ b/.travis/build-sonar.sh @@ -2,7 +2,7 @@ set -e source .travis/common-functions.sh -source .travis/colors.sh +source .travis/logger.sh VERSION=$(./mvnw -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.5.0:exec | tail -1) log_info "Building PMD Sonar ${VERSION} on branch ${TRAVIS_BRANCH}" diff --git a/.travis/colors.sh b/.travis/logger.sh similarity index 100% rename from .travis/colors.sh rename to .travis/logger.sh diff --git a/.travis/release.sh b/.travis/release.sh index fbf96eec1c..7e42471976 100755 --- a/.travis/release.sh +++ b/.travis/release.sh @@ -1,7 +1,7 @@ #!/bin/bash set -e -source .travis/colors.sh +source .travis/logger.sh echo "BUILD: $BUILD" RELEASE_VERSION=$(./mvnw -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.5.0:exec | tail -1)