-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from walter-weinmann/wwe_rebar3
Activating Travis CI.
- Loading branch information
Showing
6 changed files
with
241 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Copyright (c) 2013, Christopher Bandy | ||
|
||
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. | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
[![Build](https://travis-ci.org/cbandy/travis-oracle.svg?branch=master)](https://travis-ci.org/cbandy/travis-oracle) | ||
|
||
Use [Oracle Database Express Edition][] in your builds on [Travis CI][]. | ||
|
||
[Oracle Database Express Edition]: http://www.oracle.com/technetwork/database/database-technologies/express-edition/overview/index.html | ||
[Travis CI]: https://travis-ci.org/ | ||
|
||
|
||
Usage | ||
----- | ||
|
||
To use this tool, you must have an Oracle account with which you have accepted | ||
the current license agreement for [Oracle Database Express Edition][]. | ||
|
||
1. Add your Oracle username and password to your build [environment variables][], | ||
either as hidden repository settings or encrypted variables: | ||
|
||
| Variable Name | Value | | ||
| -------------------------- | ------------- | | ||
| `ORACLE_LOGIN_ssousername` | your username | | ||
| `ORACLE_LOGIN_password` | your password | | ||
|
||
2. Add the version information to your build environment variables: | ||
|
||
```yaml | ||
- ORACLE_COOKIE=sqldev | ||
- ORACLE_FILE=oracle11g/xe/oracle-xe-11.2.0-1.0.x86_64.rpm.zip | ||
- ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe | ||
- ORACLE_SID=XE | ||
``` | ||
3. Download and extract the [latest release][] into your project. For example, | ||
```shell | ||
wget 'https://github.com/cbandy/travis-oracle/archive/v2.0.1.tar.gz' | ||
mkdir -p .travis/oracle | ||
tar x -C .travis/oracle --strip-components=1 -f v2.0.1.tar.gz | ||
``` | ||
|
||
4. Enable [`sudo`](https://docs.travis-ci.com/user/workers/standard-infrastructure/): | ||
|
||
```yaml | ||
sudo: required | ||
``` | ||
|
||
5. Finally, execute the extracted scripts as part of your build, usually | ||
during [`before_install`](https://docs.travis-ci.com/user/customizing-the-build/#The-Build-Lifecycle): | ||
|
||
```yaml | ||
- .travis/oracle/download.sh | ||
- .travis/oracle/install.sh | ||
``` | ||
|
||
[SQL\*Plus][] is installed to `$ORACLE_HOME/bin/sqlplus`, and the current user | ||
has both normal and DBA access without a password, i.e. `/` and `/ AS SYSDBA`. | ||
|
||
[OCI][] and [OCCI][] libraries and header files are in `$ORACLE_HOME/lib` and | ||
`$ORACLE_HOME/rdbms/public`, respectively. | ||
|
||
[environment variables]: https://docs.travis-ci.com/user/environment-variables/ | ||
[latest release]: https://github.com/cbandy/travis-oracle/releases/latest | ||
[OCCI]: http://www.oracle.com/pls/topic/lookup?ctx=xe112&id=LNCPP | ||
[OCI]: http://www.oracle.com/pls/topic/lookup?ctx=xe112&id=LNOCI | ||
[SQL\*Plus]: http://www.oracle.com/pls/topic/lookup?ctx=xe112&id=SQPUG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
// vim: set et sw=2 ts=2: | ||
"use strict"; | ||
var env = process.env; | ||
var Promise = require('bluebird'); | ||
var Phantom = Promise.promisifyAll(require('node-phantom-simple')); | ||
var PhantomError = require('node-phantom-simple/headless_error'); | ||
|
||
var credentials = Object.keys(env) | ||
.filter(function (key) { return key.indexOf('ORACLE_LOGIN_') == 0 }) | ||
.map(function (key) { return [key.substr(13), env[key]] }); | ||
|
||
if (credentials.length <= 0) { | ||
console.error("Missing ORACLE_LOGIN environment variables!"); | ||
process.exit(1); | ||
} | ||
|
||
Phantom.createAsync({ parameters: { 'ssl-protocol': 'tlsv1' } }).then(function (browser) { | ||
browser = Promise.promisifyAll(browser, { suffix: 'Promise' }); | ||
|
||
// Configure the browser, open a tab | ||
return browser | ||
.addCookiePromise({'name': 'oraclelicense', 'value': "accept-" + env['ORACLE_COOKIE'] + "-cookie", 'domain': '.oracle.com' }) | ||
.then(function () { | ||
return browser.createPagePromise(); | ||
}) | ||
.then(function (page) { | ||
page = Promise.promisifyAll(page, { suffix: 'Promise' }); | ||
|
||
// Configure the tab | ||
page.onResourceError = console.error.bind(console); | ||
return page | ||
.setPromise('settings.userAgent', env['USER_AGENT']) // PhantomJS configures the UA per tab | ||
|
||
// Request the file, wait for the login page | ||
.then(function () { | ||
return page.openPromise("https://edelivery.oracle.com/akam/otn/linux/" + env['ORACLE_FILE']).then(function (status) { | ||
if (status != 'success') throw "Unable to connect to oracle.com"; | ||
return page.waitForSelectorPromise('input[type=password]', 5000); | ||
}) | ||
.catch(PhantomError, function (err) { | ||
return page.getPromise('plainText').then(function (text) { | ||
console.error("Unable to load login page. Last response was:\n" + text); | ||
throw err; | ||
}); | ||
}); | ||
}) | ||
|
||
// Export cookies for cURL | ||
.then(function () { | ||
return page.getPromise('cookies').then(function (cookies) { | ||
var data = ""; | ||
for (var i = 0; i < cookies.length; ++i) { | ||
var cookie = cookies[i]; | ||
data += cookie.domain + "\tTRUE\t" + cookie.path + "\t" | ||
+ (cookie.secure ? "TRUE" : "FALSE") + "\t0\t" | ||
+ cookie.name + "\t" + cookie.value + "\n"; | ||
} | ||
return Promise.promisifyAll(require('fs')).writeFileAsync(env['COOKIES'], data); | ||
}); | ||
}) | ||
|
||
// Submit the login form using cURL | ||
.then(function () { | ||
return page.evaluatePromise(function () { | ||
var $form = jQuery(document.forms[0]); | ||
return { | ||
action: $form.prop('action'), | ||
data: $form.serialize() | ||
}; | ||
}) | ||
.then(function (form) { | ||
return browser.exitPromise().then(function () { | ||
var unapplied = credentials.filter(function (tuple) { | ||
var applied = false; | ||
form.data = form.data.replace(tuple[0] + '=', function (name) { | ||
applied = true; | ||
return name + encodeURIComponent(tuple[1]); | ||
}); | ||
return !applied; | ||
}) | ||
.map(function (tuple) { return tuple[0] }); | ||
|
||
if (unapplied.length > 0) { | ||
console.warn("Unable to use all ORACLE_LOGIN environment variables: %j", unapplied); | ||
} | ||
|
||
var cmd = ['curl', [ | ||
'--cookie', env['COOKIES'], | ||
'--cookie-jar', env['COOKIES'], | ||
'--data', '@-', | ||
'--location', | ||
'--output', require('path').basename(env['ORACLE_FILE']), | ||
'--user-agent', env['USER_AGENT'], | ||
form.action | ||
]]; | ||
|
||
console.info("Executing %j", cmd); | ||
|
||
var child_process = require('child_process'); | ||
var child = child_process.spawn.apply(child_process, cmd.concat({ stdio: ['pipe', 1, 2] })); | ||
child.on('exit', process.exit); | ||
child.stdin.end(form.data); | ||
}); | ||
}); | ||
}) | ||
.catch(function (err) { | ||
console.error(err); | ||
browser.on('exit', function () { process.exit(1); }); | ||
browser.exit(); | ||
}); | ||
}); | ||
}) | ||
.catch(function (err) { | ||
console.error(err); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/sh -e | ||
|
||
[ -n "$ORACLE_COOKIE" ] || { echo "Missing ORACLE_COOKIE environment variable!"; exit 1; } | ||
[ -n "$ORACLE_FILE" ] || { echo "Missing ORACLE_FILE environment variable!"; exit 1; } | ||
|
||
cd "$(dirname "$(readlink -f "$0")")" | ||
|
||
npm install bluebird node-phantom-simple | ||
|
||
export COOKIES='cookies.txt' | ||
export USER_AGENT='Mozilla/5.0' | ||
|
||
echo > "$COOKIES" | ||
chmod 600 "$COOKIES" | ||
|
||
exec node download.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/sh -e | ||
|
||
[ -n "$ORACLE_FILE" ] || { echo "Missing ORACLE_FILE environment variable!"; exit 1; } | ||
[ -n "$ORACLE_HOME" ] || { echo "Missing ORACLE_HOME environment variable!"; exit 1; } | ||
|
||
ORACLE_RPM="$(basename $ORACLE_FILE .zip)" | ||
|
||
cd "$(dirname "$(readlink -f "$0")")" | ||
|
||
dpkg -s bc libaio1 rpm unzip > /dev/null 2>&1 || | ||
( sudo apt-get -qq update && sudo apt-get --no-install-recommends -qq install bc libaio1 rpm unzip ) | ||
|
||
df -B1 /dev/shm | awk 'END { if ($1 != "shmfs" && $1 != "tmpfs" || $2 < 2147483648) exit 1 }' || | ||
( sudo rm -r /dev/shm && sudo mkdir /dev/shm && sudo mount -t tmpfs shmfs -o size=2G /dev/shm ) | ||
|
||
test -f /sbin/chkconfig || | ||
( echo '#!/bin/sh' | sudo tee /sbin/chkconfig > /dev/null && sudo chmod u+x /sbin/chkconfig ) | ||
|
||
test -d /var/lock/subsys || sudo mkdir /var/lock/subsys | ||
|
||
unzip -j "$(basename $ORACLE_FILE)" "*/$ORACLE_RPM" | ||
sudo rpm --install --nodeps --nopre "$ORACLE_RPM" | ||
|
||
echo 'OS_AUTHENT_PREFIX=""' | sudo tee -a "$ORACLE_HOME/config/scripts/init.ora" > /dev/null | ||
sudo usermod -aG dba $USER | ||
|
||
( echo ; echo ; echo travis ; echo travis ; echo n ) | sudo AWK='/usr/bin/awk' /etc/init.d/oracle-xe configure | ||
|
||
"$ORACLE_HOME/bin/sqlplus" -L -S / AS SYSDBA <<SQL | ||
CREATE USER $USER IDENTIFIED EXTERNALLY; | ||
GRANT CONNECT, RESOURCE TO $USER; | ||
SQL |