diff --git a/Jenkinsfile b/Jenkinsfile index 7202257c4..c30b71b28 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -175,6 +175,8 @@ pipeline { sh 'rm -rf node_modules' // Link in the node_modules from the image sh 'ln -s /tmp/node_modules .' + // Build the app for the spectron tests to run + sh 'npm run build' // Run the tests sh 'MOCHA_FILE=pre-test-results.xml xvfb-run npm run test:ci' } diff --git a/Jenkinsfile.release b/Jenkinsfile.release deleted file mode 100644 index a086a83a9..000000000 --- a/Jenkinsfile.release +++ /dev/null @@ -1,137 +0,0 @@ -#!groovy - -@Library('realm-ci') _ - -setBuildName(env.VERSION_TAG); - -jobWrapper { - node('macos-cph-02.cph.realm') { - stage('Checkout') { - checkoutAtVersion() - } - - def packageJson = readJSON(file: 'package.json') - def nodeVersion = readFile('.nvmrc').trim() - def nvmInstallDir = sh(returnStdout: true, script: 'brew --prefix nvm').trim() - - nvm('version': nodeVersion, 'nvmInstallDir': nvmInstallDir) { - stage('Prechecks') { - assert "v${packageJson.version}" == env.VERSION_TAG : "Tag doesn't match package.json version" - // Test that we're actually using the right node version, this has been a problem before - def actualNodeVersion = sh(returnStdout: true, script: 'node --version').trim() - assert nodeVersion == actualNodeVersion : "Node version doesn't match" - } - - // Start installing, building, testing and packaging the app - stage('Install') { - sh 'npm install' - } - - stage('Build') { - withCredentials([ - string(credentialsId: 'realm-studio-sentry-token', variable: 'SENTRY_AUTH_TOKEN') - ]) { - sh 'npm run build' - } - } - - stage('Test') { - try { - // Runs the tests with reporting using the junit reporter - sh 'npm run test:ci' - } catch (err) { - error "Tests failed - see results on CI" - } finally { - junit( - keepLongStdio: true, - testResults: 'test-results.xml' - ) - // Archive any screenshots emitted by failing tests - archiveArtifacts( - artifacts: 'failure-*.png', - allowEmptyArchive: true, - ) - } - } - - stage('Package') { - withCredentials([ - file(credentialsId: 'cose-sign-certificate-windows', variable: 'WIN_CSC_LINK'), - string(credentialsId: 'cose-sign-password-windows', variable: 'WIN_CSC_KEY_PASSWORD') - ]) { - sh 'npx build -mlw -c.forceCodeSigning --publish never' - } - // Archive the packaged artifacts - archiveArtifacts 'dist/*' - } - - stage('Post-package test') { - sh 'npm run check:auto-update-files' - // TODO: Perform post-package tests on each of all platforms - } - - stage('Publish & notify') { - // Wait for input - input(message: "Ready to publish v${packageJson.version}?", id: 'publish') - - // Upload the build artifacts to S3 - def s3Config = packageJson.build.publish[0] - // Delete all the unpackaged directories - sh 'rm -rf dist/*/' - // Move yml files to another folder and upload them after other archives. - // This is to prevent clients from trying to upgrade before the files are there. - sh 'mkdir dist-finally && mv dist/*.yml dist-finally' - dir('dist') { - rlmS3Put(bucket: s3Config.bucket, path: s3Config.path) - } - // Upload the json and yml files - dir('dist-finally') { - rlmS3Put(bucket: s3Config.bucket, path: s3Config.path) - } - - // Publish GitHub release - if (env.GITHUB_RELEASE_ID) { - withCredentials([string(credentialsId: 'github-release-token', variable: 'GITHUB_TOKEN')]) { - // Update to publish the release - sh """ - curl \ - -H "Content-Type: application/json" \ - -H "Authorization: token ${GITHUB_TOKEN}" \ - -X PATCH \ - -d '{"draft": false}' \ - https://api.github.com/repos/realm/realm-studio/releases/${env.GITHUB_RELEASE_ID} - """ - } - } - - // Notify by posting to Slack - def url = "https://studio-releases.realm.io/${env.VERSION_TAG}" - def slackPost = [[ - 'title': "Realm Studio ${env.VERSION_TAG} has been released!", - 'title_link': url, - 'text': "Release notes and artifacts are available <${url}|here>", - 'color': 'good', - 'unfurl_links': false - ]] - postToSlack('slack-studio-team-url', slackPost) - postToSlack('slack-releases-webhook', slackPost) - } - } - } -} - -def checkoutAtVersion() { - return checkout([ - $class: 'GitSCM', - branches: [[name: "refs/tags/${VERSION_TAG}"]], - extensions: [ - [$class: 'WipeWorkspace'], - [$class: 'CleanCheckout'] - ], - gitTool: 'native git', - userRemoteConfigs: [[ - credentialsId: 'realm-ci-ssh', - url: 'git@github.com:realm/realm-studio.git' - ]] - ]) -} diff --git a/RELEASENOTES.md b/RELEASENOTES.md index f97938042..edb293abf 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -14,3 +14,4 @@ - Fixed the Dockerfile used when testing PRs. ([#1057](https://github.com/realm/realm-studio/pull/1057)) - Removing all existing and future unused locals. ([#1058](https://github.com/realm/realm-studio/pull/1058)) - Refactored singleton windows. ([#1066](https://github.com/realm/realm-studio/pull/1066)) +- Refactored the Jenkins CI pipeline. ([#1069](https://github.com/realm/realm-studio/pull/1069) & [#1073](https://github.com/realm/realm-studio/pull/1073))