Skip to content
This repository has been archived by the owner on Mar 4, 2024. It is now read-only.

Commit

Permalink
Merge branch 'release/0.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
mestebangutierrez committed Jul 6, 2016
2 parents ff716f2 + d8ccd23 commit 05aa5fc
Show file tree
Hide file tree
Showing 15 changed files with 1,414 additions and 1,158 deletions.
52 changes: 21 additions & 31 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,32 @@
sudo: false
language: java
jdk:
- oraclejdk7

notifications:
slack: sdhub:ti8lMh7ERZIqLzWF4dHkcgwt

cache:
directories:
- $HOME/.m2/repository
- $HOME/.sonar
notifications:
slack: sdhub:ti8lMh7ERZIqLzWF4dHkcgwt
language: java
jdk:
- oraclejdk7

before_cache:
- source ./.travis/utils.sh backup-maven-repo

before_install:
- openssl aes-256-cbc -pass pass:$ENCRYPTION_PASSWORD -in config/src/main/resources/ci/secring.gpg.enc
-out local.secring.gpg -d
- openssl aes-256-cbc -pass pass:$ENCRYPTION_PASSWORD -in config/src/main/resources/ci/pubring.gpg.enc
-out local.pubring.gpg -d
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
- source ./.travis/utils.sh prepare-build-bom $ENCRYPTION_PASSWORD

install:
- /bin/true
- "/bin/true"

script:
- if [ "${TRAVIS_PULL_REQUEST}" = "false" ];
then
if [ "${TRAVIS_BRANCH}" = "master" ] || [ "${TRAVIS_BRANCH}" = "develop" ];
then mvn clean deploy -B -Dcodebase.directory=`pwd` -Dcoverage.reports.dir=`pwd`/target/all --settings config/src/main/resources/ci/settings.xml;
else mvn clean install -B -Dcoverage.reports.dir=`pwd`/target/all --settings config/src/main/resources/ci/settings.xml;
fi
else
echo mvn clean install -B -Dcoverage.reports.dir=`pwd`/target/all --settings config/src/main/resources/ci/settings.xml;
fi
- if [ "${TRAVIS_PULL_REQUEST}" = "false" ];
then
case "${TRAVIS_BRANCH}" in
master) mvn sonar:sonar -B -Dsonar.branch=$TRAVIS_BRANCH -Dcoverage.reports.dir=`pwd`/target/all --settings config/src/main/resources/ci/settings.xml;;
develop) mvn sonar:sonar -B -Dsonar.branch=$TRAVIS_BRANCH -Dcoverage.reports.dir=`pwd`/target/all --settings config/src/main/resources/ci/settings.xml;;
feature*) mvn sonar:sonar -B -Dsonar.branch=$TRAVIS_BRANCH -Dcoverage.reports.dir=`pwd`/target/all --settings config/src/main/resources/ci/settings.xml;;
*) echo "Skip SonarQube analysis (${TRAVIS_BRANCH})";;
esac
fi
- mkdir /tmp/cache-trick
- mv $HOME/.m2/repository/org/smartdeveloperhub /tmp/cache-trick/
- source ./.travis/build.sh

after_success:
- source ./.travis/utils.sh restore-maven-repo
- source ./.travis/qa.sh

env:
global:
- secure: JslDK1Own9RevKDwXNvXBpp/Fza4+9rATZLKIFiS8WjnugZaA8dMrn87AmbH5Yg+Aq3AV5aAYQKo4MoEHJEVU6wgp5p7INaVGPpC5p8CgjTFYJu0TC0oIXzVvEQy49uTDV8iM0icQcOn6MpFEQq6qlL9JW9Lt9Eu+Am5UKfKWPWQhe63Qf2LoLRfKWZ4IoekWGlMFF+qsRxmXkNdbniIkmzu0PVj9vTg7I7igupDPC3W9r9+YgVu0PoatBgx8Jhe8iSlnW6tLrb/GKI77wQolRylm77pD3F2DFeNag8SWCYoy6tgIPUpTCZ6sjGb/Ydbus5MRBjvnRIZ6Zu4HzbvixApK5E6pjFDAoE2xuAbBuVe2aSJ2d2bMbmpI444Y56Cdzf5a0D2zz7TdTXWyv96qXQB/GHX8Ccp67nziiaoSTGRVkdVratJHTclxUFVjNSrgtVmCjrzTz1XP0Q4gB2M7G7p0eczU2riCEPembAGC4NRhCDYJ9FsvE0WDtb5JBLZhGu82WFyrMs51FoMNv0Mu6pg8TVjvrj+q418jY2uDTlLh8xYuRmNkNscwE5L+WQLVJ63D3fTgMOwuUeaGnq38oQWTB/sokG2ISimNufSfttkjyBNFBPr/ismMyJVlB4t6kqAZRy4idwblT2SjyVhSphp8QipmxwopJjX0qDr0tI=
Expand Down
52 changes: 52 additions & 0 deletions .travis/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash
# Abort script on first failure
set -e

function deploy() {
if [ "$1" != "porcelain" ];
then
echo "Executing Maven deploy (${TRAVIS_BRANCH})..."
mvn clean deploy -B -Dcodebase.directory=$(pwd) -Dcoverage.reports.dir=$(pwd)/target/all --settings config/src/main/resources/ci/settings.xml
else
echo "Skipped Maven deploy (${TRAVIS_BRANCH}): Porcelain"
fi
}

function install() {
if [ "$1" != "porcelain" ];
then
echo "Executing Maven install (${TRAVIS_BRANCH})..."
mvn clean install -B -Dcoverage.reports.dir=$(pwd)/target/all --settings config/src/main/resources/ci/settings.xml
else
echo "Skipped Maven install (${TRAVIS_BRANCH}): Porcelain"
fi
}

function runBuild() {
mode=$1
if [ "${TRAVIS_PULL_REQUEST}" = "false" ];
then
case "${TRAVIS_BRANCH}" in
master | develop ) deploy "$mode";;
feature\/* ) install "$mode";;
* ) install "$mode";;
esac
else
install "$mode"
fi
}

function skipBuild() {
echo "Skipping build..."
}

if [ "${DEBUG}" = "trace" ];
then
set -x
fi

case "${CI}" in
skip ) skipBuild ;;
porcelain ) runBuild porcelain ;;
* ) runBuild "$1" ;;
esac
147 changes: 147 additions & 0 deletions .travis/qa.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
#!/bin/bash
# Avoid aborting script on failure
set +e

function logCheckResults() {
case "${DEBUG}" in
trace | verbose )
echo "-> Trace:"
cat log.txt
echo "-> Response:"
cat data.txt
;;
* )
:
;;
esac
}

function checkWithCurl() {
if [ "${DEBUG}" = "verbose" ];
then
curl --version
fi
curl --head --silent --verbose --connect-timeout 5 "$1" > data.txt 2> log.txt
error=$?
logCheckResults
return "$error"
}

function checkWithWget() {
if [ "${DEBUG}" = "verbose" ];
then
wget --version
fi
# Write response (and headers) to 'data.txt', (verbose) activity to 'log.txt'
# including additional debug entries (e.g., requests and responses), with a
# generic timeout of 5s, and retry only once.
# In addition, discard the additional output (both standard and error)
wget --output-document=data.txt --output-file=log.txt --verbose --debug --timeout=5 --tries 1 --save-headers "$1" > error.log 2>&1
error=$?
if [ "$error" != "0" ];
then
# If a failure happens, but the server sent a response...
if [ "$(grep -c "response begin" log.txt)" -gt 0 ]
then
# ... we extract the response from the log...
from=$(awk '/response begin/{ print NR; exit }' log.txt)
to=$(awk '/response end/{ print NR; exit }' log.txt)
head -n $((to - 1)) log.txt | tail -n $((to - from - 1)) > data.txt
# ... and clear the failure status.
error=0
fi
fi
logCheckResults
return "$error"
}

function checkSonarQubeServer() {
echo "Checking SonarQube Server..."

case "${CHECKER}" in
curl ) checkWithCurl "$1";;
* ) checkWithWget "$1";;
esac

error=$?
if [ "$error" = "0" ];
then
status=$(head -n 1 data.txt | awk '{print $2}')
if [ "$status" != "200" ];
then
echo "SonarQube Server is not available (response status code: $status)"
error=1
fi
else
echo "Could not connect to SonarQube Server: "
cat log.txt
error=2
fi
rm data.txt
rm log.txt
return "$error"
}

function analyzeBranch() {
checkSonarQubeServer "$1"
if [ "$?" = "0" ];
then
if [ "$2" != "porcelain" ];
then
echo "Executing SonarQube analysis (${TRAVIS_BRANCH})..."
# If SSL network failures happen, execute the analysis with -Djavax.net.debug=all
mvn sonar:sonar -B -Dsonar.branch="$TRAVIS_BRANCH" -Dcoverage.reports.dir="$(pwd)/target/all" --settings config/src/main/resources/ci/settings.xml
else
echo "Skipped SonarQube analysis (${TRAVIS_BRANCH}): Porcelain"
fi
else
echo "Skipped SonarQube analysis (${TRAVIS_BRANCH})"
fi
}

function skipBranchAnalysis() {
echo "Skipped SonarQube analysis (${TRAVIS_BRANCH}): Non Q.A. branch"
}

function skipPullRequestAnalysis() {
echo "Skipped SonarQube analysis (${TRAVIS_BRANCH}): Pull request"
}

function skipBuild() {
echo "Skipping build..."
}

function skipSonarQubeAnalysis() {
echo "Skipping SonarQube analysis..."
}

function runSonarQubeAnalysis() {
if [ "${TRAVIS_PULL_REQUEST}" = "false" ];
then
case "${TRAVIS_BRANCH}" in
master | develop ) analyzeBranch "$1" "$2";;
feature\/* ) analyzeBranch "$1" "$2";;
* ) skipBranchAnalysis ;;
esac
else
skipPullRequestAnalysis
fi
}

if [ "${DEBUG}" = "trace" ];
then
set -x
fi

server=http://www.smartdeveloperhub.org/sonar/

case "${CI}" in
skip ) skipBuild ;;
noqa ) skipSonarQubeAnalysis ;;
porcelain ) runSonarQubeAnalysis "$server" porcelain ;;
* ) runSonarQubeAnalysis "$server" "$1" ;;
esac

set +x

return 0
134 changes: 134 additions & 0 deletions .travis/utils.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
#!/bin/bash
# Abort script on first failure
set -e

function backupMavenRepo() {
if [ "$1" != "porcelain" ];
then
mkdir /tmp/cache-trick
mv "$HOME/.m2/repository/org/smartdeveloperhub" /tmp/cache-trick/
else
echo "Skipped Maven Repo backup"
fi
}

function restoreMavenRepo() {
if [ "$1" != "porcelain" ];
then
mv /tmp/cache-trick/smartdeveloperhub "$HOME/.m2/repository/org/"
else
echo "Skipped Maven Repo restoration"
fi
}

function fail() {
echo "ERROR: Unknown command '${1}'."
return 1
}

function beginSensibleBlock() {
set +x
if [ "${DEBUG}" = "trace" ];
then
set -v
fi
}

function endSensibleBlock() {
set +v
if [ "${DEBUG}" = "trace" ];
then
set -x
fi
}

function unshallowGitRepository() {
if [[ -a .git/shallow ]];
then
echo "- Unshallowing Git repository..."
set +e
git fetch --unshallow --verbose;
set -e
error=$?
if [[ $error -ne 0 ]];
then
echo "Unshallowing failed with $error status code"
git --version
return $error
fi
fi
}

function prepareBuild() {
endSensibleBlock

if [ "$#" != "2" ];
then
echo "ERROR: No encryption password specified."
return 2
fi

if [ "$1" != "porcelain" ];
then
beginSensibleBlock

echo "Preparing Build's bill-of-materials..."
echo "- Decrypting private key..."
openssl aes-256-cbc -pass pass:"$2" -in config/src/main/resources/ci/secring.gpg.enc -out local.secring.gpg -d
echo "- Decrypting public key..."
openssl aes-256-cbc -pass pass:"$2" -in config/src/main/resources/ci/pubring.gpg.enc -out local.pubring.gpg -d

endSensibleBlock

unshallowGitRepository
else
echo "Skipped preparation of the Build's bill-of-materials"
fi
}

function runUtility() {
beginSensibleBlock

mode=$1
if [ "$mode" != "porcelain" ];
then
mode=${CI}
fi

check=$1
shift
if [ "$check" = "porcelain" ];
then
action=$1
shift
else
action=$check
fi

case "$action" in
backup-maven-repo )
endSensibleBlock
backupMavenRepo "$mode" "$@"
;;
restore-maven-repo)
endSensibleBlock
restoreMavenRepo "$mode" "$@"
;;
prepare-build-bom )
prepareBuild "$mode" "$@"
;;
* )
endSensibleBlock
fail "$action"
;;
esac
}

function skipBuild() {
echo "Skipping build..."
}

case "${CI}" in
skip ) skipBuild ;;
* ) runUtility "$@" ;;
esac
Loading

0 comments on commit 05aa5fc

Please sign in to comment.