diff --git a/Jenkinsfile b/Jenkinsfile index 9e059a45..dcd4fe06 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,33 @@ @Library('shared-libraries') _ +import groovy.transform.Field + +@Field final String NODE_INSTALL_ROOT = '/users/ml/builder/nodeJs' + +def parseNodeVersions() { + def versions = params.NODE_VERSIONS.split(',').collect { it.trim() }.findAll { it } + versions.each { v -> + if (!(v ==~ /\d+\.\d+\.\d+/)) { + error("Invalid NODE_VERSIONS entry '${v}'; expected a full Node.js version such as 22.20.0") + } + } + if (versions.isEmpty()) { + error('NODE_VERSIONS must contain at least one Node.js version') + } + return versions +} + +def withNode(String nodeVersion, Closure body) { + def nodeHome = "${NODE_INSTALL_ROOT}/node-v${nodeVersion}-linux-x64" + def nodeMajor = nodeVersion.tokenize('.')[0] + if (sh(label: "check-node-${nodeVersion}", returnStatus: true, script: "test -x '${nodeHome}/bin/node'") != 0) { + error("Node.js ${nodeVersion} is not installed at ${nodeHome}") + } + withEnv(["NODE_HOME_DIR=${nodeHome}", "NODE_MAJOR=${nodeMajor}"]) { + body() + } +} + def runTests(excludeFragileTests) { def excludeFlag = excludeFragileTests ? '--exclude "test-basic/documents-data-movement-*.js"' : '' @@ -20,11 +48,11 @@ def runTests(excludeFragileTests) { 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/mocha --timeout 10000 -R xunit test-basic/ ${excludeFlag} --reporter mocha-junit-reporter --reporter-options mochaFile=\$WORKSPACE/test-basic-reports-node\$NODE_MAJOR.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 + ./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-node\$NODE_MAJOR.xml || true """ - junit '**/*.xml' + junit "test-basic-reports-node${env.NODE_MAJOR}.xml,test-basic-proxy-reports-node${env.NODE_MAJOR}.xml" } def runDockerCompose(String markLogicDockerImage) { @@ -84,9 +112,9 @@ def runTypeScriptTests() { 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 + ./node_modules/.bin/mocha --timeout 10000 test-typescript/*.js --reporter mocha-junit-reporter --reporter-options mochaFile=$WORKSPACE/test-typescript-reports-node$NODE_MAJOR.xml || true ''' - junit '**/*test-typescript-reports.xml' + junit "test-typescript-reports-node${env.NODE_MAJOR}.xml" } def runE2ETests(excludeFragileTests) { @@ -99,8 +127,12 @@ def runE2ETests(excludeFragileTests) { npm --version npm ci + for proxyFile in test-complete-proxy/*.js; do + rm -f "test-complete/\${proxyFile##*/}" + done + 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 + ./node_modules/.bin/mocha --no-parallel -R xunit --timeout 60000 test-complete/ ${excludeFlag} --reporter mocha-junit-reporter --reporter-options mochaFile=\$WORKSPACE/test-complete-results-node\$NODE_MAJOR.xml || true echo "Done with test-complete tests" cd test-complete-proxy @@ -112,13 +144,13 @@ def runE2ETests(excludeFragileTests) { 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 + ../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-node\$NODE_MAJOR.xml || true + ../node_modules/.bin/mocha -R xunit --timeout 20000 "nodejs-ds-error-map.js" --reporter mocha-junit-reporter --reporter-options mochaFile=\$WORKSPACE/ds-error-map-results-node\$NODE_MAJOR.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-node\$NODE_MAJOR.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-node\$NODE_MAJOR.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-node\$NODE_MAJOR.xml || true """ - junit '**/*.xml' + junit "test-complete-results-node${env.NODE_MAJOR}.xml,ds-*-results-node${env.NODE_MAJOR}.xml" } pipeline { @@ -131,6 +163,7 @@ pipeline { 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.') + string(name: 'NODE_VERSIONS', defaultValue: '22.20.0,24.15.0,26.14.0', description: 'Comma-delimited list of full Node.js versions to test against (e.g., 22.20.0,24.15.0,26.14.0). Each must be installed at /users/ml/builder/nodeJs/node-v-linux-x64.') } options { @@ -139,7 +172,6 @@ pipeline { } 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" @@ -150,19 +182,37 @@ pipeline { stage('pull-request-tests') { agent { label 'nodeclientpool' } - steps { - // npm audit is non-blocking; Harness Artifact Repository does not currently support it so failures are ignored. - 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) + when { + anyOf { + branch 'develop' + changeRequest() + } } - post { - always { - teardownAfterTests() + steps { + script { + def nodeVersions = parseNodeVersions() + + withNode(nodeVersions[0]) { + // npm audit is non-blocking; Harness Artifact Repository does not currently support it so failures are ignored. + runAuditReport() + runLint() + runTypeCheck() + } + + nodeVersions.each { nodeVersion -> + stage("Node ${nodeVersion}") { + withNode(nodeVersion) { + try { + runDockerCompose('ml-docker-db-dev-tierpoint.bed-artifactory.bedford.progress.com/marklogic/marklogic-server-ubi:latest-12') + runTests(true) + runTypeScriptTests() + runE2ETests(true) + } finally { + teardownAfterTests() + } + } + } + } } } } @@ -179,17 +229,24 @@ pipeline { script { def imageTags = params.MARKLOGIC_IMAGE_TAGS.split(',') def imagePrefix = 'ml-docker-db-dev-tierpoint.bed-artifactory.bedford.progress.com/marklogic/' + def nodeVersions = parseNodeVersions() imageTags.each { tag -> def fullImage = imagePrefix + tag.trim() - try { - runDockerCompose(fullImage) - runTests(false) - runTypeScriptTests() - runE2ETests(false) - } finally { - teardownAfterTests() + nodeVersions.each { nodeVersion -> + stage("${tag.trim()} / Node ${nodeVersion}") { + withNode(nodeVersion) { + try { + runDockerCompose(fullImage) + runTests(false) + runTypeScriptTests() + runE2ETests(false) + } finally { + teardownAfterTests() + } + } + } } } } diff --git a/README.md b/README.md index 5845b659..2113083e 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ The Progress® MarkLogic® Node Client API provides access to the MarkLogic data ## System Requirements -The Node Client 4.3.0 release requires Node.js 22 or higher. Testing has verified that the client will +The Node Client 4.3.0 release requires Node.js 22 or higher and is tested against Node.js 22, 24, and 26. Testing has verified that the client will run successfully on Node 20, but we recommend 22 or higher based on [the Node.js release roadmap](https://nodejs.org/en/about/previous-releases), as Node 20 enters end-of-life in April 2026 while Node 22 is supported through April 2027.