Skip to content

Commit 2787bd7

Browse files
authored
Merge pull request #1 from utPLSQL/feature/initial_version
Feature/initial version
2 parents 6ff54b1 + 16a42e6 commit 2787bd7

18 files changed

+4932
-0
lines changed

.travis.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
sudo: required
2+
3+
language: java
4+
jdk:
5+
- oraclejdk8
6+
7+
addons:
8+
sonarqube:
9+
organization: utplsql
10+
token:
11+
secure: ${SONAR_TOKEN}
12+
branches:
13+
- master
14+
15+
env:
16+
global:
17+
#Oracle 11g XE R2 variables
18+
- ORACLE_COOKIE=sqldev
19+
- ORACLE_FILE=oracle11g/xe/oracle-xe-11.2.0-1.0.x86_64.rpm.zip
20+
- ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
21+
- ORACLE_SID=XE
22+
#Adding SQLPlus to path
23+
- PATH=$PATH:$ORACLE_HOME/bin
24+
# project variables
25+
- DB_USER=ut3_demo
26+
- DB_PASS=LHZYPbWvYdu2ctp8
27+
##utPLSQL variables
28+
- UTPLSQL_DIR="utPLSQL"
29+
- UTPLSQL_V2_DIR="utPLSQL_V2"
30+
before_install:
31+
# download travis-oracle
32+
- wget 'https://github.com/cbandy/travis-oracle/archive/v2.0.2.tar.gz'
33+
- mkdir -p .travis/oracle
34+
- tar x -C .travis/oracle --strip-components=1 -f v2.0.2.tar.gz
35+
# download latest utPLSQL release
36+
- curl -LOk $(curl --silent https://api.github.com/repos/utPLSQL/utPLSQL/releases/latest | awk '/browser_download_url/ { print $2 }' | grep ".zip" | sed 's/"//g')
37+
- unzip -q utPLSQL.zip
38+
# download utPLSQL v.2.3.1 release
39+
- curl -LOk $(curl --silent https://api.github.com/repos/utPLSQL/utPLSQL/releases/3608515 | awk '/browser_download_url/ { print $2 }' | grep ".zip" | sed 's/"//g')
40+
- unzip -d ${UTPLSQL_V2_DIR} -q utplsql-2-3-1.zip
41+
# download utPLSQL-sql-cli
42+
- curl -Lk -o client.zip $(curl --silent https://api.github.com/repos/utPLSQL/utPLSQL-sql-cli/releases/latest | awk '/zipball_url/ { print $2 }' | sed -r 's/"|,//g')
43+
- echo $(unzip -d client client.zip && f=(client/*) && mv client/*/* . && rm -rf "${f[@]}")
44+
# download Oracle XE installer for Travis
45+
- .travis/oracle/download.sh
46+
47+
install:
48+
# Install Oracle Database
49+
- .travis/oracle/install.sh
50+
# Install utPLSQL v3
51+
- .travis/install_utplsql.sh
52+
# Install utPLSQL v2.3.1
53+
- .travis/install_utplsql_v2.3.1.sh
54+
# Create user
55+
- .travis/setup_account.sh
56+
# Install project sources and tests
57+
- source/install.sh
58+
- test/install.sh
59+
60+
script:
61+
# Run tests
62+
- ./ut_run ${DB_USER}/${DB_PASS} -source_path=source -test_path=test -f=ut_documentation_reporter -c -f=ut_coverage_sonar_reporter -o=coverage.xml -f=ut_sonar_test_reporter -o=test_results.xml
63+
# Run sonar scanner and publish to sonar
64+
- sonar-scanner

.travis/install_utplsql.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+
cd $UTPLSQL_DIR/source
6+
7+
sqlplus -S -L / AS SYSDBA @install_headless.sql
8+
9+
sqlplus -L -S / AS SYSDBA <<SQL
10+
grant select any dictionary to ut3;
11+
exit
12+
SQL

.travis/install_utplsql_v2.3.1.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
set -ev
4+
5+
cd ${UTPLSQL_V2_DIR}/code
6+
7+
sqlplus -L -S / AS SYSDBA <<SQL
8+
create user utp identified by utp default tablespace
9+
users temporary tablespace temp;
10+
11+
grant create session, create table, create procedure,
12+
create sequence, create view, create public synonym,
13+
drop public synonym to utp;
14+
15+
alter user utp quota unlimited on users;
16+
grant execute on utl_file to utp;
17+
exit
18+
SQL
19+
20+
sqlplus -S -L utp/utp <<SQL
21+
@ut_i_do.sql install
22+
exit
23+
SQL

.travis/setup_account.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+
sqlplus -L -S / AS SYSDBA <<SQL
6+
create user ${DB_USER} identified by ${DB_PASS} quota unlimited on USERS default tablespace USERS;
7+
8+
grant create session, create procedure, create type, create table, create sequence, create view to ${DB_USER};
9+
grant select any dictionary to ${DB_USER};
10+
11+
exit
12+
SQL

sonar-project.properties

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# must be unique in a given SonarQube instance
2+
sonar.projectKey=utPLSQL:utPLSQL-v2-v3-bridge
3+
# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1.
4+
sonar.projectName=utPLSQL-v2-v3-bridge
5+
sonar.organization=utplsql
6+
7+
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
8+
# Since SonarQube 4.2, this property is optional if sonar.modules is set.
9+
# If not set, SonarQube starts looking for source code from the directory containing
10+
# the sonar-project.properties file.
11+
sonar.sources=./source
12+
sonar.coverageReportPaths=./coverage.xml
13+
sonar.tests=./test
14+
sonar.testExecutionReportPaths=./test_results.xml
15+
sonar.links.issue=https://github.com/utPLSQL/utPLSQL-demo-project/issues
16+
sonar.links.ci=https://travis-ci.org/utPLSQL/utPLSQL-demo-project
17+
sonar.links.homepage=https://github.com/utPLSQL/utPLSQL-demo-project
18+
sonar.projectDescription=Demo of a project using utPLSQL, TravisCI and Sonar integrations
19+
sonar.plsql.file.suffixes=sql,tab,tps,pks,pkb,tpb,prc,fnc
20+
sonar.language=plsql
21+
22+
# Encoding of the source code. Default is default system encoding
23+
#sonar.sourceEncoding=UTF-8

source/install.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+
cd "$(dirname "$(readlink -f "$0")")"
6+
7+
sqlplus -L -S / as sysdba @install.sql utp ut3

source/install.sql

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
prompt Installing utplsql v2-v3 migration utility
2+
3+
set timing off
4+
set feedback off
5+
set verify off
6+
set heading off
7+
set linesize 1000
8+
set pagesize 0
9+
set feedback off
10+
set echo off
11+
set termout off
12+
set serveroutput on size unlimited format truncated
13+
14+
column 1 new_value 1 noprint
15+
column 2 new_value 2 noprint
16+
select null as "1", null as "2" from dual where 1=0;
17+
column sep new_value sep noprint
18+
select '--------------------------------------------------------------' as sep from dual;
19+
20+
spool params.sql.tmp
21+
22+
select
23+
case
24+
when '&&1' is null then q'[ACCEPT utplsql_v2_owner CHAR DEFAULT 'UTP' PROMPT 'Provide schema owning the utPLSQL v2 (UTP)']'
25+
else 'define utplsql_v2_owner=&&1'
26+
end
27+
from dual;
28+
select
29+
case
30+
when '&&2' is null then q'[ACCEPT utplsql_v3_owner CHAR DEFAULT 'UT3' PROMPT 'Provide schema owning the utPLSQL v3 (UT3)']'
31+
else 'define utplsql_v3_owner=&&2'
32+
end
33+
from dual;
34+
35+
spool off
36+
37+
set termout on
38+
@params.sql.tmp
39+
40+
whenever sqlerror exit failure rollback
41+
whenever oserror exit failure rollback
42+
43+
prompt &&sep
44+
begin
45+
execute immediate q'[begin dbms_output.put_line('User &&utplsql_v2_owner owns utPLSQL - version '||&&utplsql_v2_owner..utplsql.version()); end;]';
46+
exception
47+
when others then
48+
raise_application_error(-20000, 'User &&utplsql_v2_owner does not own utPLSQL v2 or current user('||user||') does not have privileges to access it.');
49+
end;
50+
/
51+
52+
prompt &&sep
53+
begin
54+
execute immediate q'[begin dbms_output.put_line('User &&utplsql_v3_owner owns '||&&utplsql_v3_owner..ut.version()); end;]';
55+
exception
56+
when others then
57+
raise_application_error(-20000, 'User &&utplsql_v3_owner does not own utPLSQL v3 or current user('||user||') does not have privileges to access it.');
58+
end;
59+
/
60+
61+
prompt &&sep
62+
prompt Using schema (&&utplsql_v2_owner) as owner of utPLSQL v2
63+
prompt Using schema (&&utplsql_v3_owner) as owner of utPLSQL v3
64+
65+
alter session set current_schema = &&utplsql_v3_owner;
66+
67+
prompt &&sep
68+
PROMPT Installing into schema &&utplsql_v3_owner
69+
prompt &&sep
70+
set feedback on
71+
set echo on
72+
grant execute on sys.utl_file to &&utplsql_v3_owner;
73+
74+
drop public synonym utassert2;
75+
drop public synonym utassert;
76+
77+
set echo off
78+
@@install_component.sql 'migration/utassert2.pks'
79+
@@install_component.sql 'migration/utassert.pks'
80+
@@install_component.sql 'migration/ut_v2_migration.pks'
81+
82+
@@install_component.sql 'migration/utassert2.pkb'
83+
@@install_component.sql 'migration/utassert.pkb'
84+
@@install_component.sql 'migration/ut_v2_migration.pkb'
85+
86+
set echo on
87+
create or replace public synonym utassert for &&utplsql_v2_owner..utassert;
88+
create or replace public synonym utassert2 for &&utplsql_v2_owner..utassert2;
89+
create or replace public synonym ut_v2_migration for ut_v2_migration;
90+
91+
grant execute on utassert to public;
92+
grant execute on utassert2 to public;
93+
grant execute on ut_v2_migration to public;
94+
95+
set echo off
96+
prompt &&sep
97+
PROMPT Installation completed successfully
98+
prompt &&sep
99+
100+
set termout off
101+
102+
/*
103+
* cleanup temporary sql files
104+
*/
105+
--try running on windows
106+
$ del *.sql.tmp
107+
--try running on linux/unix
108+
! rm *.sql.tmp
109+
110+
exit success

source/install_component.sql

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
set heading off
2+
set feedback off
3+
exec dbms_output.put_line('Installing component '||upper(regexp_substr('&&1','\/(\w*)\.',1,1,'i',1)));
4+
@@&&1
5+
show errors
6+
exec dbms_output.put_line('--------------------------------------------------------------');
7+

0 commit comments

Comments
 (0)