Skip to content

Commit e43f29f

Browse files
authored
Merge pull request #12 from utPLSQL/feature/azure_pipeline
Feature/azure pipeline
2 parents de47734 + 23c85cb commit e43f29f

2 files changed

Lines changed: 124 additions & 11 deletions

File tree

.travis/install_sqlcl.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ OTN_USER=""
1313
OTN_PASS=""
1414
OUTPUT_DIR=""
1515

16+
# To allow running of locally installed node modules
17+
# see: https://2ality.com/2016/01/locally-installed-npm-executables.html
18+
function npm-do { (PATH=$(npm bin):$PATH; eval $@;) }
19+
1620
# Call the casperjs script to return the download url. Then download the file using curl.
1721
downloadFile() {
1822
user=$1
@@ -21,7 +25,7 @@ downloadFile() {
2125
downloadUrl=$4
2226
outputFile=$5
2327
echo "Signing-in"
24-
downloadUrl=$(exec casperjs ${SCRIPT_DIR}/download.js ${user} ${pass} ${agreementUrl} ${downloadUrl})
28+
downloadUrl=$(npm-do casperjs ${SCRIPT_DIR}/download.js ${user} ${pass} ${agreementUrl} ${downloadUrl})
2529
downloadUrl=${downloadUrl%$'\r'}
2630
echo "DownloadURL: $downloadUrl"
2731
curl -o ${outputFile} -L "$downloadUrl"
@@ -55,12 +59,12 @@ if [[ "$OUTPUT_DIR" == "" ]]; then
5559
fi
5660

5761
if [[ ! -f "${ZIP_TARGET_DIR}/${SQLCL_FILE}" ]]; then
58-
npm install -g phantomjs-prebuilt casperjs
62+
npm install phantomjs-prebuilt casperjs
5963
echo "Downloading sqlcl from Oracle"
6064
downloadFile ${OTN_USER} ${OTN_PASS} ${AGREEMENT_URL} ${DOWNLOAD_URL} "${ZIP_TARGET_DIR}/${SQLCL_FILE}"
6165
else
6266
echo "Installing sqlcl from cache..."
6367
fi;
6468

65-
echo "Unzipping sqlcl into: ${ZIP_TARGET_DIR}"
69+
echo "Unzipping sqlcl zip file: ${ZIP_TARGET_DIR}/${SQLCL_FILE} into: ${OUTPUT_DIR} directory"
6670
unzip -q "${ZIP_TARGET_DIR}/${SQLCL_FILE}" -d ${OUTPUT_DIR}

azure-pipelines.yml

Lines changed: 117 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,125 @@
44
# https://aka.ms/yaml
55

66
trigger:
7-
- master
7+
- develop
8+
- feature/azure_pipeline
89

910
pool:
10-
vmImage: 'ubuntu-latest'
11+
vmImage: 'ubuntu-16.04'
12+
13+
variables:
14+
DOCKHER_HUB_REPO: 'utplsqlv3/oracledb'
15+
# Timezone needed for working with Oracle DB
16+
TZ: UTC
17+
ORACLE_VERSION: '11g-r2-xe'
18+
CONNECTION_STR: '127.0.0.1:1521/XE'
19+
DOCKER_OPTIONS: '--shm-size=1g'
20+
DB_SYS_PASSWORD: oracle
21+
DB_USER: ut3_demo
22+
DB_PASS: ut3_demo
23+
SQLCL_DIR: $(Build.BinariesDirectory)/sqlcl
24+
UTPLSQL_DIR: $(Build.BinariesDirectory)/utPLSQL
25+
UTPLSQL_CLI_DIR: $(Build.BinariesDirectory)/utPLSQL-cli
26+
UTPLSQL_CLI_VERSION: 'v3.1.7'
27+
CACHE_DIR: $(Pipeline.Workspace)/.cache
28+
29+
strategy:
30+
matrix:
31+
develop:
32+
UTPLSQL_VERSION: 'develop'
33+
v3.1.1:
34+
UTPLSQL_VERSION: 'v3.1.1'
35+
v3.1.2:
36+
UTPLSQL_VERSION: 'v3.1.2'
37+
v3.1.4:
38+
UTPLSQL_VERSION: 'v3.1.4'
39+
v3.1.7:
40+
UTPLSQL_VERSION: 'v3.1.7'
1141

1242
steps:
13-
- script: echo Hello, world!
14-
displayName: 'Run a one-line script'
43+
# Possible cache options:
44+
# https://marketplace.visualstudio.com/items?itemName=1ESLighthouseEng.PipelineArtifactCaching
45+
# https://github.com/Microsoft/azure-pipelines-yaml/pull/113
46+
47+
- task: CacheBeta@0
48+
inputs:
49+
path: '$(CACHE_DIR)'
50+
key: './*'
51+
52+
# - task: Cache@0
53+
# inputs:
54+
# path: $(CACHE_DIR)
55+
# key: '*'
56+
# displayName: 'Restore cache'
57+
58+
- bash: |
59+
echo "##vso[task.prependpath]$(UTPLSQL_CLI_DIR)/bin"
60+
echo "##vso[task.prependpath]$(SQLCL_DIR)/bin"
61+
displayName: 'Setup PATH variable'
62+
63+
- bash: |
64+
mkdir -p $(CACHE_DIR)
65+
.travis/install_sqlcl.sh -u $(ORACLE_OTN_USER) -p $(ORACLE_OTN_PASSWORD) -d $(CACHE_DIR) -o $(Build.BinariesDirectory)
66+
echo $PATH
67+
sql -v
68+
displayName: 'Install Oracle sqlcl'
69+
70+
- bash: |
71+
curl -Lk -o $(UTPLSQL_CLI_DIR).zip "https://github.com/utPLSQL/utPLSQL-cli/releases/download/$(UTPLSQL_CLI_VERSION)/utPLSQL-cli.zip"
72+
cd $(Build.BinariesDirectory)
73+
unzip $(UTPLSQL_CLI_DIR).zip && chmod -R u+x $(UTPLSQL_CLI_DIR)
74+
cp $(SQLCL_DIR)/lib/ojdbc8.jar $(UTPLSQL_CLI_DIR)/lib && cp $(SQLCL_DIR)/lib/orai18n.jar $(UTPLSQL_CLI_DIR)/lib
75+
displayName: 'Install utPLSQL-cli'
76+
77+
- bash: |
78+
git clone --depth=1 --branch=${UTPLSQL_VERSION} https://github.com/utPLSQL/utPLSQL.git ${UTPLSQL_DIR}
79+
# Needed for older versions of utPLSQL.
80+
displayName: 'Download utPLSQL'
81+
82+
- bash: |
83+
docker login -u $(DOCKER_USER) -p $(DOCKER_PASSWORD)
84+
# download Oracle Database docker image from private repo and start the DB
85+
time docker pull ${DOCKHER_HUB_REPO}:${ORACLE_VERSION}
86+
# start the docker container (DB)
87+
time docker run -d --name ${ORACLE_VERSION} ${DOCKER_OPTIONS} -p 1521:1521 ${DOCKHER_HUB_REPO}:${ORACLE_VERSION}
88+
# Wait for DB startup
89+
time docker logs -f ${ORACLE_VERSION} | grep -m 1 "DATABASE IS READY TO USE!" --line-buffered
90+
displayName: 'Start Oracle DB Docker container'
91+
92+
- bash: .travis/install_utplsql.sh
93+
displayName: 'Install utPLSQL'
94+
95+
- bash: |
96+
source/setup_db_account.sh
97+
source/install.sh
98+
test/install.sh
99+
displayName: 'Deploy'
100+
101+
- bash: |
102+
$(UTPLSQL_CLI_DIR)/bin/utplsql run ${DB_USER}/${DB_PASS}@//${CONNECTION_STR} \
103+
-source_path=source \
104+
-test_path=test \
105+
-f=ut_documentation_reporter -c \
106+
-f=ut_coverage_sonar_reporter -o=coverage.xml \
107+
-f=ut_sonar_test_reporter -o=test_results.xml \
108+
-f=ut_coverage_cobertura_reporter -o=cobertura.xml \
109+
-f=ut_junit_reporter -o=junit_test_results.xml \
110+
--debug \
111+
--failure-exit-code=0
112+
cat test_results.xml
113+
cat coverage.xml
114+
displayName: 'Test'
115+
116+
- task: PublishTestResults@2
117+
inputs:
118+
testResultsFormat: 'JUnit'
119+
testResultsFiles: '**/junit_test_results.xml'
120+
testRunTitle: 'Publish test results'
121+
displayName: 'Publish test results'
15122

16-
- script: |
17-
echo Add other tasks to build, test, and deploy your project.
18-
echo See https://aka.ms/yaml
19-
displayName: 'Run a multi-line script'
123+
- task: PublishCodeCoverageResults@1
124+
inputs:
125+
codeCoverageTool: 'Cobertura'
126+
summaryFileLocation: 'cobertura.xml'
127+
pathToSources: 'source'
128+
displayName: 'Publish coverage'

0 commit comments

Comments
 (0)