Skip to content
This repository has been archived by the owner on Jul 20, 2020. It is now read-only.

[#40] Sync develop branch with master #41

Merged
merged 3 commits into from
Aug 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
language: python

python:
- '3.5'

branches:
only:
- master
- develop

script:
- bash build/ci.sh


2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +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
Expand Down
44 changes: 44 additions & 0 deletions build/ci.sh
Original file line number Diff line number Diff line change
@@ -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 ###############################"

4 changes: 4 additions & 0 deletions build/env.sh
Original file line number Diff line number Diff line change
@@ -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
76 changes: 76 additions & 0 deletions build/functions.sh
Original file line number Diff line number Diff line change
@@ -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 <$?> <custom_error_code>
#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 <$?> <custom_error_code>
#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
}