From 6b7c98654d48ec1bd28ca98628632079a26c8bec Mon Sep 17 00:00:00 2001 From: Dee-Pac Date: Fri, 24 Aug 2018 16:44:49 -0700 Subject: [PATCH 1/3] [#8] Add travis CI integration (#20) * [#8] Add travis CI integration * [#8] Add travis CI integration * [#8] Add travis CI integration * [#8] Add travis CI integration * [#8] Add travis CI integration * [#8] Add travis CI integration * [#8] Add travis CI integration --- .travis.yml | 14 +++++++++ build/ci.sh | 44 +++++++++++++++++++++++++++ build/env.sh | 4 +++ build/functions.sh | 76 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 138 insertions(+) create mode 100644 .travis.yml create mode 100644 build/ci.sh create mode 100644 build/env.sh create mode 100644 build/functions.sh diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..e7e12f9 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,14 @@ +language: python + +python: + - '3.5' + +branches: + only: + - master + - develop + +script: + - bash build/ci.sh + + diff --git a/build/ci.sh b/build/ci.sh new file mode 100644 index 0000000..b110cc7 --- /dev/null +++ b/build/ci.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +export REPO_HOME=$(pwd) +export BUILD_DIR=${REPO_HOME}/build +export WORK_DIR=${REPO_HOME}/.tmp + +# Fetch reusable functions ... +source ${BUILD_DIR}/functions.sh +# Fetch constants and environment variables ... +source ${BUILD_DIR}/env.sh + +export args=$* + +write_log "Arguments --> ${args}" + +write_log "################### Cleanup #####################" + +write_log "Work Directory --> ${WORK_DIR}" +run_cmd "rm -rf ${WORK_DIR}" +run_cmd "mkdir ${WORK_DIR}" + +#Place as many pre-requisite steps here as requires... +write_log "#################### Install Requisite Packages ###############" + +write_log " ----------- 1. Install Tableau SDK ------------- " + +run_cmd "cd ${WORK_DIR}" +run_cmd "wget ${TABLEAU_URL}" +run_cmd "tar -xvf ${TABLEAU_TAR_BALL}" +run_cmd "export TABLEAU_DIR=$(ls | grep Tableau | grep -v gz)" +run_cmd "cd ${TABLEAU_DIR}" +run_cmd "python setup.py install" +run_cmd "cd ${REPO_HOME}" + +write_log "#################### Install PPExtensions ####################" + +run_cmd "pip install ppextensions" + +write_log "################### Final Cleanup #########################" + +run_cmd "rm -rf ${WORK_DIR}" + +write_log "######################## BUILD SUCCESS ###############################" + diff --git a/build/env.sh b/build/env.sh new file mode 100644 index 0000000..af8f967 --- /dev/null +++ b/build/env.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +export TABLEAU_URL=https://downloads.tableau.com/tssoftware/Tableau-SDK-Python-Linux-64Bit-10-3-14.tar.gz +export TABLEAU_TAR_BALL=Tableau-SDK-Python-Linux-64Bit-10-3-14.tar.gz diff --git a/build/functions.sh b/build/functions.sh new file mode 100644 index 0000000..3a51acd --- /dev/null +++ b/build/functions.sh @@ -0,0 +1,76 @@ +#!/bin/bash + + +# This is a re-usable functions file +# Other scripts may use the functions in this file by sourcing them + +#----------------------------function will check for error code & exit if failure, else proceed further----------------------------# + +#usage : check_error <$?> +#Example: Check_error < pass $? from the shell command > < Custom Message for errorcode -gt 0 > + +check_error() +{ + cmd_error_code=$1 + custom_message=$2 + if [ ${cmd_error_code} -gt 0 ]; then + write_log "Error | Stage | ${custom_message}" + exit ${cmd_error_code} + else + write_log "Success | Stage | ${custom_message}" + fi +} + +#----------------------------function will check for error code & warn if failure----------------------------# + +#usage : check_warning <$?> +#Example: Check_warning < pass $? from the shell command > < Custom Message for errorcode -gt 0 > + + +check_warning() +{ + + cmd_error_code=$1 + pgm_exit_code=$2 + pgm_exit_msg=$3 + if [ ${cmd_error_code} -gt 0 ]; then + write_log "WARNING ! ${cmd_error_code} ${pgm_exit_code} ${pgm_exit_msg}" + else + echo "" + fi +} + + + +#----------------------------function will write the message to Console / Log File----------------------------# + +#Usage : write_log < Whatever message you need to log > + +write_log() +{ + msg=$1 + to_be_logged="$(date '+%Y%m%d %H:%M:%S') | $msg" + echo ${to_be_logged} +} + +#-----------------------------------Executes a Command--------------------------------------------------------# + + + +#Usage : run_cmd < The command to execute > + +run_cmd() +{ + cmd=$1 + if [ -z $2 ]; then + fail_on_error="break_code" + else + fail_on_error=$2 + fi + write_log "Executing Command --> $1" + $cmd + error_code=$? + if [ ! $fail_on_error = "ignore_errors" ]; then + check_error $error_code "$cmd" + fi +} From d6b3bb460af1dbe8f28b3935fdfc96b2d3d9bfa7 Mon Sep 17 00:00:00 2001 From: Dee-Pac Date: Fri, 24 Aug 2018 16:45:57 -0700 Subject: [PATCH 2/3] [#11] Add travis CI Badge (#31) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index dc40068..1d9e0ea 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +[![Build Status](https://travis-ci.org/paypal/PPExtensions.svg?branch=master)](https://travis-ci.org/paypal/PPExtensions) [![Documentation Status](https://readthedocs.org/projects/ppextensions/badge/?version=latest)](http://ppextensions.readthedocs.io/en/latest/?badge=latest) [![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause) From 4f7d2381f0c1b26b99ed1f3fe582ea2d0412731e Mon Sep 17 00:00:00 2001 From: Dee-Pac Date: Fri, 24 Aug 2018 18:41:34 -0700 Subject: [PATCH 3/3] [#32] Add Codacy Integration and Badge (#33) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 1d9e0ea..89af470 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ [![Build Status](https://travis-ci.org/paypal/PPExtensions.svg?branch=master)](https://travis-ci.org/paypal/PPExtensions) [![Documentation Status](https://readthedocs.org/projects/ppextensions/badge/?version=latest)](http://ppextensions.readthedocs.io/en/latest/?badge=latest) +[![Codacy Badge](https://api.codacy.com/project/badge/Grade/a3452d2e00d2458bb79c6ba5f36b5b7a)](https://www.codacy.com/project/Dee-Pac/PPExtensions/dashboard?utm_source=github.com&utm_medium=referral&utm_content=paypal/PPExtensions&utm_campaign=Badge_Grade_Dashboard) [![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause) # PPExtensions