├── .azure_templates ├── t-extend-database-build.yml ├── t-pipeline-extend-cicd.yml ├── t-task-extend-create-docker-database.yml ├── t-task-extend-download-binaries.yml ├── t-task-extend-flyway.yml ├── t-task-extend-git-clone.yml ├── t-task-extend-sonarcloud.yml ├── t-task-extend-sqlcl-liquibase.yml ├── t-task-extend-sqlcl.yml ├── t-task-extend-utplsqlcli.yml └── vars │ └── vars-global.yml ├── .github └── workflows │ └── build.yml ├── .gitignore ├── LICENSE ├── README.md ├── scripts ├── 0_start_db.sh ├── 1_install_utplsql.sh ├── 2_install_demo_project.sh ├── 3_install_tests.sh └── 4_run_tests.sh ├── sonar-project.properties ├── source ├── award_bonus │ ├── R__ut3_demo.award_bonus.prc │ ├── V1.01__employees_test.sql │ └── award_bonus.xml ├── between_string │ ├── R__ut3_demo.betwnstr.fnc │ └── between_string.xml ├── create_user.sql ├── install.sql └── remove_rooms_by_name │ ├── R__ut3_demo.remove_rooms_by_name.prc │ ├── V1.02__rooms.sql │ └── remove_rooms_by_name.xml ├── test ├── award_bonus │ ├── ut3_demo.test_award_bonus.pkb │ └── ut3_demo.test_award_bonus.pks ├── between_string │ ├── ut3_demo.test_betwnstr.pkb │ └── ut3_demo.test_betwnstr.pks ├── install.sql └── remove_rooms_by_name │ ├── ut3_demo.test_remove_rooms_by_name.pkb │ └── ut3_demo.test_remove_rooms_by_name.pks ├── utlplsql-demo-project.yml ├── utplsql-cicd-flyway-demo.yml ├── utplsql-cicd-liquibase-demo.yml ├── utplsql_changelog.xml └── utplsql_flyway.conf /.azure_templates/t-extend-database-build.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | - name: containerRegistry 3 | default: "utPLSQL-docker" 4 | - name: dockerRepo 5 | default: "gvenzl/oracle-xe" 6 | - name: utplsqlVersion 7 | default: "" 8 | - name: utplsqlDir 9 | default: "" 10 | - name: test_user 11 | default: "" 12 | - name: test_pwd 13 | default: "" 14 | - name: targetDatabases 15 | type: object 16 | default: 17 | - name: oracleVersion 18 | default: "" 19 | - name: dockerOptions 20 | type: string 21 | default: "--shm-size=1g" 22 | - name: dockerPortMap 23 | type: string 24 | default: "1521" 25 | - name: connectionString 26 | default: "" 27 | - name: scripts 28 | type: object 29 | default: 30 | - name: work_dir 31 | default: "" 32 | - name: user 33 | default: "" 34 | - name: password 35 | default: "" 36 | - name: script 37 | default: "" 38 | - name: displayName 39 | default: "" 40 | 41 | 42 | steps: 43 | - bash: | 44 | git clone --depth=1 --branch=${{ parameters.utplsqlVersion }} https://github.com/utPLSQL/utPLSQL.git ${{ parameters.utplsqlDir}} 45 | chmod -R go+w ${{ parameters.utplsqlDir}} 46 | displayName: 'Download utPLSQL' 47 | 48 | - task: Docker@2 49 | displayName: Docker Login 50 | inputs: 51 | containerRegistry: ${{ parameters.containerRegistry }} 52 | command: 'login' 53 | addPipelineData: false 54 | addBaseImageData: false 55 | 56 | - ${{ each trg_db in parameters.targetDatabases }}: 57 | - template: t-task-extend-create-docker-database.yml 58 | parameters: 59 | containerRegistry: ${{ parameters.containerRegistry }} 60 | dockerRepo: ${{ parameters.dockerRepo }} 61 | dbname: ${{ trg_db.oracleVersion }} 62 | oracleVersion: ${{ trg_db.oracleVersion }} 63 | dockerOptions: ${{ trg_db.dockerOptions }} 64 | dockerPortMap: ${{ trg_db.dockerPortMap }} 65 | 66 | - ${{ each script in trg_db.scripts }}: 67 | - template: t-task-extend-sqlcl.yml 68 | parameters: 69 | work_dir: ${{ script.work_dir}} 70 | user: ${{ script.user}} 71 | password: ${{ script.password}} 72 | connectionString: ${{ trg_db.connectionString}} 73 | script: ${{ script.script}} 74 | displayName: ${{ script.displayName}} 75 | 76 | - template: t-task-extend-utplsqlcli.yml 77 | parameters: 78 | work_dir: $(Build.SourcesDirectory) 79 | connectionString: ${{ trg_db.connectionString}} 80 | test_user: ${{ parameters.test_user }} 81 | test_pwd: ${{ parameters.test_pwd }} 82 | source_path: "source" 83 | test_path: "test" 84 | options: "--debug --failure-exit-code=0" 85 | 86 | - task: PublishTestResults@2 87 | inputs: 88 | testResultsFormat: 'JUnit' 89 | testResultsFiles: '**/junit_test_results.xml' 90 | testRunTitle: 'Publish test results' 91 | displayName: 'Publish test results' 92 | 93 | - task: PublishCodeCoverageResults@1 94 | inputs: 95 | codeCoverageTool: 'Cobertura' 96 | summaryFileLocation: 'cobertura.xml' 97 | pathToSources: 'source' 98 | displayName: 'Publish coverage' -------------------------------------------------------------------------------- /.azure_templates/t-pipeline-extend-cicd.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | - name: enableBuild 3 | type: boolean 4 | default: true 5 | - name: enableDeployment 6 | type: boolean 7 | default: true 8 | - name: enableAnalysis 9 | type: boolean 10 | default: true 11 | - name: releaseMethod 12 | type: string 13 | default: 'liquibase' 14 | values: 15 | - 'liquibase' 16 | - 'flyway' 17 | - name: buildDatabase 18 | type: object 19 | default: 20 | - name: name 21 | default: "" 22 | - name: containerRegistry 23 | default: "" 24 | - name: dockerRepo 25 | default: "" 26 | - name : connectionString 27 | default : "" 28 | - name: jdbcConnectionString 29 | default : "" 30 | - name: environment 31 | default: "" 32 | - name: artifactName 33 | default: "" 34 | - name: packages 35 | type: object 36 | default: 37 | - name: name 38 | default: "" 39 | - name: download_location 40 | default: "" 41 | - name: unpack_location 42 | default: "" 43 | - name: url 44 | default: "" 45 | - name: archive 46 | default: "zip" 47 | - name: addToPath 48 | default: "" 49 | - name: createDatabase 50 | type: object 51 | default: 52 | - name: dbname 53 | default: "" 54 | - name: oracleVersion 55 | default: "" 56 | - name: dockerOptions 57 | default: "--shm-size=1g" 58 | - name: dockerPortMap 59 | default: "1521" 60 | - name: gitCheckoutDetails 61 | type: object 62 | default: 63 | - name: gitRepo 64 | default: "" 65 | - name: branch 66 | default: "" 67 | - name: checkoutDir 68 | default: "" 69 | - name: scripts 70 | type: object 71 | default: 72 | - name: work_dir 73 | default: "" 74 | - name: user 75 | default: "" 76 | - name: password 77 | default: "" 78 | - name: script 79 | default: "" 80 | - name: displayName 81 | default: "" 82 | - name: runliquibase 83 | type: object 84 | default: 85 | - name: work_dir 86 | default: "" 87 | - name: user 88 | default: "sys" 89 | - name: password 90 | default: "oracle" 91 | - name: masterchangelogfile 92 | default: "" 93 | - name: runflyway 94 | type: object 95 | default: 96 | - name: config_dir 97 | default: "" 98 | - name: config_file 99 | default: "" 100 | - name: migrations_dir 101 | default: "" 102 | - name: driver_dir 103 | default: "" 104 | - name: user 105 | default: "sys" 106 | - name: password 107 | default: "oracle" 108 | - name: configfile 109 | default: "" 110 | - name: execute_tests 111 | type: object 112 | default: 113 | - name : work_dir 114 | default: $(Build.SourcesDirectory) 115 | - name: test_user 116 | default: "" 117 | - name: test_pwd 118 | default: "" 119 | - name: source_path 120 | default: "" 121 | - name: test_path 122 | default: "" 123 | - name: options 124 | default: "" 125 | 126 | - name: deployStages 127 | type: object 128 | default: 129 | - name: name 130 | default: "" 131 | - name: dependsOn 132 | default: "" 133 | - name: display_name 134 | default: "" 135 | - name: target_env 136 | default: "" 137 | - name: containerRegistry 138 | default: "" 139 | - name: dockerRepo 140 | default: "" 141 | - name : connectionString 142 | default : "" 143 | - name: jdbcConnectionString 144 | default : "" 145 | - name: createDatabase 146 | type: object 147 | default: 148 | - name: dbname 149 | default: "" 150 | - name: oracleVersion 151 | default: "" 152 | - name: dockerOptions 153 | default: "--shm-size=1g" 154 | - name: dockerPortMap 155 | default: "1521" 156 | - name: packages 157 | type: object 158 | default: 159 | - name: name 160 | default: "" 161 | - name: download_location 162 | default: "" 163 | - name: unpack_location 164 | default: "$(Build.BinariesDirectory)" 165 | - name: url 166 | default: "" 167 | - name: archive 168 | default: "zip" 169 | - name: addToPath 170 | default: "" 171 | - name: scripts 172 | type: object 173 | default: 174 | - name: work_dir 175 | default: "" 176 | - name: user 177 | default: "" 178 | - name: password 179 | default: "" 180 | - name: script 181 | default: "" 182 | - name: displayName 183 | default: "" 184 | - name: runliquibase 185 | type: object 186 | default: 187 | - name: work_dir 188 | default: "" 189 | - name: user 190 | default: "sys" 191 | - name: password 192 | default: "oracle" 193 | - name: masterchangelogfile 194 | default: "" 195 | - name: runflyway 196 | type: object 197 | default: 198 | - name: work_dir 199 | default: "" 200 | - name: user 201 | default: "sys" 202 | - name: password 203 | default: "oracle" 204 | - name: configfile 205 | default: "" 206 | 207 | stages: 208 | - ${{ if parameters.enableBuild }}: 209 | - ${{ each builddatabases in parameters.buildDatabase }}: 210 | - stage: ${{ builddatabases.name }} 211 | displayName: Build Database 212 | jobs: 213 | - job: BuildDatabase 214 | displayName: Build Database 215 | steps: 216 | # Download binaries 217 | - template: t-task-extend-download-binaries.yml 218 | parameters: 219 | packages: ${{ builddatabases.packages }} 220 | # Create Docker databases 221 | - ${{ each dockerdb in builddatabases.createDatabase }}: 222 | - template: t-task-extend-create-docker-database.yml 223 | parameters: 224 | containerRegistry: ${{ builddatabases.containerRegistry }} 225 | dockerRepo: ${{ builddatabases.dockerRepo }} 226 | dbname: ${{ dockerdb.dbname }} 227 | oracleVersion: ${{ dockerdb.oracleVersion }} 228 | dockerOptions: ${{ dockerdb.dockerOptions }} 229 | dockerPortMap: ${{ dockerdb.dockerPortMap }} 230 | # Checkout utplsql 231 | - template: t-task-extend-git-clone.yml 232 | parameters: 233 | gitCheckoutDetails: ${{ builddatabases.gitCheckoutDetails }} 234 | # Execute SQL scripts 235 | - ${{ each script in builddatabases.scripts }}: 236 | - template: t-task-extend-sqlcl.yml 237 | parameters: 238 | work_dir: ${{ script.work_dir}} 239 | user: ${{ script.user}} 240 | password: ${{ script.password}} 241 | connectionString: ${{ builddatabases.connectionString}} 242 | script: ${{ script.script}} 243 | displayName: ${{ script.displayName}} 244 | # Execute Liquibase 245 | - ${{ if eq(parameters.releaseMethod,'liquibase') }}: 246 | - ${{ each liquibase in builddatabases.runliquibase }}: 247 | - template: t-task-extend-sqlcl-liquibase.yml 248 | parameters: 249 | connectionString: ${{ builddatabases.connectionString}} 250 | work_dir: ${{ liquibase.work_dir }} 251 | user: ${{ liquibase.user }} 252 | password: ${{ liquibase.password }} 253 | masterchangelogfile: ${{ liquibase.masterchangelogfile }} 254 | # Execute Flyway 255 | - ${{ if eq(parameters.releaseMethod,'flyway') }}: 256 | - ${{ each flyway in builddatabases.runflyway }}: 257 | - template: t-task-extend-flyway.yml 258 | parameters: 259 | containerRegistry: ${{ builddatabases.containerRegistry }} 260 | jdbcConnectionString: ${{ builddatabases.jdbcConnectionString}} 261 | config_dir: ${{ flyway.config_dir }} 262 | config_file: ${{ flyway.config_file }} 263 | migrations_dir: ${{ flyway.migrations_dir }} 264 | driver_dir: ${{ flyway.driver_dir }} 265 | user: ${{ flyway.user }} 266 | password: ${{ flyway.password }} 267 | # Execute utplsql tests 268 | - ${{ each runutplsql in builddatabases.execute_tests }}: 269 | - template: t-task-extend-utplsqlcli.yml 270 | parameters: 271 | connectionString: ${{ builddatabases.connectionString}} 272 | work_dir: ${{ runutplsql.work_dir}} 273 | test_user: ${{ runutplsql.test_user}} 274 | test_pwd: ${{ runutplsql.test_pwd}} 275 | source_path: ${{ runutplsql.source_path}} 276 | test_path: ${{ runutplsql.test_path}} 277 | options: ${{ runutplsql.options}} 278 | #Publish Artifact 279 | - task: CopyFiles@2 280 | displayName: Copy Sources 281 | inputs: 282 | SourceFolder: $(Build.SourcesDirectory)/source 283 | Contents: '**' 284 | TargetFolder: $(Build.ArtifactStagingDirectory)/source 285 | Overwrite: true 286 | - task: CopyFiles@2 287 | displayName: Copy Tests 288 | inputs: 289 | SourceFolder: $(Build.SourcesDirectory)/test 290 | Contents: '**' 291 | TargetFolder: $(Build.ArtifactStagingDirectory)/test 292 | Overwrite: true 293 | - ${{ if eq(parameters.releaseMethod,'liquibase') }}: 294 | - task: CopyFiles@2 295 | displayName: Copy configuration 296 | inputs: 297 | SourceFolder: $(Build.SourcesDirectory) 298 | Contents: 'utplsql_changelog.xml' 299 | TargetFolder: $(Build.ArtifactStagingDirectory) 300 | Overwrite: true 301 | - ${{ if eq(parameters.releaseMethod,'flyway') }}: 302 | - task: CopyFiles@2 303 | displayName: Copy configuration 304 | inputs: 305 | SourceFolder: $(Build.SourcesDirectory) 306 | Contents: 'utplsql_flyway.conf' 307 | TargetFolder: $(Build.ArtifactStagingDirectory) 308 | Overwrite: true 309 | - publish: $(Build.ArtifactStagingDirectory) 310 | artifact: ${{ builddatabases.artifactName}} 311 | #Publish test results 312 | - task: PublishTestResults@2 313 | inputs: 314 | testResultsFormat: 'JUnit' 315 | testResultsFiles: '**/junit_test_results.xml' 316 | testRunTitle: 'Publish test results' 317 | displayName: 'Publish test results' 318 | - task: PublishCodeCoverageResults@1 319 | inputs: 320 | codeCoverageTool: 'Cobertura' 321 | summaryFileLocation: 'cobertura.xml' 322 | pathToSources: 'source' 323 | displayName: 'Publish coverage' 324 | - ${{ if parameters.enableAnalysis }}: 325 | - template: t-task-extend-sonarcloud.yml 326 | parameters: 327 | name: utplsqAnalysis 328 | serviceConnection: "utplsql-SonarCloud" 329 | organization: "utplsql" 330 | configFile: "sonar-project.properties" 331 | 332 | - ${{ if parameters.enableDeployment }}: 333 | - ${{ each stage in parameters.deployStages }}: 334 | - stage: ${{ stage.name }} 335 | displayName: ${{ stage.display_name }} 336 | ${{ if stage.dependsOn }}: 337 | dependsOn: ${{ stage.dependsOn }} 338 | jobs: 339 | - deployment: 340 | displayName: Deploy Code to Database 341 | environment: ${{ stage.target_environment }} 342 | strategy: 343 | runOnce: 344 | deploy: 345 | steps: 346 | # Download binaries 347 | - template: t-task-extend-download-binaries.yml 348 | parameters: 349 | packages: ${{ stage.packages }} 350 | # Create Docker databases 351 | - ${{ each dockerdb in stage.createDatabase }}: 352 | - template: t-task-extend-create-docker-database.yml 353 | parameters: 354 | containerRegistry: ${{ stage.containerRegistry }} 355 | dockerRepo: ${{ stage.dockerRepo }} 356 | dbname: ${{ dockerdb.dbname }} 357 | oracleVersion: ${{ dockerdb.oracleVersion }} 358 | dockerOptions: ${{ dockerdb.dockerOptions }} 359 | dockerPortMap: ${{ dockerdb.dockerPortMap }} 360 | # Execute SQL scripts 361 | - ${{ each script in stage.scripts }}: 362 | - template: t-task-extend-sqlcl.yml 363 | parameters: 364 | work_dir: ${{ script.work_dir}} 365 | user: ${{ script.user}} 366 | password: ${{ script.password}} 367 | connectionString: ${{ stage.connectionString}} 368 | script: ${{ script.script}} 369 | displayName: ${{ script.displayName}} 370 | - ${{ if eq(parameters.releaseMethod,'liquibase') }}: 371 | # Execute Liquibase 372 | - ${{ each liquibase in stage.runliquibase }}: 373 | - template: t-task-extend-sqlcl-liquibase.yml 374 | parameters: 375 | connectionString: ${{ stage.connectionString}} 376 | work_dir: ${{ liquibase.work_dir }} 377 | user: ${{ liquibase.user }} 378 | password: ${{ liquibase.password }} 379 | masterchangelogfile: ${{ liquibase.masterchangelogfile }} 380 | - ${{ if eq(parameters.releaseMethod,'flyway') }}: 381 | - ${{ each flyway in stage.runflyway }}: 382 | - template: t-task-extend-flyway.yml 383 | parameters: 384 | containerRegistry: ${{ stage.containerRegistry }} 385 | jdbcConnectionString: ${{ stage.jdbcConnectionString}} 386 | config_dir: ${{ flyway.config_dir }} 387 | config_file: ${{ flyway.config_file }} 388 | migrations_dir: ${{ flyway.migrations_dir }} 389 | driver_dir: ${{ flyway.driver_dir }} 390 | user: ${{ flyway.user }} 391 | password: ${{ flyway.password }} -------------------------------------------------------------------------------- /.azure_templates/t-task-extend-create-docker-database.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | - name: containerRegistry 3 | default: "" 4 | - name: dockerRepo 5 | default: "" 6 | - name: dbname 7 | default: "" 8 | - name: oracleVersion 9 | default: "" 10 | - name: dockerOptions 11 | default: "--shm-size=1g" 12 | - name: dockerPortMap 13 | default: "1521" 14 | 15 | steps: 16 | - task: Docker@2 17 | displayName: Docker Login 18 | inputs: 19 | containerRegistry: ${{ parameters.containerRegistry }} 20 | command: 'login' 21 | - bash: | 22 | #as test enable network 23 | docker network create utplsql_network 24 | # download Oracle Database docker image from private repo and start the DB 25 | time docker pull ${{ parameters.dockerRepo }}:${{ parameters.oracleVersion }} 26 | # start the docker container (DB) 27 | time docker run -d --name ${{ parameters.dbname }} \ 28 | ${{ parameters.dockerOptions }} \ 29 | -p 1521:${{ parameters.dockerPortMap }} \ 30 | --network utplsql_network \ 31 | -e "ORACLE_PASSWORD=oracle" \ 32 | ${{ parameters.dockerRepo }}:${{ parameters.oracleVersion }} 33 | # Wait for DB startup 34 | time docker logs -f ${{ parameters.dbname }} | grep -m 1 "DATABASE IS READY TO USE!" --line-buffered 35 | displayName: 'Start Oracle DB Docker container: ${{ parameters.dbname }}:${{ parameters.oracleVersion }}' -------------------------------------------------------------------------------- /.azure_templates/t-task-extend-download-binaries.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | - name: packages 3 | type: object 4 | default: 5 | - name: name 6 | default: "" 7 | - name: download_location 8 | default: "" 9 | - name: unpack_location 10 | default: "" 11 | - name: url 12 | default: "" 13 | - name: archive 14 | default: "zip" 15 | - name: addToPath 16 | default: "" 17 | - name: clean 18 | type: boolean 19 | default: true 20 | 21 | steps: 22 | - ${{ each package in parameters.packages }}: 23 | - bash: | 24 | curl -Lk -o ${{package.download_location}} \ 25 | ${{package.url}} 26 | 27 | if [[ ! -z "${{package.unpack_location}}" ]]; then 28 | echo Unzipping to ${{package.unpack_location}} 29 | unzip -qq -d ${{package.unpack_location}} ${{package.download_location}} 30 | chmod -R u+x ${{package.unpack_location}} 31 | rm -rf ${{package.download_location}} 32 | else 33 | chmod -R u+x ${{package.download_location}} 34 | fi 35 | 36 | if [[ ! -z "${{package.addToPath}}" ]]; then 37 | echo "Add package to path" 38 | echo "##vso[task.prependpath]${{package.addToPath}}" 39 | fi 40 | displayName: 'Unzip ${{package.name}}' -------------------------------------------------------------------------------- /.azure_templates/t-task-extend-flyway.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | - name : containerRegistry 3 | default: "" 4 | - name: jdbcConnectionString 5 | default: "" 6 | - name: config_dir 7 | default: "" 8 | - name: config_file 9 | default: "" 10 | - name: migrations_dir 11 | default: "" 12 | - name: driver_dir 13 | default: "" 14 | - name: user 15 | default: "sys" 16 | - name: password 17 | default: "oracle" 18 | - name: configfile 19 | default: "" 20 | 21 | steps: 22 | - task: Docker@2 23 | displayName: Docker Login 24 | inputs: 25 | containerRegistry: ${{ parameters.containerRegistry }} 26 | command: 'login' 27 | 28 | - bash: | 29 | time docker run --rm \ 30 | -v ${{ parameters.migrations_dir }}:/flyway/sql \ 31 | -v ${{ parameters.config_dir }}:/flyway/conf \ 32 | -v ${{ parameters.driver_dir }}:/flyway/drivers \ 33 | --network utplsql_network \ 34 | flyway/flyway:8.5 migrate \ 35 | -url=jdbc:oracle:thin:@${{ parameters.jdbcConnectionString }} \ 36 | -configFiles="/flyway/conf/${{ parameters.config_file }}" \ 37 | -user="${{ parameters.user }}" \ 38 | -password="${{ parameters.password }}" 39 | 40 | exit $? 41 | displayName: 'Run Flyway migration' 42 | 43 | -------------------------------------------------------------------------------- /.azure_templates/t-task-extend-git-clone.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | - name: gitCheckoutDetails 3 | type: object 4 | default: 5 | - name: gitRepo 6 | default: "" 7 | - name: branch 8 | default: "" 9 | - name: checkoutDir 10 | default: "" 11 | 12 | steps: 13 | - ${{ each repo in parameters.gitCheckoutDetails }}: 14 | - bash: | 15 | git clone --depth=1 --branch=${{ repo.branch }} ${{ repo.gitRepo }} ${{ repo.checkoutDir}} 16 | chmod -R go+w ${{ repo.checkoutDir}} 17 | displayName: 'Clone : ${{ repo.gitRepo }}' -------------------------------------------------------------------------------- /.azure_templates/t-task-extend-sonarcloud.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | - name: name 3 | default: "" 4 | - name: serviceConnection 5 | default: "utplsql-SonarCloud" 6 | - name: organization 7 | default: "utplsql" 8 | - name: sonarExtraProperties 9 | default: "" 10 | - name: configFile 11 | default : "sonar-project.properties" 12 | 13 | steps: 14 | - task: SonarCloudPrepare@1 15 | inputs: 16 | SonarCloud: ${{ parameters.serviceConnection }} 17 | organization: ${{ parameters.organization }} 18 | scannerMode: 'CLI' 19 | configMode: 'file' 20 | configFile: ${{ parameters.configFile }} 21 | extraProperties: ${{ parameters.sonarExtraProperties }} 22 | - task: SonarCloudAnalyze@1 23 | - task: SonarCloudPublish@1 24 | inputs: 25 | pollingTimeoutSec: '300' -------------------------------------------------------------------------------- /.azure_templates/t-task-extend-sqlcl-liquibase.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | - name: connectionString 3 | default: "" 4 | - name: work_dir 5 | default: "" 6 | - name: user 7 | default: "sys" 8 | - name: password 9 | default: "oracle" 10 | - name: masterchangelogfile 11 | default: "" 12 | 13 | steps: 14 | - bash: | 15 | # Relates to : https://community.oracle.com/tech/developers/discussion/4490418/sqlcl-production-build-21-3-0-278-1045-throwing-warning-terminal-cannot-be-created-paused 16 | export JAVA_TOOL_OPTIONS=-Dorg.jline.terminal.dumb=true 17 | cd ${{ parameters.work_dir }} 18 | #Issue with 19.3 docker images. fixed in 21 19 | sql ${{ parameters.user }}/${{ parameters.password }}@//${{ parameters.connectionString }}?oracle.net.disableOob=true<- 34 | --health-cmd healthcheck.sh 35 | --health-interval 10s 36 | --health-timeout 5s 37 | --health-retries 10 38 | 39 | steps: 40 | - uses: actions/checkout@v2 41 | with: 42 | fetch-depth: 0 43 | 44 | - name: Install utPLSQL ${{matrix.utplsql-version}} 45 | run: echo Installing ${UTPLSQL_VERSION} && sh ${{ github.workspace }}/scripts/1_install_utplsql.sh 46 | 47 | - name: Install utPLSQL-cli 48 | run: curl -Lk -o utPLSQL-cli.zip "https://github.com/utPLSQL/utPLSQL-cli/releases/download/3.1.9/utPLSQL-cli.zip" && unzip utPLSQL-cli.zip && chmod -R u+x utPLSQL-cli 49 | 50 | - name: Install demo project 51 | run: sh ${{ github.workspace }}/scripts/2_install_demo_project.sh 52 | 53 | - name: Install unit tests 54 | run: sh ${{ github.workspace }}/scripts/3_install_tests.sh 55 | 56 | - name: Run unit tests 57 | run: sh ${{ github.workspace }}/scripts/4_run_tests.sh 58 | 59 | - name: SonarCloud Scan 60 | uses: SonarSource/sonarcloud-github-action@master 61 | env: 62 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any 63 | SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} 64 | 65 | slack-workflow-status: 66 | if: always() 67 | name: Post Workflow Status To Slack 68 | needs: [ build ] 69 | runs-on: ubuntu-latest 70 | steps: 71 | - name: Slack Workflow Notification 72 | uses: Gamesight/slack-workflow-status@master 73 | with: 74 | # Required Input 75 | repo_token: ${{secrets.GITHUB_TOKEN}} 76 | slack_webhook_url: ${{secrets.SLACK_WEBHOOK_URL}} 77 | # Optional Input 78 | name: 'Github Actions[bot]' 79 | icon_url: 'https://octodex.github.com/images/mona-the-rivetertocat.png' 80 | 81 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ### JetBrains template 2 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio 3 | 4 | *.iml 5 | 6 | ## Directory-based project format: 7 | .idea/ 8 | 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build](https://github.com/utPLSQL/utPLSQL-demo-project/actions/workflows/build.yml/badge.svg)](https://github.com/utPLSQL/utPLSQL-demo-project/actions/workflows/build.yml) 2 | [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=utPLSQL%3AutPLSQL-demo-project&metric=alert_status)](https://sonarcloud.io/dashboard?id=utPLSQL%3AutPLSQL-demo-project) 3 | 4 | Main utPLSQL Project Build: 5 | [![Build Status](https://dev.azure.com/utplsql/utplsql/_apis/build/status/utPLSQL.utPLSQL-demo-project?branchName=develop)](https://dev.azure.com/utplsql/utplsql/_build/latest?definitionId=5&branchName=develop) 6 | 7 | utPLSQL build using Liquibase 8 | [![Build Status](https://dev.azure.com/utplsql/utplsql/_apis/build/status/utPLSQL.utPLSQL-demo-sqlcl-liquibase-cicd?branchName=develop)](https://dev.azure.com/utplsql/utplsql/_build/latest?definitionId=6&branchName=develop) 9 | 10 | utPLSQL build using RedgateFlyway 11 | [![Build Status](https://dev.azure.com/utplsql/utplsql/_apis/build/status/utPLSQL.utPLSQL-demo-flyway-cicd?branchName=develop)](https://dev.azure.com/utplsql/utplsql/_build/latest?definitionId=7&branchName=develop) 12 | 13 | # CI/CD and Unit Testing for Oracle PLSQL 14 | 15 | ## Demo project using utPLSQL, Travis and SonarCloud for continuous integration of PLSQL and SQL code. 16 | 17 | 18 | This is a demo project using [utPLSQL v3](https://github.com/utPLSQL/utPLSQL) for unit testing of Oracle PLSQL code. 19 | The project is also taking benefit of Continuous Integration with Travis CI server as well as static code analysis, code coverage and test results reporting using SonarCloud. 20 | 21 | With every commit made to the github repository, a build job is executed using [Travis](https://travis-ci.org/utPLSQL/utPLSQL-demo-project) CI. 22 | 23 | The build process consists of following steps: 24 | - Download Oracle Database 11g XE 25 | - Download [latest release of utPLSQL](https://github.com/utPLSQL/utPLSQL/releases/latest) 26 | - Install Oracle Database 27 | - Install [utPLSQL](https://github.com/utPLSQL/utPLSQL) framework 28 | - Install [project sources](source/install.sh) 29 | - Install [unit tests](test/install.sh) 30 | - Download and unzip the [utplsql-cli](https://github.com/utPLSQL/utPLSQL-cli) project binaries 31 | - [Execute all tests](test/run.sh) on the project 32 | - Publish [test results](https://sonarcloud.io/component_measures/metric/tests/list?id=utPLSQL%3AutPLSQL-demo-project) and [code coverage](https://sonarcloud.io/component_measures/metric/coverage/list?id=utPLSQL%3AutPLSQL-demo-project) to [SonarQube](https://sonarcloud.io/) cloud service 33 | 34 | ## Demo project using utPLSQL, Azure Devops and SQLCL Liquibase / Redgate Flyway for continuous integration of PLSQL and SQL code. 35 | 36 | This is a demo project using [utPLSQL v3](https://github.com/utPLSQL/utPLSQL) for unit testing of Oracle PLSQL code. 37 | The project is also taking benefit of Continuous Integration with Azure Devops server as well as static code analysis, code coverage and test results reporting using SonarCloud. 38 | 39 | With every commit made to the github repository, a pipeline is executed using [AzureDevops](https://dev.azure.com/utplsql/utplsql/_build) CI. 40 | The pipeline is split into stages. Each stage is build from one job which is split into set of smaller tasks responsible for the whole build. 41 | 42 | In our pipeline we used following setup for stages: 43 | - Build Database: During this stage we are deploying our code using SQLCL Liquibase. This ensures that syntax of command is correct as well as integrity of changes with others Tests are deployed to that database and executed. In our scenario we are forcing the failure into success using utplsqlcli option `--failure-exit-code=0`. Code coverage and test results are published and immutable artifact is created that will be propagated to next stages of deployment. 44 | - Build Stage consists of following steps: 45 | - Download binaries for utplsqlcli and sqlcl *(this step is optional, its possible that in self hosted agent this will be part of agent etc.)* 46 | - Provision a database from docker *(this steps is optional and depends on your setup of databases, for example Delphix provisioning)* 47 | - Clone utPLSQL repository and install utPLSQL sources into database 48 | - Create test user and install test packages 49 | - Execute Liquibase / Flyway commands to update database 50 | - Execute utPLSQL tests 51 | - Publish test results to pipeline 52 | - Execute SonarCloud analysis and publish results 53 | - Prepare artifact for publish to next stage 54 | 55 | At the end of build stage we will produce immutable artifact that has been tested and can be passed downstream to deployment jobs. 56 | 57 | - Deploy Code to Database: During this stage we are using an artifact created during build stage. We will download it and deploy to the databases ( e.g. DEV,PRD, UAT, NFT etc.), during this stage running tests depends on project setup and the stage ( we will not be deploying tests to PRD but possible to DEV yes) 58 | - Deploy Stage consists of following steps: 59 | - Download binaries for utplsqlcli and sqlcl *(this step is optional, its possible that in self hosted agent this will be part of agent etc.)* 60 | - Provision a database from docker *( this step most likely you will not run as these databases will exists already)* 61 | - Create user to deploy code to *( this step most likely you will not run as the user will exists already and we will update database)* 62 | - Execute Liquibase / Flyway commands to update database 63 | -------------------------------------------------------------------------------- /scripts/0_start_db.sh: -------------------------------------------------------------------------------- 1 | docker run -d --name ora-utplsql -p 1521:1521 -e ORACLE_PASSWORD=oracle gvenzl/oracle-xe:18-slim 2 | -------------------------------------------------------------------------------- /scripts/1_install_utplsql.sh: -------------------------------------------------------------------------------- 1 | git clone --depth=1 --branch=${UTPLSQL_VERSION} https://github.com/utPLSQL/utPLSQL.git utPLSQL 2 | chmod -R go+w $(pwd)/utPLSQL/source 3 | docker run --rm -v $(pwd)/utPLSQL:/utPLSQL -w /utPLSQL/source --network host \ 4 | --entrypoint sqlplus gvenzl/oracle-xe:21-slim sys/oracle@//127.0.0.1:1521/XE as sysdba @install_headless.sql UT3 UT3 users 5 | -------------------------------------------------------------------------------- /scripts/2_install_demo_project.sh: -------------------------------------------------------------------------------- 1 | docker run --rm -v $(pwd):/work -w /work/ --network host \ 2 | --entrypoint sqlplus gvenzl/oracle-xe:21-slim \ 3 | sys/oracle@//127.0.0.1:1521/XE as sysdba @source/create_user.sql 4 | 5 | docker run --rm -v $(pwd):/work -w /work/ --network host \ 6 | --entrypoint sqlplus gvenzl/oracle-xe:21-slim \ 7 | ut3_demo/ut3_demo@//127.0.0.1:1521/XE @source/install.sql 8 | -------------------------------------------------------------------------------- /scripts/3_install_tests.sh: -------------------------------------------------------------------------------- 1 | docker run --rm -v $(pwd):/work -w /work/ --network host \ 2 | --entrypoint sqlplus gvenzl/oracle-xe:21-slim \ 3 | ut3_demo/ut3_demo@//127.0.0.1:1521/XE @test/install.sql 4 | -------------------------------------------------------------------------------- /scripts/4_run_tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -ev 4 | 5 | utPLSQL-cli/bin/utplsql run ut3_demo/ut3_demo@//127.0.0.1:1521/XE?oracle.net.disableOob=true \ 6 | -source_path=source -regex_expression="(\w+)/(\w+)/(R__)(\w+)\.(\w+)\.(\w+)$" \ 7 | -owner_subexpression=4 \ 8 | -name_subexpression=5 \ 9 | -type_subexpression=6 \ 10 | -test_path=test -regex_expression="(\w+)/(\w+)/(\w+)\.(\w+)\.(\w+)$" \ 11 | -owner_subexpression=3 \ 12 | -name_subexpression=4 \ 13 | -type_subexpression=5 \ 14 | -f=ut_documentation_reporter -c \ 15 | -f=ut_coverage_sonar_reporter -o=coverage.xml \ 16 | -f=ut_sonar_test_reporter -o=test_results.xml \ 17 | -f=ut_coverage_cobertura_reporter -o=cobertura.xml \ 18 | -f=ut_junit_reporter -o=junit_test_results.xml \ 19 | --failure-exit-code=0 -------------------------------------------------------------------------------- /sonar-project.properties: -------------------------------------------------------------------------------- 1 | # must be unique in a given SonarQube instance 2 | sonar.projectKey=utPLSQL:utPLSQL-demo-project 3 | # this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1. 4 | sonar.projectName=utPLSQL-demo-project 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 24 | -------------------------------------------------------------------------------- /source/award_bonus/R__ut3_demo.award_bonus.prc: -------------------------------------------------------------------------------- 1 | create or replace procedure award_bonus (emp_id number, sales_amt number) as 2 | --https://docs.oracle.com/database/sql-developer-4.2/RPTUG/sql-developer-unit-testing.htm#RPTUG45065 3 | commission real; 4 | comm_missing exception; 5 | begin 6 | select commission_pct into commission 7 | from employees_test 8 | where employee_id = emp_id; 9 | 10 | if commission is null then 11 | raise comm_missing; 12 | else 13 | update employees_test 14 | set salary = nvl(salary,0) + sales_amt*commission 15 | where employee_id = emp_id; 16 | end if; 17 | end; 18 | / 19 | -------------------------------------------------------------------------------- /source/award_bonus/V1.01__employees_test.sql: -------------------------------------------------------------------------------- 1 | create table employees_test (employee_id number primary key, commission_pct number, salary number); 2 | insert into employees_test values (1001, 0.2, 8400); 3 | insert into employees_test values (1002, 0.25, 6000); 4 | insert into employees_test values (1003, 0.3, 5000); 5 | -- next employee is not in the sales department, thus is not on commission. 6 | insert into employees_test values (1004, null, 10000); 7 | commit; 8 | -------------------------------------------------------------------------------- /source/award_bonus/award_bonus.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 15 | 16 | 17 | 23 | 24 | -------------------------------------------------------------------------------- /source/between_string/R__ut3_demo.betwnstr.fnc: -------------------------------------------------------------------------------- 1 | create or replace function betwnstr( a_string varchar2, a_start_pos integer, a_end_pos integer ) return varchar2 is 2 | l_start_pos pls_integer := a_start_pos; 3 | begin 4 | if l_start_pos = 0 then 5 | l_start_pos := 1; 6 | end if; 7 | return substr( a_string, l_start_pos, a_end_pos - l_start_pos + 1); 8 | end; 9 | / 10 | -------------------------------------------------------------------------------- /source/between_string/between_string.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 15 | 16 | -------------------------------------------------------------------------------- /source/create_user.sql: -------------------------------------------------------------------------------- 1 | create user ut3_demo identified by ut3_demo quota unlimited on USERS default tablespace USERS; 2 | 3 | grant create session, create procedure,create trigger, create type, create table, create sequence, create view to ut3_demo; 4 | grant select any dictionary to ut3_demo; 5 | 6 | exit 7 | -------------------------------------------------------------------------------- /source/install.sql: -------------------------------------------------------------------------------- 1 | @source/award_bonus/V1.01__employees_test.sql 2 | @source/award_bonus/R__ut3_demo.award_bonus.prc 3 | @source/between_string/R__ut3_demo.betwnstr.fnc 4 | @source/remove_rooms_by_name/V1.02__rooms.sql 5 | @source/remove_rooms_by_name/R__ut3_demo.remove_rooms_by_name.prc 6 | exit -------------------------------------------------------------------------------- /source/remove_rooms_by_name/R__ut3_demo.remove_rooms_by_name.prc: -------------------------------------------------------------------------------- 1 | create or replace procedure remove_rooms_by_name( l_name rooms.name%type ) is 2 | begin 3 | if l_name is null then 4 | raise program_error; 5 | end if; 6 | delete from rooms where name like l_name; 7 | end; 8 | / 9 | -------------------------------------------------------------------------------- /source/remove_rooms_by_name/V1.02__rooms.sql: -------------------------------------------------------------------------------- 1 | create table rooms ( 2 | room_key number primary key, 3 | name varchar2(100) 4 | ); 5 | 6 | create table room_contents ( 7 | contents_key number primary key, 8 | room_key number, 9 | name varchar2(100), 10 | constraint fk_rooms foreign key (room_key) references rooms (room_key) 11 | ); 12 | -------------------------------------------------------------------------------- /source/remove_rooms_by_name/remove_rooms_by_name.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 15 | 16 | 17 | 23 | 24 | -------------------------------------------------------------------------------- /test/award_bonus/ut3_demo.test_award_bonus.pkb: -------------------------------------------------------------------------------- 1 | create or replace package body test_award_bonus as 2 | 3 | gc_test_employee constant integer := -1; 4 | gc_salary constant number := 4500; 5 | gc_commision_pct constant number := 0.2; 6 | 7 | procedure update_employee_salary is 8 | results sys_refcursor; 9 | expected sys_refcursor; 10 | not_affected sys_refcursor; 11 | c_sales_amount constant number := 1000; 12 | begin 13 | --arrange 14 | open expected for 15 | select (salary + c_sales_amount * gc_commision_pct) as new_salary 16 | from employees_test where employee_id = gc_test_employee; 17 | 18 | open not_affected for 19 | select * from employees_test where employee_id <> gc_test_employee; 20 | 21 | --act 22 | award_bonus(emp_id => gc_test_employee, sales_amt => c_sales_amount); 23 | 24 | --assert 25 | open results for 26 | select salary as new_salary 27 | from employees_test where employee_id = gc_test_employee; 28 | 29 | ut.expect( results ).to_( equal( expected ) ); 30 | 31 | open results for 32 | select * from employees_test where employee_id != gc_test_employee; 33 | 34 | ut.expect( results ).to_( equal( not_affected ) ); 35 | end; 36 | 37 | procedure fail_on_null_bonus is 38 | begin 39 | award_bonus(emp_id => gc_test_employee, sales_amt => null); 40 | ut.expect( sqlcode ).not_to( equal( 0 ) ); 41 | exception 42 | when others then 43 | ut.expect( sqlcode ).not_to( equal( 0 ) ); 44 | end; 45 | 46 | procedure add_employee( emp_id number, comm_pct number, sal number ) is 47 | begin 48 | insert into employees_test (employee_id, commission_pct, salary) 49 | values (emp_id, comm_pct, sal); 50 | end; 51 | 52 | procedure add_test_employee is 53 | begin 54 | add_employee(gc_test_employee, 0.2, gc_salary); 55 | end; 56 | 57 | procedure add_employee_with_null_comm is 58 | begin 59 | add_employee(gc_test_employee, null, gc_salary); 60 | end; 61 | 62 | end; 63 | / 64 | -------------------------------------------------------------------------------- /test/award_bonus/ut3_demo.test_award_bonus.pks: -------------------------------------------------------------------------------- 1 | create or replace package test_award_bonus as 2 | 3 | -- %suite 4 | -- %displayname(Award bonus) 5 | 6 | -- %test 7 | -- %displayname(Sets new salary as pct commision * sales amount) 8 | -- %beforetest(add_test_employee) 9 | procedure update_employee_salary; 10 | 11 | -- %test 12 | -- %displayname(Raises exception if null bonus is passed) 13 | -- %beforetest(add_employee_with_null_comm) 14 | procedure fail_on_null_bonus; 15 | 16 | procedure add_test_employee; 17 | 18 | procedure add_employee_with_null_comm; 19 | 20 | end; 21 | / 22 | -------------------------------------------------------------------------------- /test/between_string/ut3_demo.test_betwnstr.pkb: -------------------------------------------------------------------------------- 1 | create or replace package body test_betwnstr as 2 | 3 | procedure normal_case is 4 | begin 5 | ut.expect( betwnstr( '1234567', 2, 5 ) ).to_equal('2345'); 6 | end; 7 | 8 | procedure zero_start_position is 9 | begin 10 | ut.expect( betwnstr( '1234567', 0, 5 ) ).to_( equal('12345') ); 11 | end; 12 | 13 | procedure big_end_position is 14 | begin 15 | ut.expect( betwnstr( '1234567', 0, 500 ) ).to_( equal('1234567') ); 16 | end; 17 | 18 | procedure null_string is 19 | begin 20 | ut.expect( betwnstr( null, 2, 5 ) ).to_( be_null() ); 21 | end; 22 | 23 | procedure bad_params is 24 | begin 25 | ut.expect( betwnstr( '1234567', 'a', 'b' ) ).to_( be_null() ); 26 | end; 27 | 28 | procedure bad_test 29 | is 30 | begin 31 | ut.expect( betwnstr( '1234567', 0, 500 ) ).to_( equal('1') ); 32 | end; 33 | 34 | procedure disabled_test is 35 | begin 36 | ut.expect( betwnstr( null, null, null) ).not_to( be_null ); 37 | end; 38 | 39 | end; 40 | / 41 | -------------------------------------------------------------------------------- /test/between_string/ut3_demo.test_betwnstr.pks: -------------------------------------------------------------------------------- 1 | create or replace package test_betwnstr as 2 | 3 | -- %suite(Between string function) 4 | 5 | -- %test(Returns substring from start position to end position) 6 | procedure normal_case; 7 | 8 | -- %test(Returns substring when start position is zero) 9 | procedure zero_start_position; 10 | 11 | -- %test(Returns string until end if end position is greater than string length) 12 | procedure big_end_position; 13 | 14 | -- %test(Returns null for null input string value) 15 | procedure null_string; 16 | 17 | -- %test(A demo of test raising runtime exception) 18 | procedure bad_params; 19 | 20 | -- %test(A demo of failing test) 21 | procedure bad_test; 22 | 23 | -- %test(Demo of a disabled test) 24 | -- %disabled 25 | procedure disabled_test; 26 | 27 | end; 28 | / 29 | -------------------------------------------------------------------------------- /test/install.sql: -------------------------------------------------------------------------------- 1 | @test/award_bonus/ut3_demo.test_award_bonus.pks 2 | @test/award_bonus/ut3_demo.test_award_bonus.pkb 3 | show errors 4 | @test/between_string/ut3_demo.test_betwnstr.pks 5 | @test/between_string/ut3_demo.test_betwnstr.pkb 6 | show errors 7 | @test/remove_rooms_by_name/ut3_demo.test_remove_rooms_by_name.pks 8 | @test/remove_rooms_by_name/ut3_demo.test_remove_rooms_by_name.pkb 9 | show errors 10 | exit -------------------------------------------------------------------------------- /test/remove_rooms_by_name/ut3_demo.test_remove_rooms_by_name.pkb: -------------------------------------------------------------------------------- 1 | create or replace package body test_remove_rooms_by_name as 2 | 3 | procedure setup_rooms is 4 | begin 5 | insert all 6 | into rooms values(1, 'Dining Room') 7 | into rooms values(2, 'Living Room') 8 | into rooms values(3, 'Office') 9 | into rooms values(4, 'Bathroom') 10 | into rooms values(5, 'Bedroom') 11 | select 1 from dual; 12 | 13 | insert all 14 | into room_contents values(1, 1, 'Table') 15 | into room_contents values(2, 1, 'Hutch') 16 | into room_contents values(3, 1, 'Chair') 17 | into room_contents values(4, 2, 'Sofa') 18 | into room_contents values(5, 2, 'Lamp') 19 | into room_contents values(6, 3, 'Desk') 20 | into room_contents values(7, 3, 'Chair') 21 | into room_contents values(8, 3, 'Computer') 22 | into room_contents values(9, 3, 'Whiteboard') 23 | select 1 from dual; 24 | end; 25 | 26 | procedure remove_empty_room is 27 | l_rooms_not_named_b sys_refcursor; 28 | l_remaining_rooms sys_refcursor; 29 | begin 30 | open l_rooms_not_named_b for select * from rooms where name not like 'B%'; 31 | 32 | remove_rooms_by_name('B%'); 33 | 34 | open l_remaining_rooms for select * from rooms; 35 | ut.expect( l_remaining_rooms ).to_(equal(l_rooms_not_named_b)); 36 | end; 37 | 38 | procedure room_with_content is 39 | l_rooms sys_refcursor; 40 | l_remaining_rooms sys_refcursor; 41 | begin 42 | open l_rooms for select * from rooms; 43 | 44 | begin 45 | remove_rooms_by_name('Living Room'); 46 | ut.expect( sqlcode ).to_( equal(-2292) ); 47 | exception 48 | when others then 49 | ut.expect( sqlcode ).to_( equal(-2292) ); 50 | end; 51 | 52 | open l_remaining_rooms for select * from rooms; 53 | 54 | ut.expect( l_remaining_rooms ).to_( equal( l_rooms ) ); 55 | end; 56 | 57 | procedure null_room_name is 58 | l_rooms sys_refcursor; 59 | l_remaining_rooms sys_refcursor; 60 | begin 61 | open l_rooms for select * from rooms; 62 | 63 | begin 64 | remove_rooms_by_name(NULL); 65 | ut.expect( sqlcode ).to_( equal(-6501) ); 66 | exception 67 | when others then 68 | ut.expect( sqlcode ).to_( equal(-6501) ); 69 | end; 70 | 71 | open l_remaining_rooms for select * from rooms; 72 | 73 | ut.expect( l_remaining_rooms ).to_( equal( l_rooms ) ); 74 | end; 75 | 76 | end; 77 | / 78 | -------------------------------------------------------------------------------- /test/remove_rooms_by_name/ut3_demo.test_remove_rooms_by_name.pks: -------------------------------------------------------------------------------- 1 | create or replace package test_remove_rooms_by_name as 2 | 3 | -- %suite 4 | -- %displayname(Remove rooms by name) 5 | 6 | -- %beforeall 7 | procedure setup_rooms; 8 | 9 | -- %test 10 | -- %displayname(Removes a room without content in it) 11 | procedure remove_empty_room; 12 | 13 | -- %test 14 | -- %displayname(Does not remove room when it has content) 15 | procedure room_with_content; 16 | 17 | -- %test 18 | -- %displayname(Raises exception when null room name given) 19 | procedure null_room_name; 20 | 21 | end; 22 | / -------------------------------------------------------------------------------- /utlplsql-demo-project.yml: -------------------------------------------------------------------------------- 1 | trigger: 2 | - develop 3 | 4 | pool: 5 | vmImage: ubuntu-latest 6 | 7 | variables: 8 | CACHE_DIR: $(Pipeline.Workspace)/.cache 9 | SQLCL_DIR: $(Build.BinariesDirectory)/sqlcl 10 | UTPLSQL_DIR: $(Build.BinariesDirectory)/utPLSQL 11 | UTPLSQL_CLI_DIR: $(Build.BinariesDirectory)/utPLSQL-cli 12 | UTPLSQL_CLI_VERSION: '3.1.9' 13 | UTPLSQL_VERSION: 'v3.1.13' 14 | DOCKHER_HUB_REPO: 'gvenzl/oracle-xe' 15 | DB_USER: ut3_demo 16 | DB_PASS: ut3_demo 17 | 18 | jobs: 19 | - job: utPLSQL_demo_project 20 | displayName: Build utPLSQL-demo-project 21 | strategy: 22 | matrix: 23 | Oracle21_slim: 24 | ORACLE_VERSION: "21-slim" 25 | maxParallel: 2 26 | 27 | steps: 28 | - template: .azure_templates/t-task-extend-download-binaries.yml 29 | parameters: 30 | packages: 31 | - name: sqlcl 32 | download_location: "$(Build.BinariesDirectory)/sqlcl-latest.zip" 33 | unpack_location: "$(Build.BinariesDirectory)" 34 | url: "https://download.oracle.com/otn_software/java/sqldeveloper/sqlcl-latest.zip" 35 | archive: "zip" 36 | addtoPath: "$(SQLCL_DIR)/bin" 37 | 38 | - name: utlplsqlcli 39 | download_location: "$(Build.BinariesDirectory)/utPLSQL-cli.zip" 40 | unpack_location: "$(Build.BinariesDirectory)" 41 | url: "https://github.com/utPLSQL/utPLSQL-cli/releases/download/$(UTPLSQL_CLI_VERSION)/utPLSQL-cli.zip" 42 | archive: "zip" 43 | addToPath: "$(UTPLSQL_CLI_DIR)/bin" 44 | 45 | - template: .azure_templates/t-extend-database-build.yml 46 | parameters: 47 | containerRegistry: utPLSQL-docker 48 | dockerRepo: gvenzl/oracle-xe 49 | utplsqlVersion: ${UTPLSQL_VERSION} 50 | utplsqlDir: ${UTPLSQL_DIR} 51 | test_user: ${DB_USER} 52 | test_pwd: ${DB_PASS} 53 | targetDatabases: 54 | - oracleVersion: "21-slim" 55 | connectionString: "127.0.0.1:1521/XE" 56 | dockerPortMap: "1521" 57 | dockerOptions: "" 58 | scripts: 59 | - displayName: "Install utPLSQL" 60 | user: "sys" 61 | password: "oracle" 62 | script: "install_headless.sql UT3 UT3 users" 63 | work_dir: "${UTPLSQL_DIR}/source" 64 | 65 | - displayName: "Create Test User" 66 | user: "sys" 67 | password: "oracle" 68 | script: "source/create_user.sql" 69 | work_dir: "$(Build.SourcesDirectory)" 70 | 71 | - displayName: "Install Source" 72 | user: "${DB_USER}" 73 | password: "${DB_PASS}" 74 | script: "source/install.sql" 75 | work_dir: "$(Build.SourcesDirectory)" 76 | 77 | - displayName: "Install Tests" 78 | user: "${DB_USER}" 79 | password: "${DB_PASS}" 80 | script: "test/install.sql" 81 | work_dir: "$(Build.SourcesDirectory)" 82 | 83 | -------------------------------------------------------------------------------- /utplsql-cicd-flyway-demo.yml: -------------------------------------------------------------------------------- 1 | trigger: 2 | - none 3 | 4 | pool: 5 | vmImage: ubuntu-latest 6 | 7 | variables: 8 | # Using this variable, the template references the correct variable template file (vars-dev.yaml, vars-qa.yaml or vars-prd.yaml) from the vars folder. 9 | - template: .azure_templates/vars/vars-global.yml 10 | - name: SQLCL_DIR 11 | value: $(Build.BinariesDirectory)/sqlcl 12 | - name : UTPLSQL_DIR 13 | value: $(Build.BinariesDirectory)/utPLSQL 14 | - name : UTPLSQL_CLI_DIR 15 | value: $(Build.BinariesDirectory)/utPLSQL-cli 16 | - name : UTPLSQL_CLI_VERSION 17 | value: '3.1.9' 18 | - name : UTPLSQL_VERSION 19 | value: 'v3.1.13' 20 | - name : DB_USER 21 | value: ut3_demo 22 | - name : DB_PASS 23 | value: ut3_demo 24 | - name: artifactName 25 | value: ReleaseArtifact 26 | 27 | extends: 28 | template: .azure_templates/t-pipeline-extend-cicd.yml 29 | parameters: 30 | enableBuild: true 31 | enableDeployment: true 32 | enableAnalysis: false 33 | releaseMethod: "flyway" 34 | buildDatabase: 35 | - name: BuildDatabase 36 | containerRegistry: ${{ variables.containerRegistry }} 37 | dockerRepo: ${{ variables.dockerRepo }} 38 | connectionString: "127.0.0.1:1521/XE" 39 | jdbcConnectionString: "UTBUILD:1521:XE" 40 | environment: "build" 41 | artifactName: ${{ variables.artifactName }} 42 | packages: 43 | - name: downloadSqlcl 44 | download_location: "$(Build.BinariesDirectory)/sqlcl-latest.zip" 45 | unpack_location: "$(Build.BinariesDirectory)" 46 | url: ${{ variables.sqlclUrl }} 47 | archive: "zip" 48 | addtoPath: "$(SQLCL_DIR)/bin" 49 | - name: downloadUtlplsqlcli 50 | download_location: "$(Build.BinariesDirectory)/utPLSQL-cli.zip" 51 | unpack_location: "$(Build.BinariesDirectory)" 52 | url: ${{ variables.utplsqlcliUrl }} 53 | archive: "zip" 54 | addToPath: "$(UTPLSQL_CLI_DIR)/bin" 55 | - name: DownloadOjdbc8 56 | download_location: "$(Build.BinariesDirectory)/ojdbc8.jar " 57 | url: ${{ variables.ojdbcurl }} 58 | createDatabase: 59 | - dbname: UTBUILD 60 | oracleVersion: "21-slim" 61 | dockerPortMap: "1521" 62 | dockerOptions: "" 63 | scripts: 64 | - displayName: "Install utPLSQL" 65 | user: "sys" 66 | password: "oracle" 67 | script: "install_headless.sql UT3 UT3 users" 68 | work_dir: "${UTPLSQL_DIR}/source" 69 | - displayName: "Create Test User" 70 | user: "sys" 71 | password: "oracle" 72 | script: "source/create_user.sql" 73 | work_dir: "$(Build.SourcesDirectory)" 74 | - displayName: "Install Tests" 75 | user: "$(DB_USER)" 76 | password: "$(DB_PASS)" 77 | script: "test/install.sql" 78 | work_dir: "$(Build.SourcesDirectory)" 79 | runflyway: 80 | - config_dir: "$(Build.SourcesDirectory)" 81 | config_file: "utplsql_flyway.conf" 82 | migrations_dir: "$(Build.SourcesDirectory)/source" 83 | driver_dir: "$(Build.BinariesDirectory)" 84 | user: $(DB_USER) 85 | password: $(DB_PASS) 86 | gitCheckoutDetails: 87 | - gitRepo: ${{ variables.gitRepo }} 88 | branch: $(UTPLSQL_VERSION) 89 | checkoutDir: $(UTPLSQL_DIR) 90 | execute_tests: 91 | - work_dir: $(Build.SourcesDirectory) 92 | test_user: $(DB_USER) 93 | test_pwd: $(DB_PASS) 94 | source_path: "source" 95 | test_path: "test" 96 | options: "--debug --failure-exit-code=0" 97 | 98 | deployStages: 99 | - name: ReleaseCode 100 | display_name: Deploy code to Test Env 101 | dependsOn: BuildDatabase 102 | target_environment: TEST 103 | connectionString: "127.0.0.1:1521/XE" 104 | jdbcConnectionString: "UTTEST:1521:XE" 105 | containerRegistry: ${{ variables.containerRegistry }} 106 | dockerRepo: ${{ variables.dockerRepo }} 107 | createDatabase: 108 | - dbname: UTTEST 109 | oracleVersion: "21-slim" 110 | dockerPortMap: "1521" 111 | dockerOptions: "" 112 | packages: 113 | - name: sqlcl 114 | download_location: "$(Build.BinariesDirectory)/sqlcl-latest.zip" 115 | unpack_location: "$(Build.BinariesDirectory)" 116 | url: ${{ variables.sqlclUrl }} 117 | archive: "zip" 118 | addtoPath: "$(SQLCL_DIR)/bin" 119 | - name: DownloadOjdbc8 120 | download_location: "$(Build.BinariesDirectory)/ojdbc8.jar " 121 | url: ${{ variables.ojdbcurl }} 122 | scripts: 123 | - displayName: "Create Test User" 124 | user: "sys" 125 | password: "oracle" 126 | script: "source/create_user.sql" 127 | work_dir: "$(Pipeline.Workspace)/${{ variables.artifactName }}" 128 | runflyway: 129 | - config_dir: "$(Pipeline.Workspace)/${{ variables.artifactName }}" 130 | config_file: "utplsql_flyway.conf" 131 | migrations_dir: "$(Pipeline.Workspace)/${{ variables.artifactName }}/source" 132 | driver_dir: "$(Build.BinariesDirectory)" 133 | user: $(DB_USER) 134 | password: $(DB_PASS) -------------------------------------------------------------------------------- /utplsql-cicd-liquibase-demo.yml: -------------------------------------------------------------------------------- 1 | trigger: 2 | - none 3 | 4 | pool: 5 | vmImage: ubuntu-latest 6 | 7 | variables: 8 | # Using this variable, the template references the correct variable template file (vars-dev.yaml, vars-qa.yaml or vars-prd.yaml) from the vars folder. 9 | - template: .azure_templates/vars/vars-global.yml 10 | - name: SQLCL_DIR 11 | value: $(Build.BinariesDirectory)/sqlcl 12 | - name : UTPLSQL_DIR 13 | value: $(Build.BinariesDirectory)/utPLSQL 14 | - name : UTPLSQL_CLI_DIR 15 | value: $(Build.BinariesDirectory)/utPLSQL-cli 16 | - name : UTPLSQL_CLI_VERSION 17 | value: '3.1.9' 18 | - name : UTPLSQL_VERSION 19 | value: 'v3.1.13' 20 | - name : DB_USER 21 | value: ut3_demo 22 | - name : DB_PASS 23 | value: ut3_demo 24 | - name: artifactName 25 | value: ReleaseArtifact 26 | 27 | extends: 28 | template: .azure_templates/t-pipeline-extend-cicd.yml 29 | parameters: 30 | enableBuild: true 31 | enableDeployment: true 32 | enableAnalysis: true 33 | buildDatabase: 34 | - name: BuildDatabase 35 | containerRegistry: ${{ variables.containerRegistry }} 36 | dockerRepo: ${{ variables.dockerRepo }} 37 | connectionString: "127.0.0.1:1521/XE" 38 | environment: "build" 39 | artifactName: ${{ variables.artifactName }} 40 | releaseMethod: "liquibase" 41 | packages: 42 | - name: sqlcl 43 | download_location: "$(Build.BinariesDirectory)/sqlcl-latest.zip" 44 | unpack_location: "$(Build.BinariesDirectory)" 45 | url: ${{ variables.sqlclUrl }} 46 | archive: "zip" 47 | addtoPath: "$(SQLCL_DIR)/bin" 48 | - name: utlplsqlcli 49 | download_location: "$(Build.BinariesDirectory)/utPLSQL-cli.zip" 50 | unpack_location: "$(Build.BinariesDirectory)" 51 | url: ${{ variables.utplsqlcliUrl }} 52 | archive: "zip" 53 | addToPath: "$(UTPLSQL_CLI_DIR)/bin" 54 | createDatabase: 55 | - dbname: UTBUILD 56 | oracleVersion: "21-slim" 57 | dockerPortMap: "1521" 58 | dockerOptions: "" 59 | scripts: 60 | - displayName: "Install utPLSQL" 61 | user: "sys" 62 | password: "oracle" 63 | script: "install_headless.sql UT3 UT3 users" 64 | work_dir: "${UTPLSQL_DIR}/source" 65 | - displayName: "Create Test User" 66 | user: "sys" 67 | password: "oracle" 68 | script: "source/create_user.sql" 69 | work_dir: "$(Build.SourcesDirectory)" 70 | - displayName: "Install Tests" 71 | user: "$(DB_USER)" 72 | password: "$(DB_PASS)" 73 | script: "test/install.sql" 74 | work_dir: "$(Build.SourcesDirectory)" 75 | runliquibase: 76 | - work_dir: "$(Build.SourcesDirectory)" 77 | user: $(DB_USER) 78 | password: $(DB_PASS) 79 | masterchangelogfile: "utplsql_changelog.xml" 80 | gitCheckoutDetails: 81 | - gitRepo: ${{ variables.gitRepo }} 82 | branch: $(UTPLSQL_VERSION) 83 | checkoutDir: $(UTPLSQL_DIR) 84 | execute_tests: 85 | - work_dir: $(Build.SourcesDirectory) 86 | test_user: $(DB_USER) 87 | test_pwd: $(DB_PASS) 88 | source_path: "source" 89 | test_path: "test" 90 | options: "--debug --failure-exit-code=0" 91 | 92 | deployStages: 93 | - name: ReleaseCode 94 | display_name: Deploy code to Test Env 95 | dependsOn: BuildDatabase 96 | target_environment: TEST 97 | connectionString: "127.0.0.1:1521/XE" 98 | containerRegistry: ${{ variables.containerRegistry }} 99 | dockerRepo: ${{ variables.dockerRepo }} 100 | createDatabase: 101 | - dbname: UTTEST 102 | oracleVersion: "21-slim" 103 | dockerPortMap: "1521" 104 | dockerOptions: "" 105 | packages: 106 | - name: sqlcl 107 | download_location: "$(Build.BinariesDirectory)/sqlcl-latest.zip" 108 | unpack_location: "$(Build.BinariesDirectory)" 109 | url: ${{ variables.sqlclUrl }} 110 | archive: "zip" 111 | addtoPath: "$(SQLCL_DIR)/bin" 112 | scripts: 113 | - displayName: "Create Test User" 114 | user: "sys" 115 | password: "oracle" 116 | script: "source/create_user.sql" 117 | work_dir: "$(Pipeline.Workspace)/${{ variables.artifactName }}" 118 | runliquibase: 119 | - work_dir: "$(Pipeline.Workspace)/${{ variables.artifactName }}" 120 | user: $(DB_USER) 121 | password: $(DB_PASS) 122 | masterchangelogfile: "utplsql_changelog.xml" 123 | -------------------------------------------------------------------------------- /utplsql_changelog.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /utplsql_flyway.conf: -------------------------------------------------------------------------------- 1 | flyway.schemas=UT3_DEMO 2 | flyway.table=schema_history 3 | flyway.outOfOrder=false 4 | flyway.baselineOnMigrate=true 5 | flyway.installedBy=utplsqldemo 6 | flyway.sqlMigrationSuffixes=.sql,.fnc,.prc,.pkg --------------------------------------------------------------------------------