2017-11-08 08:40:20 -05:00
|
|
|
String cron_string = BRANCH_NAME == "master" ? "@daily" : ""
|
|
|
|
|
2017-08-16 05:43:48 -04:00
|
|
|
pipeline {
|
|
|
|
|
2017-09-15 09:20:03 -04:00
|
|
|
agent any
|
2017-08-16 05:43:48 -04:00
|
|
|
|
|
|
|
environment {
|
|
|
|
HOME = "/tmp"
|
|
|
|
}
|
|
|
|
|
|
|
|
triggers {
|
|
|
|
pollSCM('* * * * *')
|
2017-11-08 08:40:20 -05:00
|
|
|
cron(cron_string)
|
2017-08-16 05:43:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
stages {
|
CI and local dev environment improvements
The need for this became very noticeable due to the slowness of filesystem access in docker-in-mac, with a full compile taking over a minute for me in docker. Using make to introduce incremental compile makes this near instantaneous outside of docker (if only a few files have changed), and quick enough inside docker.
With incremental compile via make, it compiles quickly enough that re-compiling and restarting the web service automatically when backend files change is quick enough now. This is how the service is run via docker-compose in https://github.com/sharelatex/sharelatex-dev-environment, so it shouldn't be necessary to manually restart the container each time a coffee file changes.
At the moment Jenkins pull web modules in via the GitSCM plugin, but I believe this is creating a dependency in Jenkins, where any commits to any of the modules causes all of the web branches to rebuild. By doing it via our own scripts we can hopefully avoid this. It also creates a build process which is reproducible locally.
**Note that at the moment in this PR all modules pull from `ja-dockerize-dev` branches, but these should be merged first, and this PR updated to point to the master branches before merging**. This is necessary for other changes to build process/docker-compose workflow.
As well as a Makefile for web, there is now a `Makefile.module`. This is copied into each module directory by the top-level Makefile, and is written in a way to be flexible and support unit tests, acceptance tests, front-end js for the ide and main, and the modules `app/coffee` directory, while allowing modules to have some of these missing (not all modules have e.g. acceptance tests, or front-end JS). This will allows us to refine the build process in future, without needing to update the Makefile in each module repo separately (I found this to be a painful part of this development).
This makes web compatible with the docker-compose workflow at https://github.com/sharelatex/sharelatex-dev-environment, where each service is running in its own docker container, with networking managed by docker.
Previously the Makefile was set up to run unit tests in docker with `make unit_tests`. This now just runs them natively. In the CI, they are run in docker anyway (all steps in Jenkins are), and locally, they run fine natively with `npm run test:unit`, or can be run in docker via https://github.com/sharelatex/sharelatex-dev-environment with `bin/run web_sl npm run test:unit`.
Previously we did a lot of juggling with only mounting source files (coffee, less, etc) into the docker container for acceptance tests. This was to avoid creating root owned files if the whole directory was mounted. Now instead the whole web directory is mounted read-only, with the compilation step done outside of the container before running the tests.
This allows the host and container to share the `node_modules` folder as well, which avoids needing to `npm install` twice on the CI box, and should speed up the build by a few minutes.
On macOS, this would cause a problem with compiled modules if you tried to use the same `node_modules` to run the app natively. However, if running via docker-compose in https://github.com/sharelatex/sharelatex-dev-environment, this is no longer a problem.
2017-12-28 15:11:27 -05:00
|
|
|
stage('Install modules') {
|
2017-08-16 05:43:48 -04:00
|
|
|
steps {
|
CI and local dev environment improvements
The need for this became very noticeable due to the slowness of filesystem access in docker-in-mac, with a full compile taking over a minute for me in docker. Using make to introduce incremental compile makes this near instantaneous outside of docker (if only a few files have changed), and quick enough inside docker.
With incremental compile via make, it compiles quickly enough that re-compiling and restarting the web service automatically when backend files change is quick enough now. This is how the service is run via docker-compose in https://github.com/sharelatex/sharelatex-dev-environment, so it shouldn't be necessary to manually restart the container each time a coffee file changes.
At the moment Jenkins pull web modules in via the GitSCM plugin, but I believe this is creating a dependency in Jenkins, where any commits to any of the modules causes all of the web branches to rebuild. By doing it via our own scripts we can hopefully avoid this. It also creates a build process which is reproducible locally.
**Note that at the moment in this PR all modules pull from `ja-dockerize-dev` branches, but these should be merged first, and this PR updated to point to the master branches before merging**. This is necessary for other changes to build process/docker-compose workflow.
As well as a Makefile for web, there is now a `Makefile.module`. This is copied into each module directory by the top-level Makefile, and is written in a way to be flexible and support unit tests, acceptance tests, front-end js for the ide and main, and the modules `app/coffee` directory, while allowing modules to have some of these missing (not all modules have e.g. acceptance tests, or front-end JS). This will allows us to refine the build process in future, without needing to update the Makefile in each module repo separately (I found this to be a painful part of this development).
This makes web compatible with the docker-compose workflow at https://github.com/sharelatex/sharelatex-dev-environment, where each service is running in its own docker container, with networking managed by docker.
Previously the Makefile was set up to run unit tests in docker with `make unit_tests`. This now just runs them natively. In the CI, they are run in docker anyway (all steps in Jenkins are), and locally, they run fine natively with `npm run test:unit`, or can be run in docker via https://github.com/sharelatex/sharelatex-dev-environment with `bin/run web_sl npm run test:unit`.
Previously we did a lot of juggling with only mounting source files (coffee, less, etc) into the docker container for acceptance tests. This was to avoid creating root owned files if the whole directory was mounted. Now instead the whole web directory is mounted read-only, with the compilation step done outside of the container before running the tests.
This allows the host and container to share the `node_modules` folder as well, which avoids needing to `npm install` twice on the CI box, and should speed up the build by a few minutes.
On macOS, this would cause a problem with compiled modules if you tried to use the same `node_modules` to run the app natively. However, if running via docker-compose in https://github.com/sharelatex/sharelatex-dev-environment, this is no longer a problem.
2017-12-28 15:11:27 -05:00
|
|
|
sshagent (credentials: ['GIT_DEPLOY_KEY']) {
|
|
|
|
sh 'bin/install_modules'
|
|
|
|
}
|
2017-08-16 05:43:48 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Install') {
|
2017-09-15 09:20:03 -04:00
|
|
|
agent {
|
|
|
|
docker {
|
|
|
|
image 'node:6.9.5'
|
|
|
|
args "-v /var/lib/jenkins/.npm:/tmp/.npm"
|
|
|
|
reuseNode true
|
|
|
|
}
|
|
|
|
}
|
2017-08-16 05:43:48 -04:00
|
|
|
steps {
|
2017-09-15 09:20:03 -04:00
|
|
|
sh 'git config --global core.logallrefupdates false'
|
CI and local dev environment improvements
The need for this became very noticeable due to the slowness of filesystem access in docker-in-mac, with a full compile taking over a minute for me in docker. Using make to introduce incremental compile makes this near instantaneous outside of docker (if only a few files have changed), and quick enough inside docker.
With incremental compile via make, it compiles quickly enough that re-compiling and restarting the web service automatically when backend files change is quick enough now. This is how the service is run via docker-compose in https://github.com/sharelatex/sharelatex-dev-environment, so it shouldn't be necessary to manually restart the container each time a coffee file changes.
At the moment Jenkins pull web modules in via the GitSCM plugin, but I believe this is creating a dependency in Jenkins, where any commits to any of the modules causes all of the web branches to rebuild. By doing it via our own scripts we can hopefully avoid this. It also creates a build process which is reproducible locally.
**Note that at the moment in this PR all modules pull from `ja-dockerize-dev` branches, but these should be merged first, and this PR updated to point to the master branches before merging**. This is necessary for other changes to build process/docker-compose workflow.
As well as a Makefile for web, there is now a `Makefile.module`. This is copied into each module directory by the top-level Makefile, and is written in a way to be flexible and support unit tests, acceptance tests, front-end js for the ide and main, and the modules `app/coffee` directory, while allowing modules to have some of these missing (not all modules have e.g. acceptance tests, or front-end JS). This will allows us to refine the build process in future, without needing to update the Makefile in each module repo separately (I found this to be a painful part of this development).
This makes web compatible with the docker-compose workflow at https://github.com/sharelatex/sharelatex-dev-environment, where each service is running in its own docker container, with networking managed by docker.
Previously the Makefile was set up to run unit tests in docker with `make unit_tests`. This now just runs them natively. In the CI, they are run in docker anyway (all steps in Jenkins are), and locally, they run fine natively with `npm run test:unit`, or can be run in docker via https://github.com/sharelatex/sharelatex-dev-environment with `bin/run web_sl npm run test:unit`.
Previously we did a lot of juggling with only mounting source files (coffee, less, etc) into the docker container for acceptance tests. This was to avoid creating root owned files if the whole directory was mounted. Now instead the whole web directory is mounted read-only, with the compilation step done outside of the container before running the tests.
This allows the host and container to share the `node_modules` folder as well, which avoids needing to `npm install` twice on the CI box, and should speed up the build by a few minutes.
On macOS, this would cause a problem with compiled modules if you tried to use the same `node_modules` to run the app natively. However, if running via docker-compose in https://github.com/sharelatex/sharelatex-dev-environment, this is no longer a problem.
2017-12-28 15:11:27 -05:00
|
|
|
sh 'rm -rf node_modules/'
|
|
|
|
sh 'npm install --quiet'
|
2017-08-16 05:43:48 -04:00
|
|
|
sh 'npm rebuild'
|
2017-10-09 09:23:05 -04:00
|
|
|
// It's too easy to end up shrinkwrapping to an outdated version of translations.
|
2017-10-09 09:22:04 -04:00
|
|
|
// Ensure translations are always latest, regardless of shrinkwrap
|
|
|
|
sh 'npm install git+https://github.com/sharelatex/translations-sharelatex.git#master'
|
2017-12-01 05:49:00 -05:00
|
|
|
}
|
|
|
|
}
|
2017-08-16 05:43:48 -04:00
|
|
|
|
|
|
|
stage('Compile') {
|
2017-09-15 09:20:03 -04:00
|
|
|
agent {
|
|
|
|
docker {
|
|
|
|
image 'node:6.9.5'
|
|
|
|
reuseNode true
|
|
|
|
}
|
|
|
|
}
|
2017-08-16 05:43:48 -04:00
|
|
|
steps {
|
2018-02-12 08:24:40 -05:00
|
|
|
sh 'make clean compile_full'
|
2017-09-29 05:37:39 -04:00
|
|
|
// replace the build number placeholder for sentry
|
|
|
|
sh 'node_modules/.bin/grunt version'
|
2017-08-16 05:43:48 -04:00
|
|
|
}
|
|
|
|
}
|
2018-02-23 06:44:43 -05:00
|
|
|
|
|
|
|
stage('Lint') {
|
|
|
|
agent {
|
|
|
|
docker {
|
|
|
|
image 'node:6.9.5'
|
|
|
|
reuseNode true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
steps {
|
|
|
|
sh 'make --no-print-directory lint'
|
|
|
|
}
|
|
|
|
}
|
CI and local dev environment improvements
The need for this became very noticeable due to the slowness of filesystem access in docker-in-mac, with a full compile taking over a minute for me in docker. Using make to introduce incremental compile makes this near instantaneous outside of docker (if only a few files have changed), and quick enough inside docker.
With incremental compile via make, it compiles quickly enough that re-compiling and restarting the web service automatically when backend files change is quick enough now. This is how the service is run via docker-compose in https://github.com/sharelatex/sharelatex-dev-environment, so it shouldn't be necessary to manually restart the container each time a coffee file changes.
At the moment Jenkins pull web modules in via the GitSCM plugin, but I believe this is creating a dependency in Jenkins, where any commits to any of the modules causes all of the web branches to rebuild. By doing it via our own scripts we can hopefully avoid this. It also creates a build process which is reproducible locally.
**Note that at the moment in this PR all modules pull from `ja-dockerize-dev` branches, but these should be merged first, and this PR updated to point to the master branches before merging**. This is necessary for other changes to build process/docker-compose workflow.
As well as a Makefile for web, there is now a `Makefile.module`. This is copied into each module directory by the top-level Makefile, and is written in a way to be flexible and support unit tests, acceptance tests, front-end js for the ide and main, and the modules `app/coffee` directory, while allowing modules to have some of these missing (not all modules have e.g. acceptance tests, or front-end JS). This will allows us to refine the build process in future, without needing to update the Makefile in each module repo separately (I found this to be a painful part of this development).
This makes web compatible with the docker-compose workflow at https://github.com/sharelatex/sharelatex-dev-environment, where each service is running in its own docker container, with networking managed by docker.
Previously the Makefile was set up to run unit tests in docker with `make unit_tests`. This now just runs them natively. In the CI, they are run in docker anyway (all steps in Jenkins are), and locally, they run fine natively with `npm run test:unit`, or can be run in docker via https://github.com/sharelatex/sharelatex-dev-environment with `bin/run web_sl npm run test:unit`.
Previously we did a lot of juggling with only mounting source files (coffee, less, etc) into the docker container for acceptance tests. This was to avoid creating root owned files if the whole directory was mounted. Now instead the whole web directory is mounted read-only, with the compilation step done outside of the container before running the tests.
This allows the host and container to share the `node_modules` folder as well, which avoids needing to `npm install` twice on the CI box, and should speed up the build by a few minutes.
On macOS, this would cause a problem with compiled modules if you tried to use the same `node_modules` to run the app natively. However, if running via docker-compose in https://github.com/sharelatex/sharelatex-dev-environment, this is no longer a problem.
2017-12-28 15:11:27 -05:00
|
|
|
|
|
|
|
stage('Unit Test') {
|
2017-09-15 09:20:03 -04:00
|
|
|
agent {
|
|
|
|
docker {
|
|
|
|
image 'node:6.9.5'
|
|
|
|
reuseNode true
|
|
|
|
}
|
|
|
|
}
|
2017-08-16 05:43:48 -04:00
|
|
|
steps {
|
2018-02-19 09:55:33 -05:00
|
|
|
sh 'make --no-print-directory test_unit MOCHA_ARGS="--reporter tap"'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Frontend Unit Test') {
|
|
|
|
steps {
|
|
|
|
// Spawns its own docker containers
|
|
|
|
sh 'make --no-print-directory test_frontend'
|
CI and local dev environment improvements
The need for this became very noticeable due to the slowness of filesystem access in docker-in-mac, with a full compile taking over a minute for me in docker. Using make to introduce incremental compile makes this near instantaneous outside of docker (if only a few files have changed), and quick enough inside docker.
With incremental compile via make, it compiles quickly enough that re-compiling and restarting the web service automatically when backend files change is quick enough now. This is how the service is run via docker-compose in https://github.com/sharelatex/sharelatex-dev-environment, so it shouldn't be necessary to manually restart the container each time a coffee file changes.
At the moment Jenkins pull web modules in via the GitSCM plugin, but I believe this is creating a dependency in Jenkins, where any commits to any of the modules causes all of the web branches to rebuild. By doing it via our own scripts we can hopefully avoid this. It also creates a build process which is reproducible locally.
**Note that at the moment in this PR all modules pull from `ja-dockerize-dev` branches, but these should be merged first, and this PR updated to point to the master branches before merging**. This is necessary for other changes to build process/docker-compose workflow.
As well as a Makefile for web, there is now a `Makefile.module`. This is copied into each module directory by the top-level Makefile, and is written in a way to be flexible and support unit tests, acceptance tests, front-end js for the ide and main, and the modules `app/coffee` directory, while allowing modules to have some of these missing (not all modules have e.g. acceptance tests, or front-end JS). This will allows us to refine the build process in future, without needing to update the Makefile in each module repo separately (I found this to be a painful part of this development).
This makes web compatible with the docker-compose workflow at https://github.com/sharelatex/sharelatex-dev-environment, where each service is running in its own docker container, with networking managed by docker.
Previously the Makefile was set up to run unit tests in docker with `make unit_tests`. This now just runs them natively. In the CI, they are run in docker anyway (all steps in Jenkins are), and locally, they run fine natively with `npm run test:unit`, or can be run in docker via https://github.com/sharelatex/sharelatex-dev-environment with `bin/run web_sl npm run test:unit`.
Previously we did a lot of juggling with only mounting source files (coffee, less, etc) into the docker container for acceptance tests. This was to avoid creating root owned files if the whole directory was mounted. Now instead the whole web directory is mounted read-only, with the compilation step done outside of the container before running the tests.
This allows the host and container to share the `node_modules` folder as well, which avoids needing to `npm install` twice on the CI box, and should speed up the build by a few minutes.
On macOS, this would cause a problem with compiled modules if you tried to use the same `node_modules` to run the app natively. However, if running via docker-compose in https://github.com/sharelatex/sharelatex-dev-environment, this is no longer a problem.
2017-12-28 15:11:27 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Acceptance Test') {
|
|
|
|
steps {
|
|
|
|
// Spawns its own docker containers
|
|
|
|
sh 'make --no-print-directory test_acceptance MOCHA_ARGS="--reporter tap"'
|
2017-08-16 05:43:48 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Minify') {
|
2017-09-15 09:20:03 -04:00
|
|
|
agent {
|
|
|
|
docker {
|
|
|
|
image 'node:6.9.5'
|
|
|
|
reuseNode true
|
|
|
|
}
|
|
|
|
}
|
2017-08-16 05:43:48 -04:00
|
|
|
steps {
|
2018-05-11 10:34:22 -04:00
|
|
|
sh 'WEBPACK_ENV=production make minify'
|
2017-08-16 05:43:48 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Package') {
|
|
|
|
steps {
|
|
|
|
sh 'rm -rf ./node_modules/grunt*'
|
2017-09-04 09:58:13 -04:00
|
|
|
sh 'echo ${BUILD_NUMBER} > build_number.txt'
|
2017-08-16 05:43:48 -04:00
|
|
|
sh 'touch build.tar.gz' // Avoid tar warning about files changing during read
|
|
|
|
sh 'tar -czf build.tar.gz --exclude=build.tar.gz --exclude-vcs .'
|
|
|
|
}
|
|
|
|
}
|
2017-09-15 09:20:03 -04:00
|
|
|
|
2017-08-16 05:43:48 -04:00
|
|
|
stage('Publish') {
|
|
|
|
steps {
|
|
|
|
withAWS(credentials:'S3_CI_BUILDS_AWS_KEYS', region:"${S3_REGION_BUILD_ARTEFACTS}") {
|
|
|
|
s3Upload(file:'build.tar.gz', bucket:"${S3_BUCKET_BUILD_ARTEFACTS}", path:"${JOB_NAME}/${BUILD_NUMBER}.tar.gz")
|
2017-09-04 09:58:13 -04:00
|
|
|
// The deployment process uses this file to figure out the latest build
|
|
|
|
s3Upload(file:'build_number.txt', bucket:"${S3_BUCKET_BUILD_ARTEFACTS}", path:"${JOB_NAME}/latest")
|
2017-08-16 05:43:48 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-09-15 09:20:03 -04:00
|
|
|
|
|
|
|
|
|
|
|
stage('Sync OSS') {
|
|
|
|
when {
|
|
|
|
branch 'master'
|
|
|
|
}
|
|
|
|
steps {
|
|
|
|
sshagent (credentials: ['GIT_DEPLOY_KEY']) {
|
2017-09-18 05:11:33 -04:00
|
|
|
sh 'git push git@github.com:sharelatex/web-sharelatex.git HEAD:master'
|
2017-09-15 09:20:03 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-08-16 05:43:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
post {
|
2017-12-14 04:32:38 -05:00
|
|
|
always {
|
CI and local dev environment improvements
The need for this became very noticeable due to the slowness of filesystem access in docker-in-mac, with a full compile taking over a minute for me in docker. Using make to introduce incremental compile makes this near instantaneous outside of docker (if only a few files have changed), and quick enough inside docker.
With incremental compile via make, it compiles quickly enough that re-compiling and restarting the web service automatically when backend files change is quick enough now. This is how the service is run via docker-compose in https://github.com/sharelatex/sharelatex-dev-environment, so it shouldn't be necessary to manually restart the container each time a coffee file changes.
At the moment Jenkins pull web modules in via the GitSCM plugin, but I believe this is creating a dependency in Jenkins, where any commits to any of the modules causes all of the web branches to rebuild. By doing it via our own scripts we can hopefully avoid this. It also creates a build process which is reproducible locally.
**Note that at the moment in this PR all modules pull from `ja-dockerize-dev` branches, but these should be merged first, and this PR updated to point to the master branches before merging**. This is necessary for other changes to build process/docker-compose workflow.
As well as a Makefile for web, there is now a `Makefile.module`. This is copied into each module directory by the top-level Makefile, and is written in a way to be flexible and support unit tests, acceptance tests, front-end js for the ide and main, and the modules `app/coffee` directory, while allowing modules to have some of these missing (not all modules have e.g. acceptance tests, or front-end JS). This will allows us to refine the build process in future, without needing to update the Makefile in each module repo separately (I found this to be a painful part of this development).
This makes web compatible with the docker-compose workflow at https://github.com/sharelatex/sharelatex-dev-environment, where each service is running in its own docker container, with networking managed by docker.
Previously the Makefile was set up to run unit tests in docker with `make unit_tests`. This now just runs them natively. In the CI, they are run in docker anyway (all steps in Jenkins are), and locally, they run fine natively with `npm run test:unit`, or can be run in docker via https://github.com/sharelatex/sharelatex-dev-environment with `bin/run web_sl npm run test:unit`.
Previously we did a lot of juggling with only mounting source files (coffee, less, etc) into the docker container for acceptance tests. This was to avoid creating root owned files if the whole directory was mounted. Now instead the whole web directory is mounted read-only, with the compilation step done outside of the container before running the tests.
This allows the host and container to share the `node_modules` folder as well, which avoids needing to `npm install` twice on the CI box, and should speed up the build by a few minutes.
On macOS, this would cause a problem with compiled modules if you tried to use the same `node_modules` to run the app natively. However, if running via docker-compose in https://github.com/sharelatex/sharelatex-dev-environment, this is no longer a problem.
2017-12-28 15:11:27 -05:00
|
|
|
sh 'make clean_ci'
|
2017-12-14 04:32:38 -05:00
|
|
|
}
|
|
|
|
|
2017-08-16 05:43:48 -04:00
|
|
|
failure {
|
|
|
|
mail(from: "${EMAIL_ALERT_FROM}",
|
|
|
|
to: "${EMAIL_ALERT_TO}",
|
|
|
|
subject: "Jenkins build failed: ${JOB_NAME}:${BUILD_NUMBER}",
|
|
|
|
body: "Build: ${BUILD_URL}")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// The options directive is for configuration that applies to the whole job.
|
|
|
|
options {
|
2017-09-04 11:02:16 -04:00
|
|
|
// Only build one at a time
|
|
|
|
disableConcurrentBuilds()
|
|
|
|
|
2017-08-16 05:43:48 -04:00
|
|
|
// we'd like to make sure remove old builds, so we don't fill up our storage!
|
|
|
|
buildDiscarder(logRotator(numToKeepStr:'50'))
|
|
|
|
|
|
|
|
// And we'd really like to be sure that this build doesn't hang forever, so let's time it out after:
|
|
|
|
timeout(time: 30, unit: 'MINUTES')
|
|
|
|
}
|
|
|
|
}
|