Skip to content

Commit cf01d41

Browse files
authored
Merge pull request #8 from utPLSQL/feature/fix_build_and_badges
Refactoring Travis config.
2 parents 05d0314 + 4996fdd commit cf01d41

11 files changed

Lines changed: 113 additions & 276 deletions

File tree

.travis.yml

Lines changed: 52 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -16,61 +16,77 @@ addons:
1616

1717
env:
1818
global:
19-
#Oracle 11g XE R2 docker variables
19+
# Docker variables:
20+
- DOCKHER_HUB_REPO="${DOCKER_USER}/oracledb"
2021
- ORACLE_VERSION=11g-r2-xe
2122
- CONNECTION_STR='127.0.0.1:1521/XE'
2223
- DOCKER_OPTIONS='--shm-size=1g'
23-
# Docker database Env
24-
- SQLCLI="$HOME/sqlcl/bin/sql"
25-
- OJDBC_HOME="$HOME/sqlcl/lib"
26-
- ORACLE_PWD="oracle"
27-
- UT3_DOCKER_REPO="utplsqlv3/oracledb"
28-
- DOCKHER_HUB_REPO="${DOCKER_BASE_TAG:-$UT3_DOCKER_REPO}"
29-
# project variables
24+
25+
# SYS account password for DB - could be stored in Travis secrets
26+
- ORACLE_SYS_PASS="oracle"
27+
# Adding utPLSQL-cli to path - to be able to invoke "utplsql" from command line
28+
- PATH=$PATH:${TRAVIS_BUILD_DIR}/utPLSQL-cli/bin
29+
# Adding Oracle SQLCL to path - to be able to invoke "sql" from command line
30+
- PATH=$PATH:${TRAVIS_BUILD_DIR}/sqlcl/bin
31+
32+
# Project-specific database variables
33+
# used for creating the user in database, deploying source code and tests as well as executing the tests
3034
- DB_USER=ut3_demo
31-
- DB_PASS=LHZYPbWvYdu2ctp8
32-
##utPLSQL variables
35+
- DB_PASS=ut3_demo
36+
#utPLSQL variables
3337
- UTPLSQL_DIR="utPLSQL"
34-
- ORA_SDTZ='Europe/London' #Needed as a client parameter
35-
- TZ='Europe/London' #Needed as a DB Server parameter
36-
##utPLSQL-cli variables
37-
- UTPLSQL_CLI_VERSION="3.1.0"
3838
- CACHE_DIR=$HOME/.cache
39-
- MAVEN_HOME=/usr/local/maven
40-
- MAVEN_CFG=$HOME/.m2
39+
# Additionally, you need to set following variables as Travis secrets:
40+
# DOCKER_USER
41+
# DOCKER_PASSWORD
42+
# ORACLE_OTN_USER
43+
# ORACLE_OTN_PASSWORD
4144
matrix:
42-
- UTPLSQL_3_VERSION='develop'
43-
- UTPLSQL_3_VERSION='v3.0.0' VERSION_PLACEHOLDER='utPLSQL - Version X.X.X.X'
44-
- UTPLSQL_3_VERSION='v3.0.4' VERSION_PLACEHOLDER='X.X.X.X'
45-
- UTPLSQL_3_VERSION='v3.1.1'
45+
- UTPLSQL_VERSION='develop'
46+
- UTPLSQL_VERSION='v3.0.0' VERSION_PLACEHOLDER='utPLSQL - Version X.X.X.X'
47+
- UTPLSQL_VERSION='v3.0.4' VERSION_PLACEHOLDER='X.X.X.X'
48+
- UTPLSQL_VERSION='v3.1.1'
4649

4750
cache:
4851
pip: true
4952
directories:
5053
- $CACHE_DIR
5154
- node_modules
52-
- $MAVEN_CFG
5355

5456
before_install:
55-
# download latest utPLSQL develop code
56-
- git clone --depth=1 --branch=${UTPLSQL_3_VERSION} https://github.com/utPLSQL/utPLSQL.git ${UTPLSQL_DIR}
57-
# download latest utPLSQL-cli release
58-
- curl -Lk -o utPLSQL-cli.zip https://github.com/utPLSQL/utPLSQL-cli/releases/download/v${UTPLSQL_CLI_VERSION}/utPLSQL-cli.zip
59-
# update version placeholder before install
60-
- if [[ -n ${VERSION_PLACEHOLDER} ]] ; then sed -i "s/${VERSION_PLACEHOLDER}/${UTPLSQL_3_VERSION}/g" ${UTPLSQL_DIR}/source/core/ut_utils.pks; fi
57+
# Download Oracle sqlcl
58+
- .travis/install_sqlcl.sh -u ${ORACLE_OTN_USER} -p ${ORACLE_OTN_PASSWORD} -d ${CACHE_DIR} -o ${TRAVIS_BUILD_DIR}
59+
# Check if Oracle sqlcl it is installed correctly
60+
- sql -v
6161

62-
63-
install:
62+
# download and unzip utPLSQL-cli release
63+
- curl -Lk -o utPLSQL-cli.zip "https://github.com/utPLSQL/utPLSQL-cli/releases/download/v3.1.6/utPLSQL-cli.zip"
6464
- unzip utPLSQL-cli.zip && chmod -R u+x utPLSQL-cli
65-
# get ojdbc.jar from Oracle using maven
66-
- bash .travis/maven_cfg.sh
67-
- bash .travis/install_sqlcl.sh
68-
# download and run Oracle docker DB image
69-
- bash .travis/start_db.sh
65+
# copy ojdbc.jar from sqlcl to utPSLQL-cli so it can be visible to utPSLQL-cli
66+
- cp sqlcl/lib/ojdbc8.jar utPLSQL-cli/lib && cp sqlcl/lib/orai18n.jar utPLSQL-cli/lib
67+
68+
# Download specified version of utPLSQL from utPLSQL github repo
69+
# Allows any utPLSQL branch/tag name to be used
70+
- git clone --depth=1 --branch=${UTPLSQL_VERSION} https://github.com/utPLSQL/utPLSQL.git ${UTPLSQL_DIR}
7071

71-
# Install utPLSQL
72+
# update version placeholder before install
73+
# This is only needed when downloading utPLSQL versions older than 3.1
74+
- if [[ -n ${VERSION_PLACEHOLDER} ]] ; then sed -i "s/${VERSION_PLACEHOLDER}/${UTPLSQL_VERSION}/g" ${UTPLSQL_DIR}/source/core/ut_utils.pks; fi
75+
76+
- docker login -u "${DOCKER_USER}" -p "${DOCKER_PASSWORD}"
77+
# download Oracle Database docker image from private repo and start the DB
78+
- time docker pull ${DOCKHER_HUB_REPO}:${ORACLE_VERSION}
79+
# start the docker container (DB)
80+
- docker run -d --name ${ORACLE_VERSION} ${DOCKER_OPTIONS} -p 1521:1521 ${DOCKHER_HUB_REPO}:${ORACLE_VERSION}
81+
# Wait for DB startup
82+
- time docker logs -f ${ORACLE_VERSION} | grep -m 1 "DATABASE IS READY TO USE!" --line-buffered
83+
84+
# Install utPLSQL into the Database
7285
- .travis/install_utplsql.sh
73-
- .travis/setup_account.sh
86+
87+
install:
88+
# Create the demo project DB user account
89+
- source/setup_db_account.sh
7490
# Install project sources and tests
7591
- source/install.sh
7692
- test/install.sh

.travis/download.sh

Lines changed: 0 additions & 71 deletions
This file was deleted.

.travis/install_sqlcl.sh

Lines changed: 56 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,66 @@
11
#!/bin/bash
22
set -e
33

4+
###############################3
5+
# Declarations
6+
###############################3
7+
SCRIPT_DIR="$( dirname "${BASH_SOURCE[0]}" )"
48
SQLCL_FILE=sqlcl-18.3.0.259.2029.zip
5-
cd .travis
9+
AGREEMENT_URL="http://www.oracle.com/technetwork/developer-tools/sqlcl/downloads/index.html"
10+
DOWNLOAD_URL="https://download.oracle.com/otn/java/sqldeveloper/${SQLCL_FILE}"
11+
ZIP_TARGET_DIR=""
12+
OTN_USER=""
13+
OTN_PASS=""
14+
OUTPUT_DIR=""
615

7-
# Download if not present on cache dir.
8-
if [ ! -f $CACHE_DIR/$SQLCL_FILE ]; then
16+
# Call the casperjs script to return the download url. Then download the file using curl.
17+
downloadFile() {
18+
user=$1
19+
pass=$2
20+
agreementUrl=$3
21+
downloadUrl=$4
22+
outputFile=$5
23+
echo "Signing-in"
24+
downloadUrl=$(exec casperjs ${SCRIPT_DIR}/download.js ${user} ${pass} ${agreementUrl} ${downloadUrl})
25+
downloadUrl=${downloadUrl%$'\r'}
26+
echo "DownloadURL: $downloadUrl"
27+
curl -o ${outputFile} -L "$downloadUrl"
28+
}
29+
30+
###############################3
31+
# Main script
32+
###############################3
33+
34+
#Evaluate script input parameters
35+
while getopts "p:u:d:o:" OPTNAME; do
36+
case "${OPTNAME}" in
37+
"d") ZIP_TARGET_DIR="${OPTARG}" ;;
38+
"u") OTN_USER="${OPTARG}" ;;
39+
"p") OTN_PASS="${OPTARG}" ;;
40+
"o") OUTPUT_DIR="${OPTARG}" ;;
41+
esac
42+
done
43+
44+
#Check parameters
45+
if [[ "${ZIP_TARGET_DIR}" == "" ]]; then
46+
ZIP_TARGET_DIR="."
47+
fi
48+
if [[ "$OTN_USER" == "" ]] || [[ "$OTN_PASS" == "" ]]; then
49+
echo "Error: Oracle OTN username/password not specified."
50+
exit 1
51+
fi
52+
if [[ "$OUTPUT_DIR" == "" ]]; then
53+
echo "Error: Output directory not specified"
54+
exit 1
55+
fi
56+
57+
if [[ ! -f "${ZIP_TARGET_DIR}/${SQLCL_FILE}" ]]; then
958
npm install -g phantomjs-prebuilt casperjs
10-
bash download.sh -p sqlcl
11-
mv $SQLCL_FILE $CACHE_DIR
59+
echo "Downloading sqlcl from Oracle"
60+
downloadFile ${OTN_USER} ${OTN_PASS} ${AGREEMENT_URL} ${DOWNLOAD_URL} "${ZIP_TARGET_DIR}/${SQLCL_FILE}"
1261
else
1362
echo "Installing sqlcl from cache..."
1463
fi;
1564

16-
# Install sqlcl.
17-
unzip -q $CACHE_DIR/$SQLCL_FILE -d $HOME
18-
19-
# Check if it is installed correctly.
20-
$SQLCLI -v
65+
echo "Unzipping sqlcl into: ${ZIP_TARGET_DIR}"
66+
unzip -q "${ZIP_TARGET_DIR}/${SQLCL_FILE}" -d ${OUTPUT_DIR}

.travis/install_utplsql.sh

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22

33
set -ev
44

5-
cd $UTPLSQL_DIR/source
5+
cd ${UTPLSQL_DIR}/source
66

7-
${SQLCLI} -S -L sys/${ORACLE_PWD}@//${CONNECTION_STR} AS SYSDBA @install_headless.sql
8-
9-
#${SQLCLI} -L -S sys/${ORACLE_PWD}@//${CONNECTION_STR} AS SYSDBA <<SQL
10-
#grant select any dictionary to ut3;
11-
#exit
12-
#SQL
7+
sql -S -L sys/${ORACLE_SYS_PASS}@//${CONNECTION_STR} AS SYSDBA @install_headless.sql

.travis/maven_cfg.sh

Lines changed: 0 additions & 18 deletions
This file was deleted.

.travis/pom.xml

Lines changed: 0 additions & 62 deletions
This file was deleted.

0 commit comments

Comments
 (0)