Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 282035c

Browse files
committed
Merge branch 'develop' into feature/add_version_check
# Conflicts: # test/install_and_run_tests.sh # test/install_tests.sql # test/ut_utils/test_ut_utils.pkb
2 parents fb51b31 + bd0c89f commit 282035c

28 files changed

Lines changed: 391 additions & 129 deletions

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ release/
1212
*.gz
1313
*.zip
1414
node_modules/
15+
utPLSQL_latest_release/
16+
utPLSQL-cli/
17+
development/env.sh

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ env:
4545
- UT3_DOCKER_REPO="utplsqlv3/oracledb"
4646
- DOCKHER_HUB_REPO="${DOCKER_BASE_TAG:-$UT3_DOCKER_REPO}"
4747
#utPLSQL released version directory
48-
- UTPLSQL_DIR="utPLSQL"
48+
- UTPLSQL_DIR="utPLSQL_latest_release"
49+
- UTPLSQL_CLI_FILE="utPLSQL-cli-develop-test3.zip"
4950
matrix:
5051
- ORACLE_VERSION="${DOCKER_TAG_11G:-11g-r2-xe}" CONNECTION_STR='127.0.0.1:1521/XE' DOCKER_OPTIONS='--shm-size=1g'
5152
- ORACLE_VERSION="${DOCKER_TAG_12C:-12c-r1-se2}" CONNECTION_STR='127.0.0.1:1521/ORCLPDB1' DOCKER_OPTIONS="-v /dev/pdbs:/opt/oracle/oradata/pdbs"
@@ -68,7 +69,7 @@ before_install:
6869
#- curl -LOk $(curl --silent https://api.github.com/repos/utPLSQL/utPLSQL/releases/latest | awk '/browser_download_url/ { print $2 }' | grep ".zip" | sed 's/"//g')
6970
- git clone --depth=1 --branch=${SELFTESTING_BRANCH:-master} https://github.com/utPLSQL/utPLSQL.git $UTPLSQL_DIR
7071
# download utPLSQL-cli develop
71-
- curl -Lk -o utPLSQL-cli.zip https://bintray.com/viniciusam/utPLSQL-cli/download_file?file_path=utPLSQL-cli-develop-test3.zip
72+
- curl -Lk -o utPLSQL-cli.zip https://bintray.com/viniciusam/utPLSQL-cli/download_file?file_path=${UTPLSQL_CLI_FILE}
7273

7374
install:
7475
#- unzip utPLSQL.zip

.travis/run_examples.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ whenever oserror exit failure rollback
99
cd examples
1010
@RunAllExamplesAsTests.sql
1111
12-
conn $UT3_USER/$UT3_USER_PASSWORD@//$CONNECTION_STR
13-
@RunUserExamples.sql
14-
1512
exit
1613
1714
SQL

CONTRIBUTING.md

Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
# How to contribute
2+
3+
The following are the guidelines everyone should use to contribute to utPLSQL.
4+
Changes are welcome from all members of the Community.
5+
6+
# Getting Started
7+
8+
1. Create a [GitHub Account](https://github.com/join).
9+
2. Fork the utPLSQL Repository and setup your local Repository. _See [how to Fork](https://help.github.com/articles/fork-a-repo) article_
10+
* Each of the steps below are detailed in **Get started with development** section.
11+
* Clone your Fork to your local machine.
12+
* Configure "upstream" remote to the [utPLSQL repository](https://github.com/utPLSQL/utPLSQL.git).
13+
3. For each change you want to make:
14+
* Make sure your forked repository is up to date with upstream before you start coding. See [syncing your local repository](https://help.github.com/articles/syncing-a-fork) with upstream utPLSQL repository.
15+
* Create a new branch for your change. We use `feature/feature_name` or `bugfix/fixed_issue_name` to identify branch types.
16+
* Make your change in your new branch.
17+
* Make sure your change is covered with unit tests.
18+
* **Verify code compiles and all existing and new unit tests pass.**
19+
* The quickest way to have a Pull Request not approved, is to submit code that does not compile or pass tests.
20+
* Commit change to your local repository.
21+
* Push change to your remote repository.
22+
* Submit a [Pull Request](https://help.github.com/articles/using-pull-requests) into develop branch.
23+
* Note: local and remote branches can be deleted after pull request has been merged.
24+
25+
# Coding Standards
26+
27+
* We use snake case for all identifiers in PLSQL code. This separates keywords in names with underscores. `execute_test`
28+
* All code is lower case.
29+
* Prefixes:
30+
* Arguments to procedures and functions will start with `a_` an Example would be procedure `is_valid(a_owner_name varchar2)`
31+
* Object types and packages will start with `ut_`
32+
* Local variables `l_`
33+
* Global variables `g_`
34+
* Global Constants start with `gc_`
35+
* Types in packages, objects start with `t_`
36+
* Nested Tables start with `tt_`
37+
* varchar2 lengths are set in characters not bytes
38+
39+
40+
# Configuring local environment
41+
42+
Your local environment can be of any flavor (Unix/Linux/Windows/Mac).
43+
At minimum you need to have Oracle database 11.2 XE accessible for the project and SYS account access to install and develop utPLSQL.
44+
45+
We use four different database accounts (users) for development process.
46+
* `ut3_latest_release` - holds latest released version of utPLSQL. This schema holds the testing framework used for self-testing of utPLSQL development.
47+
* `ut3` - holds latest (current) development version of utPLSQL. This is the schema you will be working on.
48+
* `ut3_tester` - holds unit test packages for development of utPLSQL.
49+
* `ut3$user#` - used for testing accessibility to schema names with special characters.
50+
51+
52+
53+
## Get started with development
54+
55+
To get started with development, follow the below steps.
56+
57+
_If you're using Windows, run the shell scripts using `GIT bash` - Windows-based bash command line._
58+
59+
### Clone your fork of utPLSQL git repository
60+
61+
```bash
62+
# clone your fork of utPLSQL
63+
git clone https://github.com/your account/utPLSQL.git utPLSQL
64+
65+
cd utPLSQL
66+
67+
# add main project repo as upstream
68+
git remote add upstream https://github.com/utPLSQL/utPLSQL.git
69+
70+
# fetch all remote repositories
71+
git fetch --all
72+
```
73+
74+
### Prepare environment script
75+
76+
Copy the environment variables template `development/template.env.sh` to `development/env.sh`
77+
```bash
78+
cp development/template.env.sh development/env.sh
79+
chmod u+w development/env.sh
80+
```
81+
82+
You might have to adjust the following lines in `development/env.sh`:
83+
```bash
84+
export SQLCLI=sql # For sqlcl client
85+
#export SQLCLI=sqlplus # For sqlplus client
86+
export CONNECTION_STR=127.0.0.1:1521/xe # Adjust the connect string
87+
export ORACLE_PWD=oracle # Adjust your local SYS password
88+
```
89+
90+
### Download utPLSQL release sources and utplsq-cli
91+
92+
The below script is fetching latest release version from utPLSQL repository. Latest release version is used for self-testing.
93+
```bash
94+
development/refresh_sources.sh
95+
```
96+
97+
### Setup local database for utPLSQL development
98+
99+
```bash
100+
development/install.sh
101+
```
102+
103+
### That's it
104+
105+
You now have the following:
106+
- sources from `develop` branch of your fork of utPLSQL repository in `utPLSQL/ut3_latest_release` directory
107+
- sources from `master` branch of utPLSQL/utPLSQL repository in `utPLSQL/ut3_latest_release` directory
108+
- binaries of `utplsql-cli` in `utPLSQL/utPLSQL-cli` directory
109+
- database users created
110+
- utPLSQL develop version deployed to `ut3` schema
111+
- utPLSQL released version deployed to `ut3_latest_release`
112+
113+
At any time, if you need to refresh your database, the below scripts might be helpful.
114+
115+
## Running unit tests
116+
117+
Currently we use two forms of unit tests in our CI build:
118+
- sql scripts as unit tests in the `old_tests` directory
119+
- utPLSQL v3 unit tests in the `test` directory
120+
121+
Before you push any changes and create a pull request to the utPLSQL project repository, make sure that all of the tests are executing successfully in your local environment.
122+
123+
Every new functionality needs to be documented by unit tests that cover both happy-path scenarios as well as edge-cases and exception paths.
124+
125+
> **Important notice:**
126+
> We do our best to keep utPLSQL covered with unit tests.
127+
> Lack of sufficient unit testing is a perfect reason for PR to be rejected.
128+
129+
To suite of legacy unit tests execute:
130+
```bash
131+
development/env.sh
132+
old_tests/runAll.sh
133+
```
134+
To run a full suite of unit tests execute:
135+
```bash
136+
development/env.sh
137+
test/install_and_run_tests.sh
138+
```
139+
140+
You can review the results of tests as well as see information about code coverage in `./old_tests/coverage.html, ./coverage.html` files.
141+
142+
143+
## Cleanup of utPLSQL installation in local database
144+
145+
```bash
146+
development/cleanup.sh
147+
```
148+
149+
## Reinstalling utPLSQL development in `ut3` schema
150+
151+
```bash
152+
development/refresh_ut3.sh
153+
```
154+
155+
## Refreshing after release
156+
157+
Whenever a new version of utPLSQL or a new version of utPLSQL-cli is available, use `development/refresh_sources.sh` to refresh files in your local project folders.
158+
159+
160+
## Modules
161+
162+
Below diagram gives a high-level overview of utPLSQL v3 modules and their dependencies.
163+
Dependencies to `ut_util` are not shown as most of modules are depending on it.
164+
165+
![utPLSQL V3 Modules](development/utPSLQLv3-modules.png)
166+
167+
168+
## Build Environment
169+
170+
We are using private docker images to test utPLSQL for our Travis CI builds. The following versions of Oracle Database are being used.
171+
172+
* 11g XE R2
173+
* 12c SE R1
174+
* 12c SE R2
175+
176+
These images are based on the slimmed versions [official dockerfiles released by Oracle](https://github.com/utPLSQL/docker-scripts), but due to licensing restrictions, we can't make the images public.
177+
You can build your own and use it locally, or push to a private docker repository.
178+
179+
The build steps are simple if you already have some experience using Docker. You can find detailed information about how to build your own image with a running database in: [example of creating an image with pre-built DB](https://github.com/oracle/docker-images/blob/master/OracleDatabase/samples/prebuiltdb/README.md)
180+
181+
> You can find more info about the official Oracle images on the [Oracle Database on Docker](https://github.com/oracle/docker-images/tree/master/OracleDatabase) GitHub page.
182+
183+
> If you are new to Docker, you can start by reading the [Getting Started With Docker](https://docs.docker.com/engine/getstarted/) docs.
184+
185+
### Docker Build Notes
186+
187+
* You need to comment out the VOLUME line. This step is required, because volumes are not saved when using `docker commit` command.
188+
* When the build process is complete, you will run the container to install the database. Once everything is set up and you see the message "DATABASE IS READY!", you may change the password and stop the running container. After the container is stopped, you can safely commit the container.
189+
* You can use the --squash experimental docker tag to reduce the image size. Example:
190+
```
191+
docker build --force-rm --no-cache --squash -t oracle/db-prebuilt .
192+
```
193+
194+
Travis will use your Docker Hub credentials to pull the private images, and the following secure environment variables must be defined.
195+
196+
Variable | Description
197+
---------|------------
198+
**DOCKER_USER**<br />**DOCKER_PASSWORD** | _Your Docker Hub website credentials. They will be used to pull the private database images._
199+
200+
### SQLCL
201+
202+
Our build configuration uses SQLCL to run the scripts, and you need to configure a few additional secure environment variables. After the first build, the downloaded file will be cached.
203+
204+
Variable | Description
205+
---------|------------
206+
**ORACLE_OTN_USER<br />ORACLE_OTN_PASSWORD** | _Your Oracle website credentials. They will be used to download SQLCL._
207+
208+
209+
## New to GIT
210+
211+
If you are new to GIT here are some links to help you with understanding how it works.
212+
213+
- [GIT Documentation](http://git-scm.com/doc)
214+
- [Atlassian Git Tutorial](https://www.atlassian.com/git/tutorial/git-basics)
215+
- [What are other resources for learning Git and GitHub](https://help.github.com/articles/what-are-other-good-resources-for-learning-git-and-github)

development/cleanup.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
3+
#goto git root directory
4+
git rev-parse && cd "$(git rev-parse --show-cdup)"
5+
6+
. development/env.sh
7+
8+
"${SQLCLI}" sys/${ORACLE_PWD}@//${CONNECTION_STR} AS SYSDBA <<-SQL
9+
set echo on
10+
drop user ${UT3_OWNER} cascade;
11+
drop user ${UT3_RELEASE_VERSION_SCHEMA} cascade;
12+
drop user ${UT3_TESTER} cascade;
13+
drop user ${UT3_USER} cascade;
14+
15+
begin
16+
for i in (
17+
select decode(owner,'PUBLIC','drop public synonym "','drop synonym "'||owner||'"."')|| synonym_name ||'"' drop_orphaned_synonym from dba_synonyms a
18+
where not exists (select null from dba_objects b where a.table_name=b.object_name and a.table_owner=b.owner )
19+
and a.table_owner <> 'SYS'
20+
) loop
21+
execute immediate i.drop_orphaned_synonym;
22+
end loop;
23+
end;
24+
/
25+
exit
26+
SQL

development/install.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
#goto git root directory
4+
git rev-parse && cd "$(git rev-parse --show-cdup)"
5+
6+
. development/env.sh
7+
8+
development/cleanup.sh
9+
10+
.travis/install.sh
11+
.travis/install_utplsql_release.sh
12+
.travis/create_additional_grants_for_old_tests.sh

development/readme.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

development/refresh_sources.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
3+
#goto git root directory
4+
git rev-parse && cd "$(git rev-parse --show-cdup)"
5+
6+
. development/env.sh
7+
8+
# remove sub-direcotry containing master branch shallow copy
9+
rm -rf ${UTPLSQL_DIR:-utPLSQL_latest_release}
10+
# clone utPLSQL master branch from upstream into utPLSQL sub-directory of your project
11+
git clone --depth=1 --branch=${SELFTESTING_BRANCH:-master} https://github.com/utPLSQL/utPLSQL.git ${UTPLSQL_DIR:-utPLSQL_latest_release}
12+
13+
rm -rf utPLSQL-cli/*
14+
# download beta version of utPLSQL-cli
15+
curl -Lk -o utPLSQL-cli.zip https://bintray.com/viniciusam/utPLSQL-cli/download_file?file_path=${UTPLSQL_CLI_FILE}
16+
# unzip utPLSQL-cli and remove the zip file
17+
unzip utPLSQL-cli.zip && chmod u+x utPLSQL-cli/bin/utplsql && rm utPLSQL-cli.zip
18+

development/refresh_ut3.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
3+
#goto git root directory
4+
git rev-parse && cd "$(git rev-parse --show-cdup)"
5+
6+
. development/env.sh
7+
8+
cd source
9+
10+
"${SQLCLI}" sys/${ORACLE_PWD}@//${CONNECTION_STR} AS SYSDBA <<-SQL
11+
@uninstall ${UT3_OWNER}
12+
@install ${UT3_OWNER}
13+
exit
14+
SQL

development/template.env.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
3+
export SQLCLI=sql # For sqlcl client
4+
#export SQLCLI=sqlplus # For sqlplus client
5+
export CONNECTION_STR=127.0.0.1:1521/xe # Adjust the connect string
6+
export ORACLE_PWD=oracle # Adjust your local SYS password
7+
export UTPLSQL_CLI_FILE="utPLSQL-cli-develop-test3.zip"
8+
export SELFTESTING_BRANCH=develop
9+
10+
export UTPLSQL_DIR="utPLSQL_latest_release"
11+
export UT3_OWNER=ut3
12+
export UT3_OWNER_PASSWORD=ut3
13+
export UT3_RELEASE_VERSION_SCHEMA=ut3_latest_release
14+
export UT3_TESTER=ut3_tester
15+
export UT3_TESTER_PASSWORD=ut3
16+
export UT3_TABLESPACE=users
17+
export UT3_USER="UT3\$USER#"
18+
export UT3_USER_PASSWORD=ut3
19+

0 commit comments

Comments
 (0)