-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathJenkinsfile
More file actions
198 lines (174 loc) · 6.97 KB
/
Jenkinsfile
File metadata and controls
198 lines (174 loc) · 6.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
@Library('shared-libraries') _
def runTests(excludeFragileTests) {
def excludeFlag = excludeFragileTests ? '--exclude "test-basic/documents-data-movement-*.js"' : ''
sh label: 'deploy-test-app-and-run-tests', script: """
export JAVA_HOME=\$JAVA_HOME_DIR
export GRADLE_USER_HOME=\$WORKSPACE/\$GRADLE_DIR
export PATH=\$JAVA_HOME/bin:\${NODE_HOME_DIR}/bin:\$PATH
cd node-client-api
node --version
npm --version
npm ci
cd test-app
./gradlew -i mlWaitTillReady
./gradlew -i mlTestConnections
./gradlew -i mlDeploy
./gradlew -i -Penv=e2e mlLoadData mlLoadModules
cd ..
rm -rf \$WORKSPACE/*.xml || true
./node_modules/.bin/mocha --timeout 10000 -R xunit test-basic/ ${excludeFlag} --reporter mocha-junit-reporter --reporter-options mochaFile=\$WORKSPACE/test-basic-reports.xml || true
./node_modules/.bin/gulp setupProxyTests || true
./node_modules/.bin/mocha --timeout 10000 -R xunit test-basic-proxy/lib/**/*.js --reporter mocha-junit-reporter --reporter-options mochaFile=\$WORKSPACE/test-basic-proxy-reports.xml || true
"""
junit '**/*.xml'
}
def runDockerCompose(String markLogicDockerImage) {
cleanupDocker()
sh label: 'run-docker-compose', script: '''#!/bin/bash
echo "Removing any running MarkLogic server and clean up MarkLogic data directory"
sudo /usr/local/sbin/mladmin remove
docker-compose down -v || true
sudo /usr/local/sbin/mladmin cleandata
cd node-client-api
echo "Running docker compose with MarkLogic image: ''' + markLogicDockerImage + '''"
MARKLOGIC_LOGS_VOLUME=/tmp MARKLOGIC_IMAGE=''' + markLogicDockerImage + ''' docker-compose up -d --build
'''
}
def teardownAfterTests() {
updateWorkspacePermissions()
sh label: 'teardown-docker', script: '''#!/bin/bash
cd node-client-api
docker-compose down -v || true
'''
cleanupDocker()
}
def runAuditReport() {
sh label: 'run-audit-report', script: '''
export PATH=${NODE_HOME_DIR}/bin:$PATH
cd node-client-api
npm ci
rm -rf $WORKSPACE/npm-audit-report.json || true
npm audit --audit-level=moderate --json > $WORKSPACE/npm-audit-report.json
'''
}
// For now, only failing on errors. See eslint.config.js for the lint configuration.
def runLint() {
sh label: 'run-lint', script: '''
export PATH=${NODE_HOME_DIR}/bin:$PATH
cd node-client-api
npm ci
npm run lint -- --quiet
'''
}
def runTypeCheck() {
sh label: 'run-type-check', script: '''
export PATH=${NODE_HOME_DIR}/bin:$PATH
cd node-client-api
npm ci
npm run test:types
'''
}
def runTypeScriptTests() {
sh label: 'run-typescript-tests', script: '''
export PATH=${NODE_HOME_DIR}/bin:$PATH
cd node-client-api
npm ci
npm run test:compile
./node_modules/.bin/mocha --timeout 10000 test-typescript/*.js --reporter mocha-junit-reporter --reporter-options mochaFile=$WORKSPACE/test-typescript-reports.xml || true
'''
junit '**/*test-typescript-reports.xml'
}
def runE2ETests(excludeFragileTests) {
def excludeFlag = excludeFragileTests ? '--exclude "test-complete/nodejs-dmsdk*.js"' : ''
sh label: 'run-e2e-tests', script: """
export PATH=\${NODE_HOME_DIR}/bin:\$PATH
cd node-client-api
node --version
npm --version
npm ci
echo "Running test-complete tests"
./node_modules/.bin/mocha --no-parallel -R xunit --timeout 60000 test-complete/ ${excludeFlag} --reporter mocha-junit-reporter --reporter-options mochaFile=\$WORKSPACE/test-complete-results.xml || true
echo "Done with test-complete tests"
cd test-complete-proxy
npm install gulp-cli
gulp loadToModulesDB
gulp generateFnClasses
gulp copyFnClasses
cp *.js ../test-complete/
cp -R ml-modules/ ../test-complete
cd ../test-complete
../node_modules/.bin/mocha -R xunit --timeout 20000 nodejs-ds-setup-docs.js
../node_modules/.bin/mocha -R xunit --timeout 20000 "nodejs-ds-required-params.js" --reporter mocha-junit-reporter --reporter-options mochaFile=\$WORKSPACE/ds-required-params-results.xml || true
../node_modules/.bin/mocha -R xunit --timeout 20000 "nodejs-ds-error-map.js" --reporter mocha-junit-reporter --reporter-options mochaFile=\$WORKSPACE/ds-multipleWorker-results.xml || true
../node_modules/.bin/mocha -R xunit --timeout 20000 "nodejs-ds-multipleWorker.js" --reporter mocha-junit-reporter --reporter-options mochaFile=\$WORKSPACE/ds-multipleWorker-results.xml || true
../node_modules/.bin/mocha -R xunit --timeout 20000 "nodejs-ds-transactions.js" --reporter mocha-junit-reporter --reporter-options mochaFile=\$WORKSPACE/ds-transactions-results.js.xml || true
../node_modules/.bin/mocha -R xunit --timeout 20000 "nodejs-ds-dynamic.js" --reporter mocha-junit-reporter --reporter-options mochaFile=\$WORKSPACE/ds-dynamic-results.xml || true
"""
junit '**/*.xml'
}
pipeline {
agent none
triggers {
parameterizedCron(env.BRANCH_NAME == "develop" ? "00 02 * * * % regressions=true" : "")
}
parameters {
booleanParam(name: 'regressions', defaultValue: false, description: 'indicator if build is for regressions')
string(name: 'MARKLOGIC_IMAGE_TAGS', defaultValue: 'marklogic-server-ubi:latest-11,marklogic-server-ubi:latest-12', description: 'Comma-delimited list of MarkLogic image tags including variant (e.g., marklogic-server-ubi:latest-11,marklogic-server-ubi-rootless:11.3.2). The registry/org (ml-docker-db-dev-tierpoint.bed-artifactory.bedford.progress.com/marklogic) path will be prepended automatically.')
}
options {
checkoutToSubdirectory 'node-client-api'
buildDiscarder logRotator(artifactDaysToKeepStr: '7', artifactNumToKeepStr: '', daysToKeepStr: '7', numToKeepStr: '10')
}
environment {
NODE_HOME_DIR = "/users/ml/builder/nodeJs/node-v22.20.0-linux-x64"
DMC_USER = credentials('MLBUILD_USER')
DMC_PASSWORD = credentials('MLBUILD_PASSWORD')
GRADLE_DIR = ".gradle"
JAVA_HOME_DIR = "/home/builder/java/jdk-17.0.2"
}
stages {
stage('pull-request-tests') {
agent { label 'nodeclientpool' }
steps {
runAuditReport()
runLint()
runTypeCheck()
runDockerCompose('ml-docker-db-dev-tierpoint.bed-artifactory.bedford.progress.com/marklogic/marklogic-server-ubi:latest-12')
runTests(true)
runTypeScriptTests()
runE2ETests(true)
}
post {
always {
teardownAfterTests()
}
}
}
stage('regressions') {
agent { label 'nodeclientpool' }
when {
allOf {
branch 'develop'
expression { return params.regressions }
}
}
steps {
script {
def imageTags = params.MARKLOGIC_IMAGE_TAGS.split(',')
def imagePrefix = 'ml-docker-db-dev-tierpoint.bed-artifactory.bedford.progress.com/marklogic/'
imageTags.each { tag ->
def fullImage = imagePrefix + tag.trim()
try {
runDockerCompose(fullImage)
runTests(false)
runTypeScriptTests()
runE2ETests(false)
} finally {
teardownAfterTests()
}
}
}
}
}
}
}