Skip to content

Commit 469e175

Browse files
committed
Merge pull request #36 from rsim/feeature/travis-ci-builds
Setup CI build on travis-ci.org
2 parents 17b02d2 + 777a60f commit 469e175

File tree

11 files changed

+275
-2
lines changed

11 files changed

+275
-2
lines changed

.travis.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
sudo: required
2+
3+
env:
4+
global:
5+
- ORACLE_COOKIE=sqldev
6+
- ORACLE_FILE=oracle11g/xe/oracle-xe-11.2.0-1.0.x86_64.rpm.zip
7+
- ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
8+
- NLS_LANG=AMERICAN_AMERICA.AL32UTF8
9+
- ORACLE_BASE=/u01/app/oracle
10+
- LD_LIBRARY_PATH=$ORACLE_HOME/lib
11+
- PATH=$PATH:$ORACLE_HOME/jdbc/lib
12+
- DATABASE_VERSION=11.2.0.2
13+
- ORACLE_SID=XE
14+
- DATABASE_NAME=XE
15+
# - JRUBY_OPTS='--ng'
16+
- ORA_SDTZ='Europe/London' #Needed as a client parameter
17+
- TZ='Europe/London' #Needed as a DB Server parameter
18+
19+
before_install:
20+
- chmod +x .travis/oracle/download.sh
21+
- chmod +x .travis/oracle/install.sh
22+
- chmod +x .travis/setup_accounts.sh
23+
24+
install:
25+
- .travis/oracle/download.sh
26+
- .travis/oracle/install.sh
27+
- .travis/setup_accounts.sh
28+
- bundle install
29+
30+
language: ruby
31+
rvm:
32+
- 2.3.1
33+
- 2.3.0
34+
- 2.2.4
35+
- 1.9.3
36+
- jruby-1.7.9
37+
- jruby-9.0.5.0
38+
- jruby-9.1.0.0

.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

.travis/setup_accounts.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
set -ev
4+
5+
"$ORACLE_HOME/bin/sqlplus" -L -S / AS SYSDBA <<SQL
6+
@@spec/support/unlock_and_setup_hr_user.sql
7+
SQL

Gemfile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@ gem 'nokogiri', '~> 1.6.0'
99
group :development do
1010
gem 'jeweler', '~> 2.0.1'
1111

12-
# gem 'ruby-oci8', '~> 2.1.0'
13-
gem 'ruby-oci8', :git => 'git://github.com/kubo/ruby-oci8.git', :platforms => :mri
12+
platforms :ruby, :mswin, :mingw do
13+
gem 'ruby-oci8', '~> 2.1'
14+
end
15+
# gem 'ruby-oci8', :git => 'git://github.com/kubo/ruby-oci8.git', :platforms => :mri
1416
gem 'rspec_junit_formatter'
1517
end
18+
19+
group :test do
20+
gem 'rake', '>= 10.0'
21+
end

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
[![Build Status](https://travis-ci.org/rsim/ruby-plsql-spec.svg?branch=master)](https://travis-ci.org/rsim/ruby-plsql-spec)
2+
13
ruby-plsql-spec
24
===============
35
PL/SQL unit testing with Ruby

Rakefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ RSpec::Core::RakeTask.new(:rcov) do |t|
3535
end
3636

3737
task :default => :spec
38+
task :test => :spec
3839

3940
require 'rdoc/task'
4041
Rake::RDocTask.new do |rdoc|
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
alter user hr identified by hr account unlock;
2+
grant execute on dbms_lock to hr;

0 commit comments

Comments
 (0)