Skip to content

Commit 3669224

Browse files
committed
Merge branch 'develop' of https://github.com/utPLSQL/utPLSQL into develop
2 parents 31db250 + df64d7c commit 3669224

39 files changed

+1197
-543
lines changed

.travis.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,13 @@ env:
3434
- UTPLSQL_BUILD_VERSION=$(. .travis/get_project_build_version.sh)
3535
- UTPLSQL_SOURCES_DIR='source'
3636
- UTPLSQL_BUILD_USER_NAME="Travis CI"
37-
# Target Branch and Directory for Deployment of Docs
38-
- PAGES_TARGET_BRANCH="gh-pages"
39-
- PAGES_VERSION_BASE="version3"
4037
- CACHE_DIR=$HOME/.cache
4138
# Database Env
4239
- SQLCLI="$HOME/sqlcl/bin/sql"
4340
- ORACLE_PWD="oracle"
4441
matrix:
45-
- ORACLE_VERSION="12c-se-r1" CONNECTION_STR='127.0.0.1:1521/ORCLPDB1'
46-
- ORACLE_VERSION="11g-xe-r2" CONNECTION_STR='127.0.0.1:1521/XE' DOCKER_OPTIONS='--shm-size=1g'
42+
- ORACLE_VERSION="11g-xe-r2" CONNECTION_STR='127.0.0.1:1521/XE' DOCKER_OPTIONS='--shm-size=1g'
43+
- ORACLE_VERSION="12c-se-r1" CONNECTION_STR='127.0.0.1:1521/ORCLPDB1'
4744
- ORACLE_VERSION="12c-se2-r2-v2" CONNECTION_STR='127.0.0.1:1521/ORCLPDB1' DOCKER_OPTIONS="-v /dev/pdbs:/opt/oracle/oradata/pdbs"
4845

4946
cache:
@@ -74,6 +71,7 @@ script:
7471
- if [ "${TRAVIS_TAG}" = "" ]; then bash .travis/coveralls_uploader.sh; fi
7572
- bash .travis/build_docs.sh
7673
- if [ "${TRAVIS_TAG}" = "" ]; then bash .travis/push_release_version.sh; fi
74+
- bash .travis/push_docs_to_gh_pages.sh
7775

7876
before_deploy:
7977
- bash .travis/build_release_archive.sh

.travis/build_docs.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,3 @@ cd "${0%/*}"
44
# Change back to root
55
cd ..
66
mkdocs build --clean --strict
7-
8-
mkdir docs/markdown
9-
mv -t docs/markdown/ docs/about docs/images docs/userguide docs/index.md
10-
mkdir docs/html
11-
cp -r -v site/* docs/html

.travis/build_release_archive.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#!/bin/bash
22

3+
# remove markdown documentation
4+
rm -rf docs/*
5+
# and replace it with generated html documentation from the ignored site folder
6+
cp -r -v site/* docs
7+
38
mv -f .gitattributes.release .gitattributes
49
git add .
510
git commit -m "tmp commit for building a release archive"

.travis/deploy_key.enc

-3.18 KB
Binary file not shown.

.travis/push_docs_to_gh_pages.sh

Lines changed: 83 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1,126 +1,99 @@
11
#!/bin/bash
2-
3-
# Many aspsects of this came from https://gist.github.com/domenic/ec8b0fc8ab45f39403dd
2+
3+
# Many aspects of this came from https://gist.github.com/domenic/ec8b0fc8ab45f39403dd
44
# Significant alterations
5-
# - Avoid pulling all history for cloned repo
6-
# - Support for multiple copies of documenation,
7-
# - only clearing out latest
8-
# - doc-history.md logging doc history
9-
# - Wrapped calls with actual encrypt keys with > /dev/null 2> /dev/null4
5+
# - Support for multiple copies of documentation,
6+
# - only clearing out develop
7+
# - index.md logging doc history
108

11-
# How to run:
9+
# How to run:
1210
# - From repository root .travis/push_docs_to_gh_pages.sh
1311

1412
# Required files / directories (relative from repo root)
15-
# - Folder : "site" with that contains latest docs
16-
# - File : ".travis/deploy_key.enc" SSH deployment key encrypted by Travis command line tool
13+
# - File: "docs/index.md" with that contains develop docs
1714

1815
# Required ENV Variables
19-
# ENCRYPTION_LABEL - Manually Set in travis web settings. Value can be displayed in LOG
20-
# encrypted_${ENCRYPTION_LABEL}_key - Set in web settings using travis cmdline encryption
21-
# encrypted_${ENCRYPTION_LABEL}_iv - Set in web settings using travis cmdline encryption
22-
# PAGES_TARGET_BRANCH="gh-pages" - Set in .travis.yml, branch were pages will be deployed
23-
# PAGES_VERSION_BASE="version3" -Set in .travis.yml, directory for pages deployment
16+
PAGES_TARGET_BRANCH="gh-pages"
17+
LATEST_DOCS_BRANCH="develop"
2418
# TRAVIS_* variables are set by travis directly and only need to be if testing externally
2519

26-
# Pull requests are special...
27-
# They won't have acceess to the encrypted variables.
28-
# This prevent access to the Encrypted SSH Key
29-
# Regardless we don't want a pull request automatically updating the repository
30-
if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
20+
# Since we are running job matrix, only thie first job slave will need to do the work
21+
if [[ "${TRAVIS_JOB_NUMBER}" =~ \.1$ ]]; then
22+
# We don't want a pull request automatically updating the repository
23+
if [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "${CURRENT_BRANCH}" == "${LATEST_DOCS_BRANCH}" ]; then
3124

32-
# ENV Variable checks are to help with configuration troubleshooting
33-
# they silently exit with unique message. Anyone one of them not set
34-
# can be used to turn off this functionality.
35-
# For example a feature branch in the master repository that we don't want docs produced for yet.
36-
[[ -n "$PAGES_VERSION_BASE" ]] || { echo "PAGES_VERSION_BASE Missing"; exit 0; }
37-
[[ -n "$PAGES_TARGET_BRANCH" ]] || { echo "PAGES_TARGET_BRANCH Missing"; exit 0; }
38-
[[ -n "$ENCRYPTION_LABEL" ]] || { echo "ENCRYPTION_LABEL Missing"; exit 0; }
39-
40-
# Fail because required script to generate documenation must have not been run, or was changed.
41-
[[ -d ./site ]] || { echo "site directory not found"; exit 1; }
42-
43-
# Save some useful information
44-
REPO=`git config remote.origin.url`
45-
SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:}
46-
SHA=`git rev-parse --verify HEAD`
25+
# ENV Variable checks are to help with configuration troubleshooting, they silently exit with unique message.
26+
# Anyone one of them not set can be used to turn off this functionality.
4727

48-
# shallow clone the repostoriy and switch to PAGES_TARGET_BRANCH branch
49-
mkdir pages
50-
cd pages
51-
git clone --depth 1 $REPO .
52-
PAGES_BRANCH_EXISTS=$(git ls-remote --heads $REPO $PAGES_TARGET_BRANCH)
53-
54-
if [ -n "$PAGES_BRANCH_EXISTS" ] ; then
55-
echo "Pages Branch Found"
56-
echo "-$PAGES_BRANCH_EXISTS-"
57-
git remote set-branches origin $PAGES_TARGET_BRANCH
58-
git fetch --depth 1 origin $PAGES_TARGET_BRANCH
59-
git checkout $PAGES_TARGET_BRANCH
60-
else
61-
echo "Creating Pages Branch"
62-
git checkout --orphan $PAGES_TARGET_BRANCH
63-
git rm -rf .
64-
fi
65-
66-
#clear out latest and copy site contents to it.
67-
echo "updating $VERSION_BASE/latest"
68-
mkdir -p $PAGES_VERSION_BASE/latest
69-
rm -rf $PAGES_VERSION_BASE/latest/**./* || exit 0
70-
cp -a ../site/. $PAGES_VERSION_BASE/latest
71-
72-
# If a Tagged Build then copy to it's own directory as well.
73-
if [ -n "$TRAVIS_TAG" ]; then
74-
echo "Creating $PAGES_VERSION_BASE/$TRAVIS_TAG"
75-
mkdir -p $PAGES_VERSION_BASE/$TRAVIS_TAG || exit 0
76-
cp -a ../site/. $PAGES_VERSION_BASE/$TRAVIS_TAG
77-
fi
78-
79-
#Check if there are doc changes, if none exit the script
80-
if [[ -z `git diff --exit-code` ]] && [ -n "$PAGES_BRANCH_EXISTS" ] ; then
81-
echo "No changes to docs detected."
82-
exit 0
83-
fi
28+
# If a version of the project is not defined
29+
[[ -n "${UTPLSQL_VERSION}" ]] || { echo "variable UTPLSQL_VERSION is not defines or missing value"; exit 0; }
30+
# Fail if the markdown documentation is not present.
31+
[[ -f ./docs/index.md ]] || { echo "file docs/index.md not found"; exit 1; }
8432

85-
#Chganges where detected, so it's safe to write to log.
86-
now=$(date +"%d %b %Y - %r")
87-
export latest=" - [Latest Doc Change]($PAGES_VERSION_BASE/latest/) - Created $now"
88-
if [ ! -f doc-history.md ]; then
89-
echo "<!-- Auto generated in .travis/push_docs_to_gh_pages.sh -->" >doc-history.md
90-
echo "#Doc Generation Log" >>doc-history.md
91-
echo "" >>doc-history.md
92-
echo "- 4th line placeholder see below" >>doc-history.md
93-
echo "" >>doc-history.md
94-
echo "##Released Version Doc History" >>doc-history.md
95-
echo "" >>doc-history.md
96-
fi
97-
if [ -n "$TRAVIS_TAG" ]; then
98-
echo " - [$TRAVIS_TAG]($PAGES_VERSION_BASE/$TRAVIS_TAG/) - Created $now" >>doc-history.md
99-
fi
100-
101-
#replace 4th line in log
102-
sed -i '4s@.*@'"$latest"'@' doc-history.md
33+
# Save some useful information
34+
SHA=`git rev-parse --verify HEAD`
10335

104-
#Setup Git with Commiter info
105-
git config user.name "Travis CI"
106-
git config user.email "utplsql@users.noreply.github.com"
36+
# clone the repository and switch to PAGES_TARGET_BRANCH branch
37+
mkdir pages
38+
cd pages
39+
git clone https://${github_api_token}@github.com/${UTPLSQL_REPO} .
10740

108-
#Add and Commit the changes back to pages repo.
109-
git add .
110-
git commit -m "Deploy to GitHub Pages: ${SHA}"
111-
112-
#unencrypt and configure deployment key
113-
[[ -e ../.travis/deploy_key.enc ]] || { echo ".travis/deploy_key.enc file not found"; exit 1; }
114-
ENCRYPTED_KEY_VAR="encrypted_${ENCRYPTION_LABEL}_key"
115-
ENCRYPTED_IV_VAR="encrypted_${ENCRYPTION_LABEL}_iv"
116-
ENCRYPTED_KEY=${!ENCRYPTED_KEY_VAR} > /dev/null 2> /dev/null
117-
ENCRYPTED_IV=${!ENCRYPTED_IV_VAR} > /dev/null 2> /dev/null
118-
openssl aes-256-cbc -K $ENCRYPTED_KEY -iv $ENCRYPTED_IV -in ../.travis/deploy_key.enc -out ../.travis/deploy_key -d > /dev/null 2> /dev/null
119-
chmod 600 ../.travis/deploy_key
120-
eval `ssh-agent -s`
121-
ssh-add ../.travis/deploy_key
122-
123-
# Now that we're all set up, we can push.
124-
echo "git push $SSH_REPO $PAGES_TARGET_BRANCH"
125-
git push $SSH_REPO $PAGES_TARGET_BRANCH
41+
PAGES_BRANCH_EXISTS=$(git ls-remote --heads origin ${PAGES_TARGET_BRANCH})
42+
43+
if [ -n "$PAGES_BRANCH_EXISTS" ] ; then
44+
echo "Pages Branch Found"
45+
git checkout ${PAGES_TARGET_BRANCH}
46+
else
47+
echo "Creating Pages Branch"
48+
git checkout --orphan ${PAGES_TARGET_BRANCH}
49+
git rm -rf .
50+
fi
51+
#clear out develop documentation directory and copy docs contents to it.
52+
echo "updating 'develop' directory"
53+
mkdir -p develop
54+
rm -rf develop/**./* || exit 0
55+
cp -a ../docs/. ./develop
56+
# If a Tagged Build then copy to it's own directory as well.
57+
if [ -n "$TRAVIS_TAG" ]; then
58+
echo "Creating ${UTPLSQL_VERSION}"
59+
mkdir -p ${UTPLSQL_VERSION}
60+
rm -rf ${UTPLSQL_VERSION}/**./* || exit 0
61+
cp -a ../docs/. ${UTPLSQL_VERSION}
62+
fi
63+
# Stage changes for commit
64+
git add .
65+
#Check if there are doc changes, if none exit the script
66+
if [[ -z `git diff HEAD --exit-code` ]] && [ -n "${PAGES_BRANCH_EXISTS}" ] ; then
67+
echo "No changes to docs detected."
68+
exit 0
69+
fi
70+
#Changes where detected, so we need to update the version log.
71+
now=$(date +"%d %b %Y - %r")
72+
export latest=" - [Latest development version](develop/) - Created $now"
73+
if [ ! -f index.md ]; then
74+
echo "---" >>index.md
75+
echo "layout: default" >>index.md
76+
echo "---" >>index.md
77+
echo "<!-- Auto generated from .travis/push_docs_to_gh_pages.sh -->" >>index.md
78+
echo "# Documentation versions" >>index.md
79+
echo "" >>index.md
80+
echo "" >>index.md #- 7th line - placeholder for latest release doc
81+
echo "" >>index.md #- 8th line - placeholder for develop branch doc
82+
echo "" >>index.md
83+
echo "## Released Version Doc History" >>index.md
84+
echo "" >>index.md
85+
fi
86+
#If build running on a TAG - it's a new release - need to add it to documentation
87+
if [ -n "${TRAVIS_TAG}" ]; then
88+
latest_release=" - [${TRAVIS_TAG} documentation](${UTPLSQL_VERSION}/) - Created $now"
89+
sed -i '7s@.*@'"Latest release ${latest_release}"'@' index.md
90+
fi
91+
#replace 4th line in log
92+
sed -i '8s@.*@'"${latest}"'@' index.md
93+
#Add and Commit the changes back to pages repo.
94+
git add .
95+
git commit -m "Deploy to gh-pages branch: base commit ${SHA}"
96+
# Now that we're all set up, we can push.
97+
git push --quiet origin HEAD:${PAGES_TARGET_BRANCH}
98+
fi
12699
fi

client_source/sqlplus/file_list

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# All parameters are required. This way, users can't pass empty string as parameter.
5+
invalidArgs=0
6+
[ -z "$1" ] && invalidArgs=1
7+
[ -z "$2" ] && invalidArgs=1
8+
[ -z "$3" ] && invalidArgs=1
9+
10+
if [ $invalidArgs -eq 1 ]; then
11+
echo Usage: ut_run.sh "project_path" "sql_param_name" "output_file" "scan_path"
12+
exit 1
13+
fi
14+
15+
# Remove trailing slashes.
16+
projectPath=${1%/}
17+
sqlParamName=$2
18+
outputFile=$3
19+
scanPath=$4
20+
21+
fullScanPath="$projectPath/$scanPath"
22+
23+
if [ ! -d "$fullScanPath" ] || [ -z "$4" ]; then
24+
echo "begin" > $outputFile
25+
echo " open :$sqlParamName for select null from dual where 1= 0;" >> $outputFile
26+
echo "end;" >> $outputFile
27+
echo "/" >> $outputFile
28+
exit 0
29+
fi
30+
31+
echo "declare" > $outputFile
32+
echo " l_list ut_varchar2_list := ut_varchar2_list();" >> $outputFile
33+
echo "begin" >> $outputFile
34+
for f in $(find $fullScanPath/* -type f | sed "s|$projectPath/||"); do
35+
echo " l_list.extend; l_list(l_list.last) := '$f';" >> $outputFile
36+
done
37+
echo " open :$sqlParamName for select * from table(l_list);" >> $outputFile
38+
echo "end;" >> $outputFile
39+
echo "/" >> $outputFile

client_source/sqlplus/file_list.bat

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
@echo off
2+
setlocal EnableDelayedExpansion
3+
4+
REM All parameters are required. This way, users can't pass empty string as parameter.
5+
set invalidArgs=0
6+
set pathNotProvided=0
7+
if [%1] == "" set invalidArgs=1
8+
if [%2] == "" set invalidArgs=1
9+
if [%3] == "" set invalidArgs=1
10+
11+
if %invalidArgs% == 1 (
12+
echo Usage: ut_run.bat "project_path" "sql_param_name" "output_file" "scan_path"
13+
exit /b 1
14+
)
15+
REM Expand relative path from parameter to be a full path
16+
set projectPath=%~f1
17+
set sqlParamName=%~2
18+
set outputFile=%~3
19+
set scanPath=%~4
20+
21+
REM Remove trailing slashes.
22+
if %projectPath:~-1%==\ set projectPath=%projectPath:~0,-1%
23+
if [%scanPath%] == [] (set pathNotProvided=1) else (set "fullScanPath=%projectPath%\%scanPath%")
24+
if not exist "%fullScanPath%\*" set pathNotProvided=1
25+
26+
if %pathNotProvided% == 1 (
27+
echo begin>%outputFile%
28+
echo ^ open :%sqlParamName% for select null from dual where 1 = 0;>>%outputFile%
29+
echo end;>>%outputFile%
30+
echo />>%outputFile%
31+
exit /b 0
32+
)
33+
34+
echo declare>%outputFile%
35+
echo ^ l_list ut_varchar2_list := ut_varchar2_list();>>%outputFile%
36+
echo begin>>%outputFile%
37+
for /f "tokens=* delims= " %%a in ('dir %fullScanPath%\* /B /S /A:-D') do (
38+
set "filePath=%%a"
39+
set filePath=!filePath:%projectPath%\=!
40+
echo ^ l_list.extend; l_list^(l_list.last^) := '!filePath!^';>>%outputFile%
41+
)
42+
echo ^ open :%sqlParamName% for select * from table(l_list);>>%outputFile%
43+
echo end;>>%outputFile%
44+
echo />>%outputFile%

client_source/sqlplus/ut_run

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
set -e
3+
4+
clientDir="$(dirname "$(readlink -f "$0")")"
5+
projectDir="$(pwd)"
6+
7+
if [[ "$clientDir" != "${clientDir% *}" ]]; then
8+
echo "Error: ut_run script path cannot have spaces."
9+
exit 1
10+
fi
11+
12+
if [[ "$#" -eq 0 ]] ; then
13+
echo "Usage: ut_run user/password@database [options...]"
14+
exit 1
15+
fi
16+
17+
sqlplus /nolog @"$clientDir/ut_run.sql" "$clientDir" "$projectDir" "$@"

client_source/sqlplus/ut_run.bat

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@echo off
2+
3+
set clientDir=%~dp0
4+
set projectDir=%__CD__%
5+
6+
if not "%clientDir%" == "%clientDir: =%" (
7+
echo Error: ut_run script path cannot have spaces.
8+
exit /b 1
9+
)
10+
11+
if "%1" == "" (
12+
echo Usage: ut_run user/password@database [options...]
13+
exit /b 1
14+
)
15+
16+
sqlplus /nolog @"%clientDir%\ut_run.sql" '%clientDir%' '%projectDir%' %*

0 commit comments

Comments
 (0)