From 72f8d5ea6ea3d9d610521eb869b8d99cb60d91ee Mon Sep 17 00:00:00 2001 From: m1ga Date: Tue, 18 Apr 2023 13:59:03 +0200 Subject: [PATCH 1/3] feat: update minimum node.js version to 14.x --- Jenkinsfile | 6 +++--- android/package.json | 2 +- iphone/package.json | 2 +- package-lock.json | 2 +- package.json | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 62c678c2ee3..1d36dcb7301 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -15,7 +15,7 @@ def runDanger = isPR // run Danger.JS if it's a PR by default. (should we also r def publishToS3 = isMainlineBranch // publish zips to S3 if on mainline branch, by default // Variables we can change -def nodeVersion = '12.18.0' // NOTE that changing this requires we set up the desired version on jenkins master first! +def nodeVersion = '14.21.0' // NOTE that changing this requires we set up the desired version on jenkins master first! def npmVersion = 'latest' // We can change this without any changes to Jenkins. 5.7.1 is minimum to use 'npm ci' // Variables which we assign and share between nodes @@ -72,7 +72,7 @@ def gatherAndroidCrashReports() { def androidUnitTests(testName, nodeVersion, npmVersion, deviceId) { return { def labels = 'git && osx && android-emulator && android-sdk' // FIXME get working on windows/linux! - + if (!deviceId) { deviceId = 'android-31-playstore-x86_64'; } @@ -80,7 +80,7 @@ def androidUnitTests(testName, nodeVersion, npmVersion, deviceId) { node(labels) { env.JAVA_HOME="${tool name:'OpenJDK 11.0.11+9', type: 'jdk'}" env.PATH="${env.JAVA_HOME}/bin:${env.PATH}" - + // TODO: Do a shallow checkout rather than stash/unstash? unstash 'mocha-tests' try { diff --git a/android/package.json b/android/package.json index e44b893a543..4da25415db8 100644 --- a/android/package.json +++ b/android/package.json @@ -27,7 +27,7 @@ "java": ">=11.x" }, "engines": { - "node": ">=12.13.0" + "node": ">=14.21.0" }, "repository": { "type": "git", diff --git a/iphone/package.json b/iphone/package.json index 0bb3a5ecb8d..728471322d5 100644 --- a/iphone/package.json +++ b/iphone/package.json @@ -19,7 +19,7 @@ "ios sdk": ">=13.0 <=16.x" }, "engines": { - "node": ">=12.13.0" + "node": ">=14.21.0" }, "repository": { "type": "git", diff --git a/package-lock.json b/package-lock.json index 50c53e4845b..7ff3fb1ef87 100644 --- a/package-lock.json +++ b/package-lock.json @@ -87,7 +87,7 @@ "titanium-docgen": "4.10.3" }, "engines": { - "node": ">=12.13.0" + "node": ">=14.21.0" } }, "node_modules/@babel/code-frame": { diff --git a/package.json b/package.json index cb0d2a9551f..bae3b150268 100644 --- a/package.json +++ b/package.json @@ -163,10 +163,10 @@ "url": "git://github.com/tidev/titanium_mobile.git" }, "vendorDependencies": { - "node": "12.x || 14.x || 16.x" + "node": "14.x || 16.x || 19.x" }, "engines": { - "node": ">=12.13.0" + "node": ">=14.21.0" }, "nyc": { "exclude": [ From 35145af1a51aef6ee5f96267cb71bd42716ae766 Mon Sep 17 00:00:00 2001 From: m1ga Date: Thu, 20 Apr 2023 12:20:31 +0200 Subject: [PATCH 2/3] chore: move to node 16 --- Jenkinsfile | 2 +- android/package.json | 2 +- iphone/package.json | 2 +- package-lock.json | 2 +- package.json | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1d36dcb7301..a16c07b1c1e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -15,7 +15,7 @@ def runDanger = isPR // run Danger.JS if it's a PR by default. (should we also r def publishToS3 = isMainlineBranch // publish zips to S3 if on mainline branch, by default // Variables we can change -def nodeVersion = '14.21.0' // NOTE that changing this requires we set up the desired version on jenkins master first! +def nodeVersion = '16.0.0' // NOTE that changing this requires we set up the desired version on jenkins master first! def npmVersion = 'latest' // We can change this without any changes to Jenkins. 5.7.1 is minimum to use 'npm ci' // Variables which we assign and share between nodes diff --git a/android/package.json b/android/package.json index 4da25415db8..029f11d80b9 100644 --- a/android/package.json +++ b/android/package.json @@ -27,7 +27,7 @@ "java": ">=11.x" }, "engines": { - "node": ">=14.21.0" + "node": ">=16.0.0" }, "repository": { "type": "git", diff --git a/iphone/package.json b/iphone/package.json index 728471322d5..b731a51320f 100644 --- a/iphone/package.json +++ b/iphone/package.json @@ -19,7 +19,7 @@ "ios sdk": ">=13.0 <=16.x" }, "engines": { - "node": ">=14.21.0" + "node": ">=16.0.0" }, "repository": { "type": "git", diff --git a/package-lock.json b/package-lock.json index 7ff3fb1ef87..25a5c308f30 100644 --- a/package-lock.json +++ b/package-lock.json @@ -87,7 +87,7 @@ "titanium-docgen": "4.10.3" }, "engines": { - "node": ">=14.21.0" + "node": ">=16.0.0" } }, "node_modules/@babel/code-frame": { diff --git a/package.json b/package.json index bae3b150268..49e5a8e00e0 100644 --- a/package.json +++ b/package.json @@ -163,10 +163,10 @@ "url": "git://github.com/tidev/titanium_mobile.git" }, "vendorDependencies": { - "node": "14.x || 16.x || 19.x" + "node": "16.x || 18.x || 20.x" }, "engines": { - "node": ">=14.21.0" + "node": ">=16.0.0" }, "nyc": { "exclude": [ From c69329d56f70d3b7f9aa7e86260274dc02bbdd66 Mon Sep 17 00:00:00 2001 From: Michael Gangolf Date: Fri, 22 Dec 2023 14:19:07 +0100 Subject: [PATCH 3/3] remove conflict --- Jenkinsfile | 540 ---------------------------------------------------- 1 file changed, 540 deletions(-) delete mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index a16c07b1c1e..00000000000 --- a/Jenkinsfile +++ /dev/null @@ -1,540 +0,0 @@ -#!groovy -library 'pipeline-library' - -// Some branch flags to alter behavior -def isPR = env.CHANGE_ID || false // CHANGE_ID is set if this is a PR. (We used to look whether branch name started with PR-, which would not be true for a branch from origin filed as PR) -def MAINLINE_BRANCH_REGEXP = /master|next|\d+_\d_(X|\d)/ // a branch is considered mainline if 'master' or like: 6_2_X, 7_0_X, 6_2_1 -def isMainlineBranch = (env.BRANCH_NAME ==~ MAINLINE_BRANCH_REGEXP) - -// Keep logs/reports/etc of last 30 builds, only keep build artifacts of last 3 builds -properties([buildDiscarder(logRotator(numToKeepStr: '30', artifactNumToKeepStr: '3'))]) - -// These values could be changed manually on PRs/branches, but be careful we don't merge the changes in. We want this to be the default behavior for now! -// target branch of test suite to test with -def runDanger = isPR // run Danger.JS if it's a PR by default. (should we also run on origin branches that aren't mainline?) -def publishToS3 = isMainlineBranch // publish zips to S3 if on mainline branch, by default - -// Variables we can change -def nodeVersion = '16.0.0' // NOTE that changing this requires we set up the desired version on jenkins master first! -def npmVersion = 'latest' // We can change this without any changes to Jenkins. 5.7.1 is minimum to use 'npm ci' - -// Variables which we assign and share between nodes -// Don't modify these yourself, these are generated during the build -def gitCommit = '' -def basename = '' -def vtag = '' - -@NonCPS -def hasAPIDocChanges() { - // https://javadoc.jenkins-ci.org/hudson/scm/ChangeLogSet.html - def changeLogSets = currentBuild.changeSets - for (int i = 0; i < changeLogSets.size(); i++) { - def entries = changeLogSets[i].items - for (int j = 0; j < entries.size(); j++) { - def entry = entries[j] - if (entry.msg.contains('[skip ci]')) { - echo "skipping commit: ${entry.msg}" - continue; // skip this commit - } - // echo "checking commit: ${entry.msg}" - def paths = entry.affectedPaths - for (int k = 0; k < paths.size(); k++) { - def path = paths[k] - if (path.startsWith('apidoc/')) { - return true - } - } - } - } - return false -} - -def getBuiltSDK() { - // Unarchive the osx build of the SDK (as a zip) - sh 'rm -rf osx.zip' // delete osx.zip file if it already exists - unarchive mapping: ['dist/mobilesdk-*-osx.zip': 'osx.zip'] // grab the osx zip from our current build - return sh(returnStdout: true, script: 'ls osx.zip/dist/mobilesdk-*-osx.zip').trim() -} - -def gatherAndroidCrashReports() { - // gather crash reports/tombstones for Android - timeout(5) { - sh label: 'gather crash reports/tombstones for Android', returnStatus: true, script: './tests/adb-all.sh pull /data/tombstones' - archiveArtifacts allowEmptyArchive: true, artifacts: 'tombstones/' - sh returnStatus: true, script: 'rm -rf tombstones/' - // wipe tombstones and re-build dir with proper permissions/ownership on emulator - sh returnStatus: true, script: './tests/adb-all.sh shell rm -rf /data/tombstones' - sh returnStatus: true, script: './tests/adb-all.sh shell mkdir -m 771 /data/tombstones' - sh returnStatus: true, script: './tests/adb-all.sh shell chown system:system /data/tombstones' - } -} - -def androidUnitTests(testName, nodeVersion, npmVersion, deviceId) { - return { - def labels = 'git && osx && android-emulator && android-sdk' // FIXME get working on windows/linux! - - if (!deviceId) { - deviceId = 'android-31-playstore-x86_64'; - } - - node(labels) { - env.JAVA_HOME="${tool name:'OpenJDK 11.0.11+9', type: 'jdk'}" - env.PATH="${env.JAVA_HOME}/bin:${env.PATH}" - - // TODO: Do a shallow checkout rather than stash/unstash? - unstash 'mocha-tests' - try { - nodejs(nodeJSInstallationName: "node ${nodeVersion}") { - ensureNPM(npmVersion) - sh 'npm ci' - def zipName = getBuiltSDK() - sh label: 'Install SDK', script: "npm run deploy -- ${zipName} --select" // installs the sdk - try { - withEnv(['CI=1']) { - timeout(30) { - // Forcibly remove value for specific build tools version to use (set by module builds) - sh returnStatus: true, script: 'ti config android.buildTools.selectedVersion --remove' - sh label: 'Run Test Suite on emulator', script: "npm run test:integration -- android -T emulator -D test -C ${deviceId} -J ${testName}" - } // timeout - } - } catch (e) { - archiveArtifacts 'tmp/mocha/build/build_*.log' // save build log if build failed - gatherAndroidCrashReports() - throw e - } finally { - try { - // Kill the app and emulators! - timeout(5) { - sh returnStatus: true, script: './tests/adb-all.sh shell am force-stop com.appcelerator.testApp.testing' - sh returnStatus: true, script: './tests/adb-all.sh uninstall com.appcelerator.testApp.testing' - } - killAndroidEmulators() - } finally { - sh 'npm run clean:sdks' // remove non-GA sdks - sh 'npm run clean:modules' // remove modules - } - } // try/catch/finally - // save the junit reports as artifacts explicitly so danger.js can use them later - stash includes: 'junit.*.xml', name: "test-report-android-${testName}" - junit 'junit.*.xml' - archiveArtifacts allowEmptyArchive: true, artifacts: 'tests/diffs/,tests/generated/' - } // nodejs - } finally { - deleteDir() - } - } // node - } -} - -def macosUnitTests(nodeVersion, npmVersion) { - return { - node('git && xcode-14') { - // TODO: Do a shallow checkout rather than stash/unstash? - unstash 'mocha-tests' - try { - nodejs(nodeJSInstallationName: "node ${nodeVersion}") { - ensureNPM(npmVersion) - sh 'npm ci' - def zipName = getBuiltSDK() - sh label: 'Install SDK', script: "npm run deploy -- ${zipName} --select" // installs the sdk - try { - withEnv(['CI=1']) { - timeout(20) { - sh label: 'Run Test Suite on macOS', script: 'npm run test:integration -- ios -T macos' - } - } - } catch (e) { - gatherIOSCrashReports('mocha') // app name is mocha - throw e - } finally { - sh 'npm run clean:sdks' // remove non-GA sdks - sh 'npm run clean:modules' // remove modules - } - // save the junit reports as artifacts explicitly so danger.js can use them later - stash includes: 'junit.ios.macos.xml', name: "test-report-ios-macos" - junit 'junit.ios.macos.xml' - // Save any diffed images - archiveArtifacts allowEmptyArchive: true, artifacts: 'tests/diffs/,tests/generated/' - } // nodejs - } finally { - deleteDir() - } - } - } -} - -def iosUnitTests(deviceFamily, nodeVersion, npmVersion) { - return { - node('git && xcode-14') { - // TODO: Do a shallow checkout rather than stash/unstash? - unstash 'mocha-tests' - try { - nodejs(nodeJSInstallationName: "node ${nodeVersion}") { - ensureNPM(npmVersion) - sh 'npm ci' - def zipName = getBuiltSDK() - sh label: 'Install SDK', script: "npm run deploy -- ${zipName} --select" // installs the sdk - try { - withEnv(['CI=1']) { - timeout(40) { - sh label: 'Run Test Suite on simulator', script: "npm run test:integration -- ios -F ${deviceFamily}" - } - } - } catch (e) { - archiveArtifacts 'tmp/mocha/build/build_*.log' // save build log if build failed - gatherIOSCrashReports('mocha') // app name is mocha - throw e - } finally { - sh 'npm run clean:sdks' // remove non-GA sdks - sh 'npm run clean:modules' // remove modules - } - // save the junit reports as artifacts explicitly so danger.js can use them later - stash includes: 'junit.ios.*.xml', name: "test-report-ios-${deviceFamily}" - junit 'junit.ios.*.xml' - // Save any diffed images - archiveArtifacts allowEmptyArchive: true, artifacts: 'tests/diffs/,tests/generated/' - } // nodejs - } finally { - deleteDir() - } - } - } -} - -def cliUnitTests(nodeVersion, npmVersion) { - return { - node('git && osx') { // ToDo: refactor to try and run across mac, linux, and windows? - unstash 'cli-unit-tests' - nodejs(nodeJSInstallationName: "node ${nodeVersion}") { - ensureNPM(npmVersion) - sh 'npm ci' - try { - sh 'npm run test:cli' - } finally { - if (fileExists('coverage/cobertura-coverage.xml')) { - step([$class: 'CoberturaPublisher', autoUpdateHealth: false, autoUpdateStability: false, coberturaReportFile: 'coverage/cobertura-coverage.xml', failUnhealthy: false, failUnstable: false, maxNumberOfBuilds: 0, onlyStable: false, sourceEncoding: 'ASCII', zoomCoverageChart: false]) - } - stash includes: 'junit.cli.report.xml', name: 'test-report-cli' - junit 'junit.cli.report.xml' - } - } - } - } -} - -// Wrap in timestamper -timestamps { - try { - node('git && android-sdk && gperf && xcode-14') { - env.JAVA_HOME="${tool name:'OpenJDK 11.0.11+9', type: 'jdk'}" - env.PATH="${env.JAVA_HOME}/bin:${env.PATH}" - - stage('Checkout') { - // Update our shared reference repo for all branches/PRs - dir('..') { - if (fileExists('titanium_mobile.git')) { - dir('titanium_mobile.git') { - sh 'git gc' - sh 'git remote update -p' // update the clone - sh 'git prune' // prune to avoid "warning: There are too many unreachable loose objects" - } - } else { - sh 'git clone --mirror git@github.com:appcelerator/titanium_mobile.git' // create a mirror - } - } - - // checkout scm - // Hack for JENKINS-37658 - see https://support.cloudbees.com/hc/en-us/articles/226122247-How-to-Customize-Checkout-for-Pipeline-Multibranch - checkout([ - $class: 'GitSCM', - branches: scm.branches, - extensions: scm.extensions + [ - [$class: 'WipeWorkspace'], - [$class: 'CloneOption', honorRefspec: true, noTags: true, reference: "${pwd()}/../titanium_mobile.git", shallow: true, depth: 30, timeout: 30]], - userRemoteConfigs: scm.userRemoteConfigs - ]) - // FIXME: Workaround for missing env.GIT_COMMIT: http://stackoverflow.com/questions/36304208/jenkins-workflow-checkout-accessing-branch-name-and-git-commit - gitCommit = sh(returnStdout: true, script: 'git rev-parse HEAD').trim() - } - - nodejs(nodeJSInstallationName: "node ${nodeVersion}") { - - stage('Lint') { - ensureNPM(npmVersion) - - // Install dependencies - timeout(5) { - sh 'npm ci' - } - // Run npm test, but record output in a file and check for failure of command by checking output - if (fileExists('npm_test.log')) { - sh 'rm -rf npm_test.log' - } - // forcibly grab and set correct value for android sdk path by grabbing from node we're actually building on (using env.ANDROID_SDK will pick up master node's env value!) - def androidSDK = env.ANDROID_SDK - withEnv(['ANDROID_SDK=']) { - try { - androidSDK = sh(returnStdout: true, script: 'printenv ANDROID_SDK').trim() - } catch (e) { - // squash, env var not set at OS-level - } - } - def npmTestResult = sh(returnStatus: true, script: "ANDROID_SDK_ROOT=${androidSDK} npm test &> npm_test.log") - recordIssues(tools: [checkStyle(pattern: 'android/**/build/reports/checkstyle/checkJavaStyle.xml')]) - if (runDanger) { // Stash files for danger.js later - stash includes: 'package.json,package-lock.json,dangerfile.js,.eslintignore,.eslintrc,npm_test.log,android/**/*.java', name: 'danger' - } - stash includes: 'package.json,package-lock.json,android/cli/**,iphone/cli/**,build/**', name: 'cli-unit-tests' - stash includes: 'package.json,package-lock.json,tests/**,build/**', name: 'mocha-tests' - // was it a failure? - if (npmTestResult != 0) { - error readFile('npm_test.log') - } else if (env.BRANCH_NAME.equals('master') && hasAPIDocChanges()) { - // if we have a master branch build of SDK with updated apidocs, trigger a new doc site build - build job: 'docs/doctools/docs', wait: false - } - } - - stage('Build') { - // Normal build, pull out the version - def version = sh(returnStdout: true, script: 'sed -n \'s/^ *"version": *"//p\' package.json | tr -d \'"\' | tr -d \',\'').trim() - echo "VERSION: ${version}" - // Create a timestamp - def timestamp = sh(returnStdout: true, script: 'date +\'%Y%m%d%H%M%S\'').trim() - echo "TIMESTAMP: ${timestamp}" - vtag = "${version}.v${timestamp}" - echo "VTAG: ${vtag}" - basename = "dist/mobilesdk-${vtag}" - echo "BASENAME: ${basename}" - - ansiColor('xterm') { - timeout(15) { - def buildCommand = 'npm run clean' - if (isMainlineBranch) { - buildCommand += ' -- --all' - } - sh label: 'clean', script: buildCommand - } // timeout - timeout(15) { - def buildCommand = 'npm run build' - if (isMainlineBranch) { - buildCommand += ' -- --all' - } - try { - sh label: 'build', script: buildCommand - } finally { - recordIssues(tools: [clang(), java()]) - } - } // timeout - timeout(25) { - def packageCommand = "npm run package -- --version-tag ${vtag}" - if (isMainlineBranch) { - // on mainline builds, build for all 3 host OSes - packageCommand += ' --all' - } else { - // On PRs, just build android and ios for macOS - packageCommand += ' android ios' - } - sh label: 'package', script: packageCommand - } // timeout - } // ansiColor - - archiveArtifacts artifacts: "${basename}-*.zip" - stash includes: 'dist/parity.html', name: 'parity' - } // end 'Build' stage - } // nodeJs - } // end node for checkout/build - - // Run unit tests in parallel for android/iOS - stage('Test') { - parallel( - 'android main unit tests': androidUnitTests('main', nodeVersion, npmVersion, null), - 'android 5.0 unit tests': androidUnitTests('5.0', nodeVersion, npmVersion, 'android-21-x86'), - 'iPhone unit tests': iosUnitTests('iphone', nodeVersion, npmVersion), - 'iPad unit tests': iosUnitTests('ipad', nodeVersion, npmVersion), - 'macOS unit tests': macosUnitTests(nodeVersion, npmVersion), - 'cli unit tests': cliUnitTests(nodeVersion, npmVersion), - failFast: false - ) - } - - stage('Deploy') { - if (publishToS3) { - // Now allocate a node for uploading artifacts to s3 and in Jenkins - node('(osx || linux) && !axway-internal && curl') { - def indexJson = [] - if (fileExists('index.json')) { - sh 'rm -f index.json' - } - try { - sh "curl -O http://builds.appcelerator.com.s3.amazonaws.com/mobile/${env.BRANCH_NAME}/index.json" - } catch (err) { - // ignore? Not able to grab the index.json, so assume it means it's a new branch - } - if (fileExists('index.json')) { - def contents = readFile('index.json') - if (!contents.startsWith(' env.json' - sh returnStatus: true, script: 'npx danger ci --verbose' // Don't fail build if danger fails. We want to retain existing build status. - } // withEnv - } // nodejs - deleteDir() - } // node - } // Danger stage - } // if(runDanger) - } -}