Skip to content

Commit b73e53a

Browse files
committed
TravisCI is now able to kick-in to run the project and the tests.
Added Travis configuration. Added create user script. Added RunAllExamplesAsTests.sql so failing examples will make build fail Added slack channel notifications.
1 parent b647d4a commit b73e53a

12 files changed

Lines changed: 315 additions & 0 deletions

File tree

.travis.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
sudo: required
2+
3+
language: bash
4+
5+
env:
6+
global:
7+
- ORACLE_COOKIE=sqldev
8+
- ORACLE_FILE=oracle11g/xe/oracle-xe-11.2.0-1.0.x86_64.rpm.zip
9+
- ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
10+
- NLS_LANG=AMERICAN_AMERICA.AL32UTF8
11+
- ORACLE_BASE=/u01/app/oracle
12+
- LD_LIBRARY_PATH=$ORACLE_HOME/lib
13+
- PATH=$PATH:$ORACLE_HOME/jdbc/lib:$ORACLE_HOME/bin
14+
- DATABASE_VERSION=11.2.0.2
15+
- ORACLE_SID=XE
16+
- DATABASE_NAME=XE
17+
- ORA_SDTZ='Europe/London' #Needed as a client parameter
18+
- TZ='Europe/London' #Needed as a DB Server parameter
19+
20+
install:
21+
- bash .travis/oracle/download.sh
22+
- bash .travis/oracle/install.sh
23+
24+
script:
25+
- bash install.sh
26+
- bash examples.sh
27+
- bash test.sh
28+
29+
notifications:
30+
slack: utplsql:oiMuXO95TvKeAUENuDt4cPrB
31+

.travis/oracle/LICENSE

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Copyright (c) 2013, Christopher Bandy
2+
3+
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
4+
5+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

.travis/oracle/README.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
[![Build](https://travis-ci.org/cbandy/travis-oracle.svg?branch=master)](https://travis-ci.org/cbandy/travis-oracle)
2+
3+
Use [Oracle Database Express Edition][] in your builds on [Travis CI][].
4+
5+
[Oracle Database Express Edition]: http://www.oracle.com/technetwork/database/database-technologies/express-edition/overview/index.html
6+
[Travis CI]: https://travis-ci.org/
7+
8+
9+
Usage
10+
-----
11+
12+
To use this tool, you must have an Oracle account with which you have accepted
13+
the current license agreement for [Oracle Database Express Edition][].
14+
15+
1. Add your Oracle username and password to your build [environment variables][],
16+
either as hidden repository settings or encrypted variables:
17+
18+
| Variable Name | Value |
19+
| -------------------------- | ------------- |
20+
| `ORACLE_LOGIN_ssousername` | your username |
21+
| `ORACLE_LOGIN_password` | your password |
22+
23+
2. Add the version information to your build environment variables:
24+
25+
```yaml
26+
- ORACLE_COOKIE=sqldev
27+
- ORACLE_FILE=oracle11g/xe/oracle-xe-11.2.0-1.0.x86_64.rpm.zip
28+
- ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
29+
- ORACLE_SID=XE
30+
```
31+
32+
3. Download and extract the [latest release][] into your project. For example,
33+
34+
```shell
35+
wget 'https://github.com/cbandy/travis-oracle/archive/v2.0.0.tar.gz'
36+
mkdir -p .travis/oracle
37+
tar xz --strip-components 1 -C .travis/oracle -f v2.0.0.tar.gz
38+
```
39+
40+
4. Enable [`sudo`](https://docs.travis-ci.com/user/workers/standard-infrastructure/):
41+
42+
```yaml
43+
sudo: required
44+
```
45+
46+
5. Finally, execute the extracted scripts as part of your build, usually
47+
during [`before_install`](https://docs.travis-ci.com/user/customizing-the-build/#The-Build-Lifecycle):
48+
49+
```yaml
50+
- .travis/oracle/download.sh
51+
- .travis/oracle/install.sh
52+
```
53+
54+
[SQL\*Plus][] is installed to `$ORACLE_HOME/bin/sqlplus`, and the current user
55+
has both normal and DBA access without a password, i.e. `/` and `/ AS SYSDBA`.
56+
57+
[OCI][] and [OCCI][] libraries and header files are in `$ORACLE_HOME/lib` and
58+
`$ORACLE_HOME/rdbms/public`, respectively.
59+
60+
[environment variables]: https://docs.travis-ci.com/user/environment-variables/
61+
[latest release]: https://github.com/cbandy/travis-oracle/releases/latest
62+
[OCCI]: http://www.oracle.com/pls/topic/lookup?ctx=xe112&id=LNCPP
63+
[OCI]: http://www.oracle.com/pls/topic/lookup?ctx=xe112&id=LNOCI
64+
[SQL\*Plus]: http://www.oracle.com/pls/topic/lookup?ctx=xe112&id=SQPUG

.travis/oracle/download.js

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
// vim: set et sw=2 ts=2:
2+
"use strict";
3+
var env = process.env;
4+
var Promise = require('bluebird');
5+
var Phantom = Promise.promisifyAll(require('node-phantom-simple'));
6+
var PhantomError = require('node-phantom-simple/headless_error');
7+
8+
Phantom.createAsync({ parameters: { 'ssl-protocol': 'tlsv1' } }).then(function (browser) {
9+
browser = Promise.promisifyAll(browser, { suffix: 'Promise' });
10+
11+
// Configure the browser, open a tab
12+
return browser
13+
.addCookiePromise({'name': 'oraclelicense', 'value': "accept-" + env['ORACLE_COOKIE'] + "-cookie", 'domain': '.oracle.com' })
14+
.then(function () {
15+
return browser.createPagePromise();
16+
})
17+
.then(function (page) {
18+
page = Promise.promisifyAll(page, { suffix: 'Promise' });
19+
20+
// Configure the tab
21+
page.onResourceError = console.error.bind(console);
22+
return page
23+
.setPromise('settings.userAgent', env['USER_AGENT']) // PhantomJS configures the UA per tab
24+
25+
// Request the file, wait for the login page
26+
.then(function () {
27+
return page.openPromise("https://edelivery.oracle.com/akam/otn/linux/" + env['ORACLE_FILE']).then(function (status) {
28+
if (status != 'success') throw "Unable to connect to oracle.com";
29+
return page.waitForSelectorPromise('input[type=password]', 5000);
30+
})
31+
.catch(PhantomError, function (err) {
32+
return page.getPromise('plainText').then(function (text) {
33+
console.error("Unable to load login page. Last response was:\n" + text);
34+
throw err;
35+
});
36+
});
37+
})
38+
39+
// Export cookies for cURL
40+
.then(function () {
41+
return page.getPromise('cookies').then(function (cookies) {
42+
var data = "";
43+
for (var i = 0; i < cookies.length; ++i) {
44+
var cookie = cookies[i];
45+
data += cookie.domain + "\tTRUE\t" + cookie.path + "\t"
46+
+ (cookie.secure ? "TRUE" : "FALSE") + "\t0\t"
47+
+ cookie.name + "\t" + cookie.value + "\n";
48+
}
49+
return Promise.promisifyAll(require('fs')).writeFileAsync(env['COOKIES'], data);
50+
});
51+
})
52+
53+
// Submit the login form using cURL
54+
.then(function () {
55+
return page.evaluatePromise(function () {
56+
var $form = jQuery(document.forms[0]);
57+
return {
58+
action: $form.prop('action'),
59+
data: $form.serialize()
60+
};
61+
})
62+
.then(function (form) {
63+
return browser.exitPromise().then(function () {
64+
for (var key in env) {
65+
if (key.indexOf('ORACLE_LOGIN_') == 0 && env.hasOwnProperty(key)) {
66+
var name = key.substr(13) + '=';
67+
form.data = form.data.replace(name, name + env[key]);
68+
}
69+
}
70+
71+
var cmd = ['curl', [
72+
'--cookie', env['COOKIES'],
73+
'--cookie-jar', env['COOKIES'],
74+
'--data', '@-',
75+
'--location',
76+
'--output', require('path').basename(env['ORACLE_FILE']),
77+
'--user-agent', env['USER_AGENT'],
78+
form.action
79+
]];
80+
81+
console.info("Executing %j", cmd);
82+
83+
var child_process = require('child_process');
84+
var child = child_process.spawn.apply(child_process, cmd.concat({ stdio: ['pipe', 1, 2] }));
85+
child.on('exit', process.exit);
86+
child.stdin.end(form.data);
87+
});
88+
});
89+
})
90+
.catch(function (err) {
91+
console.error(err);
92+
browser.on('exit', function () { process.exit(1); });
93+
browser.exit();
94+
});
95+
});
96+
})
97+
.catch(function (err) {
98+
console.error(err);
99+
process.exit(1);
100+
});

.travis/oracle/download.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh -e
2+
3+
[ -n "$ORACLE_COOKIE" ] || { echo "Missing ORACLE_COOKIE environment variable!"; exit 1; }
4+
[ -n "$ORACLE_FILE" ] || { echo "Missing ORACLE_FILE environment variable!"; exit 1; }
5+
6+
cd "$(dirname "$(readlink -f "$0")")"
7+
8+
npm install bluebird node-phantom-simple
9+
10+
export COOKIES='cookies.txt'
11+
export USER_AGENT='Mozilla/5.0'
12+
13+
echo > "$COOKIES"
14+
chmod 600 "$COOKIES"
15+
16+
exec node download.js

.travis/oracle/install.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/sh -e
2+
3+
[ -n "$ORACLE_FILE" ] || { echo "Missing ORACLE_FILE environment variable!"; exit 1; }
4+
[ -n "$ORACLE_HOME" ] || { echo "Missing ORACLE_HOME environment variable!"; exit 1; }
5+
6+
ORACLE_RPM="$(basename $ORACLE_FILE .zip)"
7+
8+
cd "$(dirname "$(readlink -f "$0")")"
9+
10+
sudo apt-get -qq update
11+
sudo apt-get --no-install-recommends -qq install bc libaio1 rpm unzip
12+
13+
df -B1 /dev/shm | awk 'END { if ($1 != "shmfs" && $1 != "tmpfs" || $2 < 2147483648) exit 1 }' ||
14+
( sudo rm -r /dev/shm && sudo mkdir /dev/shm && sudo mount -t tmpfs shmfs -o size=2G /dev/shm )
15+
16+
test -f /sbin/chkconfig ||
17+
( echo '#!/bin/sh' | sudo tee /sbin/chkconfig > /dev/null && sudo chmod u+x /sbin/chkconfig )
18+
19+
test -d /var/lock/subsys || sudo mkdir /var/lock/subsys
20+
21+
unzip -j "$(basename $ORACLE_FILE)" "*/$ORACLE_RPM"
22+
sudo rpm --install --nodeps --nopre "$ORACLE_RPM"
23+
24+
echo 'OS_AUTHENT_PREFIX=""' | sudo tee -a "$ORACLE_HOME/config/scripts/init.ora" > /dev/null
25+
sudo usermod -aG dba $USER
26+
27+
( echo ; echo ; echo travis ; echo travis ; echo n ) | sudo AWK='/usr/bin/awk' /etc/init.d/oracle-xe configure
28+
29+
"$ORACLE_HOME/bin/sqlplus" -L -S / AS SYSDBA <<SQL
30+
CREATE USER $USER IDENTIFIED EXTERNALLY;
31+
GRANT CONNECT, RESOURCE TO $USER;
32+
SQL

examples.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
set -ev
4+
5+
cd examples
6+
"$ORACLE_HOME/bin/sqlplus" ut3/ut3 @RunAllExamplesAsTests.sql

examples/RunAllExamplesAsTests.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
whenever sqlerror exit failure rollback
2+
whenever oserror exit failure rollback
3+
4+
@@RunAllExamples.sql
5+
6+
exit success

install.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
set -ev
4+
5+
#create user
6+
"$ORACLE_HOME/bin/sqlplus" -L -S / AS SYSDBA <<SQL
7+
@@install/create_utplsql_user.sql ut3 ut3 users
8+
SQL
9+
10+
cd source
11+
#install core of utplsql
12+
"$ORACLE_HOME/bin/sqlplus" ut3/ut3 @install.sql

install/create_utplsql_user.sql

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
whenever sqlerror exit failure rollback
2+
whenever oserror exit failure rollback
3+
4+
set echo off
5+
set feedback off
6+
set heading off
7+
set verify off
8+
9+
--make SQLPLUS parameters optional
10+
column 1 new_value 1
11+
column 2 new_value 2
12+
column 3 new_value 3
13+
select '' "1", '' "2", '' "3" from dual where rownum = 0;
14+
15+
16+
column ut3_user new_value ut3_user
17+
column ut3_pass new_value ut3_pass
18+
column ut3_tablespace new_value ut3_tablespace
19+
--do not show the values
20+
set termout off
21+
select nvl('&&1', default_user) as ut3_user,
22+
nvl('&&2', default_pass) as ut3_pass,
23+
nvl('&&3', default_ts) as ut3_tablespace
24+
from (select 'ut3' as default_user,
25+
'ut3' as default_pass,
26+
'users' as default_ts
27+
from dual);
28+
29+
create user &ut3_user identified by &ut3_pass default tablespace &ut3_tablespace;
30+
31+
grant create session, create procedure, create type, create table to &ut3_user;
32+
33+
exit success

0 commit comments

Comments
 (0)