Skip to content

Commit

Permalink
Merge 1a875a6 into abce191
Browse files Browse the repository at this point in the history
  • Loading branch information
jgebal committed Mar 9, 2017
2 parents abce191 + 1a875a6 commit c532aa7
Show file tree
Hide file tree
Showing 45 changed files with 232 additions and 137 deletions.
19 changes: 10 additions & 9 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@

.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.travis.yml export-ignore

.travis export-ignore

^docs/* linguist-documentation
.travis export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.travis.yml export-ignore
mkdocs.yml export-ignore
tests export-ignore
development export-ignore
sonar-project.properties export-ignore
^docs/* linguist-documentation
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff:
.idea/
site/
.sonar/
pages/
release/
release/*
*.gz
*.zip
51 changes: 33 additions & 18 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,45 @@ addons:
- master
env:
global:
#Needed to install Oracle
- ORACLE_COOKIE=sqldev
- ORACLE_FILE=oracle11g/xe/oracle-xe-11.2.0-1.0.x86_64.rpm.zip
#Needed to run and access Oracle db
- ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
- NLS_LANG=AMERICAN_AMERICA.AL32UTF8
- ORACLE_BASE=/u01/app/oracle
- LD_LIBRARY_PATH=$ORACLE_HOME/lib
- PATH=$PATH:$ORACLE_HOME/jdbc/lib:$ORACLE_HOME/bin
- JAVA_HOME=/usr/lib/jvm/java-8-oracle/jre
- DATABASE_VERSION=11.2.0.2
- ORACLE_SID=XE
- DATABASE_NAME=XE
- ORA_SDTZ='Europe/London' #Needed as a client parameter
- TZ='Europe/London' #Needed as a DB Server parameter
#Needed for Sonar integration - as it runs on Java8
- JAVA_HOME=/usr/lib/jvm/java-8-oracle/jre
#utPLSQL install user
- UT3_OWNER=ut3
- UT3_OWNER_PASSWORD=ut3
- UT3_OWNER_TABLESPACE=users
#utPLSQL another user - for testing utPLSQL runability from other schema
- UT3_USER=ut3_user
- UT3_USER_PASSWORD=ut3
- UT3_USER_TABLESPACE=users
# Target Branch and Directory for Deployment of Docs
# Target Branch and Directory for Deployment of Docs
- PAGES_TARGET_BRANCH="gh-pages"
- PAGES_VERSION_BASE="version3"

#Environment for building a release
# File containing new version number
- CURRENT_BRANCH="${TRAVIS_BRANCH}"
- IS_RELEASE_BRANCH="`if [[ $CURRENT_BRANCH =~ ^release/v[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then echo true; fi`"
- UTPLSQL_PROJECT_ROOT=${TRAVIS_BUILD_DIR}
- UTPLSQL_REPO="utPLSQL/utPLSQL"
- UTPLSQL_BUILD_NO="${TRAVIS_BUILD_NUMBER:-0}"
- UTPLSQL_VERSION_PLACEHOLDER='utPLSQL - Version'
- UTPLSQL_VERSION="`. .travis/get_project_version.sh`"
- UTPLSQL_SOURCES_DIR='source'
- UTPLSQL_BUILD_USER_NAME="Travis CI"
cache:
directories:
- .cache
Expand All @@ -54,35 +70,34 @@ before_install:
- test -f "$ORACLE_ZIP_DIR"/$(basename $ORACLE_FILE) || bash .travis/oracle/download.sh

install:
- sudo pip install -r .travis/python_req.txt
- sudo pip install mkdocs
- bash .travis/oracle/install.sh

script:
- bash .travis/create_utplsql_owner.sh
- bash .travis/create_utplsql_user.sh
- bash .travis/install_libraries.sh
- bash .travis/install.sh
- bash .travis/grant_user.sh

script:
- bash .travis/run_examples_as_owner.sh
- bash .travis/run_test_as_owner.sh
- bash .travis/run_examples_as_user.sh
- bash .travis/create_release.sh
# - bash .travis/run_test_as_user.sh
# - bash .travis/build_docs.sh
# - bash .travis/push_docs_to_gh_pages.sh
- bash .travis/run_test_as_owner.sh
- sonar-scanner
- bash .travis/coveralls_uploader.sh

before_deploy:
- git clean -d -f -q
- bash .travis/release/update_project_version.sh
- bash .travis/release/build_docs.sh
# - bash .travis/push_docs_to_gh_pages.sh

deploy:
provider: releases
api_key: $github_api_token
file:
- utPLSQL$TRAVIS_TAG.zip
- utPLSQL$TRAVIS_TAG.tar.gz
provider: script
script: bash .travis/release/make_release.sh
skip_cleanup: true
on:
repo: utPLSQL/utPLSQL
tags: true
repo: ${UTPLSQL_REPO}
condition: ${IS_RELEASE_BRANCH} == true
all_branches: true

notifications:
slack: utplsql:oiMuXO95TvKeAUENuDt4cPrB
6 changes: 0 additions & 6 deletions .travis/build_docs.sh

This file was deleted.

7 changes: 0 additions & 7 deletions .travis/create_release.sh

This file was deleted.

33 changes: 0 additions & 33 deletions .travis/create_release_archive.sh

This file was deleted.

10 changes: 10 additions & 0 deletions .travis/get_project_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
#If building a new version from a release branch - then version is taken from release branch name
if [[ "${CURRENT_BRANCH}" =~ ^release/v[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then
version=${CURRENT_BRANCH#release\/}
version=`sed -r "s/(v?[0-9]+\.)([0-9]+\.)([0-9]+)(-.*)/\1\2\3\.${UTPLSQL_BUILD_NO}\4/" <<< "${version}"`
echo ${version} > VERSION
else
version=`cat VERSION`
fi
echo ${version}
4 changes: 0 additions & 4 deletions .travis/install_libraries.sh

This file was deleted.

68 changes: 34 additions & 34 deletions .travis/push_docs_to_gh_pages.sh
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
#!/bin/bash

# Many aspsects of this came from https://gist.github.com/domenic/ec8b0fc8ab45f39403dd
# Significant alterations
# - Avoid pulling all history for cloned repo
# - Support for multiple copies of documenation,
# - Avoid pulling all history for cloned repo
# - Support for multiple copies of documenation,
# - only clearing out latest
# - doc-history.md logging doc history
# - Wrapped calls with actual encrypt keys with > /dev/null 2> /dev/null4

# How to run:
# How to run:
# - From repository root .travis/push_docs_to_gh_pages.sh

# Required files / directories (relative from repo root)
# - Folder : "site" with that contains latest docs
# - File : ".travis/deploy_key.enc" SSH deployment key encrypted by Travis command line tool
# - File : ".travis/deploy_key.enc" SSH deployment key encrypted by Travis command line tool

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

# Pull requests are special...
# They won't have acceess to the encrypted variables.
# This prevent access to the Encrypted SSH Key
# Regardless we don't want a pull request automatically updating the repository
if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
# Regardless we don't want a pull request automatically updating the repository
if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then

# ENV Variable checks are to help with configuration troubleshooting
# they silently exit with unique message. Anyone one of them not set
# can be used to turn off this functionality.
# For example a feature branch in the master repository that we don't want docs produced for yet.
# can be used to turn off this functionality.
# For example a feature branch in the master repository that we don't want docs produced for yet.
[[ -n "$PAGES_VERSION_BASE" ]] || { echo "PAGES_VERSION_BASE Missing"; exit 0; }
[[ -n "$PAGES_TARGET_BRANCH" ]] || { echo "PAGES_TARGET_BRANCH Missing"; exit 0; }
[[ -n "$ENCRYPTION_LABEL" ]] || { echo "ENCRYPTION_LABEL Missing"; exit 0; }

# Fail because required script to generate documenation must have not been run, or was changed.
[[ -d ./site ]] || { echo "site directory not found"; exit 1; }

# Save some useful information
REPO=`git config remote.origin.url`
SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:}
Expand All @@ -50,32 +50,32 @@ if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
cd pages
git clone --depth 1 $REPO .
PAGES_BRANCH_EXISTS=$(git ls-remote --heads $REPO $PAGES_TARGET_BRANCH)

if [ -n "$PAGES_BRANCH_EXISTS" ] ; then
echo "Pages Branch Found"
echo "-$PAGES_BRANCH_EXISTS-"
git remote set-branches origin $PAGES_TARGET_BRANCH
git fetch --depth 1 origin $PAGES_TARGET_BRANCH
git checkout $PAGES_TARGET_BRANCH
git fetch --depth 1 origin $PAGES_TARGET_BRANCH
git checkout $PAGES_TARGET_BRANCH
else
echo "Creating Pages Branch"
git checkout --orphan $PAGES_TARGET_BRANCH
git rm -rf .
fi
#clear out latest and copy site contents to it.
git checkout --orphan $PAGES_TARGET_BRANCH
git rm -rf .
fi

#clear out latest and copy site contents to it.
echo "updating $VERSION_BASE/latest"
mkdir -p $PAGES_VERSION_BASE/latest
mkdir -p $PAGES_VERSION_BASE/latest
rm -rf $PAGES_VERSION_BASE/latest/**./* || exit 0
cp -a ../site/. $PAGES_VERSION_BASE/latest
cp -a ../docs/html/. $PAGES_VERSION_BASE/latest

# If a Tagged Build then copy to it's own directory as well.
if [ -n "$TRAVIS_TAG" ]; then
echo "Creating $PAGES_VERSION_BASE/$TRAVIS_TAG"
mkdir -p $PAGES_VERSION_BASE/$TRAVIS_TAG || exit 0
cp -a ../site/. $PAGES_VERSION_BASE/$TRAVIS_TAG
cp -a ../docs/html/. $PAGES_VERSION_BASE/$TRAVIS_TAG
fi

#Check if there are doc changes, if none exit the script
if [[ -z `git diff --exit-code` ]] && [ -n "$PAGES_BRANCH_EXISTS" ] ; then
echo "No changes to docs detected."
Expand All @@ -84,7 +84,7 @@ if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then

#Chganges where detected, so it's safe to write to log.
now=$(date +"%d %b %Y - %r")
export latest=" - [Latest Doc Change]($PAGES_VERSION_BASE/latest/) - Created $now"
export latest=" - [Latest Doc Change]($PAGES_VERSION_BASE/latest/) - Created $now"
if [ ! -f doc-history.md ]; then
echo "<!-- Auto generated in .travis/push_docs_to_gh_pages.sh -->" >doc-history.md
echo "#Doc Generation Log" >>doc-history.md
Expand All @@ -93,13 +93,13 @@ if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
echo "" >>doc-history.md
echo "##Released Version Doc History" >>doc-history.md
echo "" >>doc-history.md
fi
fi
if [ -n "$TRAVIS_TAG" ]; then
echo " - [$TRAVIS_TAG]($PAGES_VERSION_BASE/$TRAVIS_TAG/) - Created $now" >>doc-history.md
fi
fi

#replace 4th line in log
sed -i '4s@.*@'"$latest"'@' doc-history.md
sed -i '4s@.*@'"$latest"'@' doc-history.md

#Setup Git with Commiter info
git config user.name "Travis CI"
Expand All @@ -108,7 +108,7 @@ if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
#Add and Commit the changes back to pages repo.
git add .
git commit -m "Deploy to GitHub Pages: ${SHA}"

#unencrypt and configure deployment key
[[ -e ../.travis/deploy_key.enc ]] || { echo ".travis/deploy_key.enc file not found"; exit 1; }
ENCRYPTED_KEY_VAR="encrypted_${ENCRYPTION_LABEL}_key"
Expand All @@ -118,9 +118,9 @@ if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
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
chmod 600 ../.travis/deploy_key
eval `ssh-agent -s`
ssh-add ../.travis/deploy_key
ssh-add ../.travis/deploy_key

# Now that we're all set up, we can push.
echo "git push $SSH_REPO $PAGES_TARGET_BRANCH"
git push $SSH_REPO $PAGES_TARGET_BRANCH
git push $SSH_REPO $PAGES_TARGET_BRANCH
fi
1 change: 0 additions & 1 deletion .travis/python_req.txt

This file was deleted.

4 changes: 4 additions & 0 deletions .travis/release/build_docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
# Change working directory to project root
cd "${UTPLSQL_PROJECT_ROOT}"
mkdocs build --clean --strict
24 changes: 24 additions & 0 deletions .travis/release/commit_and_push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

#inspired by:
# https://github.com/travis-ci/travis-ci/issues/1476
# http://stackoverflow.com/questions/36915499/push-to-git-master-branch-from-travis-ci
current_dir=`pwd`
commit_message="${1}"

cd "${UTPLSQL_PROJECT_ROOT}"

git config --global user.email "builds@travis-ci.com"
git config --global user.name "${UTPLSQL_BUILD_USER_NAME}"

echo Adding new/modified/removed files
git add --all .
echo Commiting changes
git commit --quiet -m "${commit_message}"
echo Pushing

# As suggested here: https://github.com/blog/1270-easier-builds-and-deployments-using-git-over-https-and-oauth
# "To avoid writing tokens to disk, don't clone. Instead, just use the full git URL in your push/pull operations (with `.git` suffix)"
git push --quiet https://${github_api_token}@github.com/${UTPLSQL_REPO}.git HEAD:${CURRENT_BRANCH}

cd "${current_dir}"
8 changes: 8 additions & 0 deletions .travis/release/create_tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

COMMIT_SHA=`git rev-parse HEAD`

#github API documentation: https://developer.github.com/v3/repos/releases/#create-a-release
#using https://stedolan.github.io/jq/
curl -H "Authorization: token ${github_api_token}" \
-X POST --data '{"name":"'${UTPLSQL_VERSION}'","tag_name":"'${UTPLSQL_VERSION}'","target_commitish":"'${COMMIT_SHA}'","prerelease":true' "https://api.github.com/repos/${UTPLSQL_REPO}/releases"

0 comments on commit c532aa7

Please sign in to comment.