Commit 67cf9663 authored by Andrew Newdigate's avatar Andrew Newdigate

gitlab ci build

parent aed9aec5
......@@ -47,6 +47,7 @@
"no-with": "error",
"no-useless-call": "error",
"no-spaced-func": "error",
"no-useless-escape": "warn",
"max-statements": [
"warn",
30
......
stages:
- docker_images
- build_unit_test
- deploy
.job_template: &node_job
image: registry.gitlab.com/gitlab-org/gitter/webapp
before_script:
- npm config set prefer-offline true
- npm config set cache /npm_cache
- mv /app/node_modules ./node_modules
- npm install
# Do this until we've solved the bug in
# shrinkwrap process
# this means that this fork is not production ready quite yet
- npm shrinkwrap
.job_template: &docker_job
image: registry.gitlab.com/gitlab-org/gitter/webapp/dind:latest
services:
- docker:dind
# Disabled for now
# test:
# <<: *docker_job
# stage: build_unit_test
# variables:
# COMPOSE_HTTP_TIMEOUT: 120 # Two minute timeout for slow pulls
# script:
# - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com
# - ./exec-in-docker2 make test
validate:
<<: *node_job
stage: build_unit_test
script:
- make validate
package:
<<: *node_job
stage: build_unit_test
script:
- make package
artifacts:
paths:
- output/app.tar.gz
- output/assets.tar.gz
expire_in: 1 week
docker-base:
variables:
DOCKER_DRIVER: overlay
stage: docker_images
only:
- schedules
image: docker:latest
services:
- docker:dind
script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com
- docker build -t registry.gitlab.com/gitlab-org/gitter/webapp .
- docker push registry.gitlab.com/gitlab-org/gitter/webapp
docker-dind:
variables:
DOCKER_DRIVER: overlay
stage: docker_images
only:
- schedules
image: docker:latest
services:
- docker:dind
script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com
- docker build -t registry.gitlab.com/gitlab-org/gitter/webapp/dind:latest scripts/docker/dind/
- docker push registry.gitlab.com/gitlab-org/gitter/webapp/dind:latest
deploy_beta:
stage: deploy
script:
- echo "Deploy to beta server"
environment:
name: beta
url: https://beta.gitter.im
only:
- develop
deploy_beta_staging:
stage: deploy
script:
- echo "Deploy to beta staging server"
environment:
name: beta
url: https://beta.gitter.im
only:
- /^feature\/.*$/
# Contributor license agreement
By submitting code or text for the website as an individual you agree to the GitLab [individual contributor license agreement](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/legal/individual_contributor_license_agreement.md).
By submitting code or text for the website as an entity you agree to the GitLab [corporate contributor license agreement](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/legal/corporate_contributor_license_agreement.md).
For more information about the technicalities of contributing please see the [README](README.md).
FROM docker-registry.service.jenkins.gitter:5000/node/node:${NODE_VERSION}
FROM node:4
ENV PKGLIST="git make gcc g++ python linux-headers paxctl gnupg"
RUN apk add --no-cache $PKGLIST libgcc libstdc++
ENV ENV="${ENVIRONMENT}"
ENV NODE_ENV="$ENV"
ENV GIT_TAG="${GIT_TAG}"
ENV GIT_COMMIT="${GIT_COMMIT}"
ENV HOME="/root"
ENV TMPDIR="/tmp/gitter"
ENV PORT=5000
LABEL selected-git-tag="${SELECTED_GIT_TAG}"
LABEL git-tag="${GIT_TAG}"
LABEL git-commit="${GIT_COMMIT}"
LABEL staged="${STAGED_ENVIRONMENT}"
LABEL node-version="${NODE_VERSION}"
LABEL env="${ENVIRONMENT}"
EXPOSE $PORT
ENTRYPOINT ["node"]
RUN mkdir -p /app /npm_cache
WORKDIR /app
COPY ./app/ /app
COPY ./ssh/ /root/.ssh
RUN npm install -g npm@latest-5
RUN npm config set cache /npm_cache
RUN npm config set prefer-offline true
# TODO: add npm-shrinkwrap here too
COPY package.json /app/
RUN sed -i '/file:.*modules/d; /file:.*shared/d' package.json
RUN npm install
RUN rm -rf /app/node_modules
RUN npm install --production
RUN apk del $PKGLIST
RUN rm -rf /tmp/* /var/cache/apk/* /root/.npm /root/.node-gyp /root/.gnupg /root/.ssh 2>/dev/null
The MIT License (MIT)
Copyright (c) 2017 GitLab B.V.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
......@@ -8,28 +8,32 @@ continuous-integration: build
build: clean npm validate test package
validate: npm
validate:
gulp validate
test-lua:
echo lua tests disabled #gulp test-redis-lua
package: npm
package:
gulp package --skip-stage validate --skip-stage test
clean: npm
clean:
gulp clean || (make npm-full && gulp clean)
# If gulp clean failed, it's almost certainly a problem
# with the npm folder, so nuke it and try again
test: clean npm
ci-test: clean
mkdir -p output/
./exec-in-docker ./node_modules/.bin/gulp test --test-coverage --test-suite docker --test-xunit-reports
gulp test --test-coverage --test-suite docker --test-xunit-reports
echo "Docker tests completed"
test-no-coverage: clean npm
test: clean
mkdir -p output/
./exec-in-docker ./node_modules/.bin/gulp test --test-suite docker --test-xunit-reports
gulp test
test-no-coverage: clean
mkdir -p output/
gulp test --test-suite docker --test-xunit-reports
echo "Docker tests completed"
print-nodejs-version:
......@@ -39,17 +43,12 @@ print-nodejs-version:
npm-quick: print-nodejs-version
npm prune
npm install
npm run link
./build-scripts/validate-modules-for-build.sh
npm-full: print-nodejs-version
npm cache clean
rm -rf node_modules/
rm -rf modules/*/node_modules
rm -rf shared/node_modules
rm -rf node_modules/ modules/*/node_modules shared/node_modules
npm install
npm run link
npm:
make npm-quick || make npm-full
......
......@@ -9,14 +9,21 @@ Gitter requires MongoDB, Redis, ElasticSearch and Neo4J. These are all included
## Mac
1. Install [Docker Toolbox](https://www.docker.com/products/docker-toolbox)
* **Please note this is different to Docker for Mac**
* Due to limitations in Docker for Mac and Docker for Windows, you cannot use these products.
* You can choose either `Docker Quickstart Terminal` or `Kitematic`
* You can choose either *Docker Quickstart Terminal* or *Kitematic*
2. Install [Node.js 4](https://nodejs.org/dist/latest-v4.x/)
* We recommend doing this with `nvm`
* We recommend doing this with **nvm**
* You can install nvm with `curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash`
* `nvm install 4/*` will install the latest 4.x version of node
3. Install **npm 5** with `npm install npm@latest -g`
* If you are unable to run npm 5 for whatever reason, you will need to `npm i -g linklocal` and then run `linklocal` after running `npm install`
3. Clone this repo
4. Run `npm install`
* Go and make a cup of tea, because this will take a rather long time.
5. Whilst drinking your tea, make sure you have Gulp installed. You can do this with `npm install -g gulp`. You may need to use `sudo` for this.
6. Do an initial compile of the CSS with `npm run task-css` this will be part of the gulp task [in the future](https://gitlab.com/gitlab-org/gitter/webapp/issues/1741).
## Starting Gitter
......@@ -24,7 +31,7 @@ Gitter requires MongoDB, Redis, ElasticSearch and Neo4J. These are all included
Gitter uses hostnames to connect to the dependant Docker-provided services. When starting Gitter, we will prompt you to automatically add these to your hostfile. This requires sudo. If you do not feel comfortable, you will need to do it manually in order for Gitter to work.
Below is an example of what this should look like
Below is an example of what this should look like. If you are happy for us to do this for you, you don't need to do anything here.
```
192.168.99.100 gitter-mongo-dev
......@@ -58,4 +65,16 @@ Export the environment variables with:
Only proceed once the Docker containers have downloaded and installed.
Gitter is executed through Gulp with the following command:
```gulp watch```
`gulp watch`
Visit [http://localhost:5000](http://localhost:5000)
### Shutting Docker down
You can stop the docker containers with `./kill-services` or `docker-machine stop`
If this doesn't work, you can also use `docker-machine rm -f default`.
# Contributing
We use GitFlow and MRs should be made against `develop` not `master`.
......@@ -3,7 +3,7 @@
var gulp = require('gulp');
var gutil = require('gulp-util');
var sourcemaps = require('gulp-sourcemaps');
var webpack = require('gulp-webpack');
var webpack = require('webpack-stream');
var uglify = require('gulp-uglify');
var restoreTimestamps = require('./gulp-restore-timestamps');
var getSourceMapOptions = require('./get-sourcemap-options');
......
......@@ -7,7 +7,7 @@ var mqpacker = require('css-mqpacker');
var csswring = require('csswring');
var styleBuilder = require('./style-builder');
var getSourceMapOptions = require('./get-sourcemap-options');
var webpack = require('gulp-webpack');
var webpack = require('webpack-stream');
var uglify = require('gulp-uglify');
var cssDestDir = 'output/assets/styles';
......
......@@ -12,7 +12,7 @@ var eslintFilter = require('./eslint-filter');
var del = require('del');
function guessBaseBranch() {
var branch = process.env.GIT_BRANCH;
var branch = process.env.CI_COMMIT_REF_NAME || process.env.GIT_BRANCH;
if (!branch) return 'develop';
if (branch.match(/\bfeature\//)) return 'origin/develop';
......@@ -35,6 +35,7 @@ gulp.task('linter:validate:eslint', function() {
quiet: argv.quiet,
extensions: ['.js', '.jsx']
}))
.pipe(eslint.format('unix'))
.pipe(eslint.format('checkstyle', function(checkstyleData) {
fs.writeFileSync('output/eslint/checkstyle.xml', checkstyleData);
}))
......@@ -69,7 +70,7 @@ gulp.task('linter:validate:eslint-diff', function() {
/**
* Hook into the validate phase
*/
gulp.task('linter:validate', ['linter:validate:config', 'linter:validate:eslint', 'linter:validate:eslint-diff']);
gulp.task('linter:validate', ['linter:validate:config', 'linter:validate:eslint'/*, 'linter:validate:eslint-diff'*/]);
gulp.task('linter:clean', function (cb) {
......
......@@ -59,8 +59,8 @@ gulp.task('process:assemble:copy-app:version', function(done) {
}
// Use jenkins variables
if(branch === 'HEAD' && process.env.GIT_BRANCH) {
branch = process.env.GIT_BRANCH;
if(branch === 'HEAD' && process.env.CI_COMMIT_REF_SLUG) {
branch = process.env.CI_COMMIT_REF_SLUG;
}
mkdirp.sync('output/app/');
......
'use strict';
// Loader adding a header
var htmlclean = require('htmlclean');
module.exports = function(source) {
this.cacheable();
var result = htmlclean(source, {
protect: /\{\{.*?\}\}/g
});
return result;
};
......@@ -795,7 +795,7 @@ body.outlook p {
.avatar {
border-radius: 4px;
}
img.avatar {
width: 24px;
height: 24px;
......@@ -959,7 +959,7 @@ body.outlook p {
<tr>
<td align="center">
<center>
<p>Copyright © 2016 Troupe Technology Limited<br>All rights reserved.</p>
Gitter, from <a href="https://gitlab.com">GitLab</a>.
</center>
</td>
<td class="expander"></td>
......
......@@ -98,7 +98,7 @@ elasticsearchsetup:
entrypoint: [ "/src/scripts/docker/es/setup-elasticsearch.sh" ]
internal-min:
image: node:${NODE_VERSION}
image: registry.gitlab.com/gitlab-org/gitter/webapp
restart: 'no'
links:
- redis1
......@@ -112,54 +112,12 @@ internal-min:
environment:
NODE_ENV: ${NODE_ENV}
DEBUG: ${DEBUG}
SU_TO_USER: ${SU_TO_USER}
SU_TO_UID: ${SU_TO_UID}
env_file: ${GITTER_SECRETS_ENV_FILE}
volumes:
- ${WORKSPACE}:${WORKSPACE}
extra_hosts:
beta-internal: 10.0.0.140
beta-internal.beta.gitter: 10.0.0.140
working_dir: ${WORKSPACE}
internal-mac:
image: node:${NODE_VERSION}
restart: 'no'
links:
- redis1
- redis2
- mongo1
- mongo2
- mongo3
- sentinel1
- elasticsearch
- neo4j
volumes:
- ${WORKSPACE}:${WORKSPACE}
- ${WORKSPACE}/node_modules_linux:${WORKSPACE}/node_modules/
extra_hosts:
beta-internal: 10.0.0.140
beta-internal.beta.gitter: 10.0.0.140
env_file: ${GITTER_SECRETS_ENV_FILE}
working_dir: ${WORKSPACE}
internal-mac-np:
image: node:${NODE_VERSION}
restart: 'no'
environment:
NODE_ENV: ${NODE_ENV}
DEBUG: ${DEBUG}
volumes:
- ${WORKSPACE}:${WORKSPACE}
- ${WORKSPACE}/node_modules_linux:${WORKSPACE}/node_modules/
extra_hosts:
beta-internal: 10.0.0.140
beta-internal.beta.gitter: 10.0.0.140
env_file: ${GITTER_SECRETS_ENV_FILE}
working_dir: ${WORKSPACE}
internal:
image: node:${NODE_VERSION}
image: registry.gitlab.com/gitlab-org/gitter/webapp
restart: 'no'
links:
- redis1
......@@ -172,5 +130,4 @@ internal:
- sentinel1
volumes:
- ${WORKSPACE}:/src
env_file: ${GITTER_SECRETS_ENV_FILE}
working_dir: /src
#!/bin/sh
set -u
set -e
set -x
WORKSPACE="$(pwd)"
DEBUG="${DEBUG:-}"
NODE_ENV="${NODE_ENV:-test-docker}"
NODE_VERSION="4"
export WORKSPACE
export DEBUG
export NODE_VERSION
export NODE_ENV
TARGET_DOCKER_CONTAINER=internal-min
function setup_env {
docker-compose -f docker-compose.internal.yml run --rm mongosetup &
sleep 2;
docker-compose -f docker-compose.internal.yml run --rm elasticsearchsetup &
echo "Waiting for setup to complete"
wait
echo "Setup complete"
}
if [[ -z "${SKIP_COMPOSE_SETUP:-}" ]]; then
setup_env
fi
docker-compose -f docker-compose.internal.yml run \
-e "NODE_ENV=${NODE_ENV}" \
-e "DEBUG=${DEBUG}" \
-e "WORKSPACE=${WORKSPACE:-}" \
"${TARGET_DOCKER_CONTAINER}" \
"/bin/sh" "-c" "$@"
echo "docker-compose run exited with $?"
# docker-compose -f docker-compose.internal.yml ps
# docker ps -a|grep "${PROJECT_NAME}"
echo "exec-in-docker complete, shutting down"
......@@ -8,6 +8,25 @@ set -euo pipefail
DOCKER_MACHINE_NAME=${DOCKER_MACHINE_NAME-default}
function has_docker_for_mac {
if [[ "$OSTYPE" == "linux-gnu" ]]; then
return 1
fi
# Is Docker for Mac running?
if (pgrep -f /Applications/Docker.app/Contents/MacOS/Docker > /dev/null); then
return 0
fi
return 1
}
if has_docker_for_mac; then
echo "The docker-compose setup is not compatible with Docker for Mac. Please install Docker Toolbox for Mac: https://docs.docker.com/toolbox/toolbox_install_mac/"
exit 1
fi
function has_local_docker_install {
if [[ "$OSTYPE" == "linux-gnu" ]]; then
return 0
......
......@@ -7,7 +7,7 @@
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"@gitterhq/env": "^0.29.2"
"@gitterhq/env": "^0.33.0"
},
"private": true
}
......@@ -15,7 +15,7 @@
"gitter-web-env": "file:../env",
"gitter-web-persistence": "file:../persistence",
"gitter-web-persistence-utils": "file:../persistence-utils",
"mongodb": "~2.1.18"
"mongodb": "~2.2.19"
},
"private": true
}
......@@ -17,7 +17,7 @@
"gitter-web-identity": "file:../identity",
"gitter-web-avatars": "file:../avatars",
"gitter-web-github": "file:../github",
"mongodb": "~2.1.18",
"mongodb": "~2.2.19",
"node-uuid": "^1.4.0",
"statuserror": "^0.1.3"
}
......
......@@ -12,7 +12,7 @@
<tr>
<td align="center">
<center>
<p>Copyright © 2016 Troupe Technology Limited<br>All rights reserved.</p>
<p>Gitter, from <a href="https://gitlab.com">GitLab</a>.</p>
</center>
</td>
<td class="expander"></td>
......
......@@ -9,6 +9,6 @@
"private": true,
"dependencies": {
"bluebird": "^3.2.1",
"mongoose": "~4.5.3"
"mongoose": "~4.10.0"
}
}
......@@ -13,7 +13,7 @@
"bluebird": "^3.2.1",
"gitter-web-env": "file:../env",
"lodash": "^3.2.0",
"mongodb": "~2.1.18",
"mongodb": "~2.2.19",
"mongodb-unique-ids": "^0.2.0"
}
}
......@@ -16,7 +16,7 @@
"gitter-web-env": "file:../env",
"gitter-web-mongoose-bluebird": "file:../mongoose-bluebird",
"lodash": "^3.2.0",
"mongoose": "~4.5.3",
"mongoose": "~4.10.0",
"mongoose-number": "^0.1.1",
"node-mongodb-debug-log": "^0.1.2"
}
......
'use strict';
var gulp = require('gulp');
var webpack = require('gulp-webpack');
var webpack = require('webpack-stream');
var sourcemaps = require('gulp-sourcemaps');
var uglify = require('gulp-uglify');
var filter = require('gulp-filter');
......
......@@ -22,7 +22,7 @@
"gulp-sourcemaps": "^1.6.0",
"gulp-uglify": "^1.4.2",
"gulp-util": "^3.0.7",
"gulp-webpack": "^1.5.0",
"webpack-stream": "^3.2.0",
"pump": "^1.0.1"
}
}
......@@ -22,7 +22,7 @@
"gitter-web-topic-serialization": "file:../topic-serialization",
"lodash": "^3.2.0",
"moment": "^2.10.3",
"mongodb": "~2.1.18",
"mongodb": "~2.2.19",
"rx": "^4.1.0",
"rx-node": "^1.0.2"
},
......
......@@ -15,7 +15,7 @@
"gitter-web-persistence-utils": "file:../persistence-utils",
"gitter-web-topic-models": "file:../topic-models",
"lodash": "^3.2.0",
"mongodb": "~2.1.18",
"mongodb": "~2.2.19",
"statuserror": "^0.1.3"
},
"devDependencies": {
......
......@@ -35,7 +35,7 @@
"react/jsx-uses-react": 2,
"react/jsx-uses-vars": 2,
"react/no-danger": 2,
"react/no-deprecated": 2,
"react/no-deprecated": "warn",
"react/no-did-mount-set-state": 2,
"react/no-did-update-set-state": 2,
"react/no-direct-mutation-state": 2,
......
'use strict';
var gulp = require('gulp');
var webpack = require('gulp-webpack');
var webpack = require('webpack-stream');
var sourcemaps = require('gulp-sourcemaps');
var uglify = require('gulp-uglify');
var filter = require('gulp-filter');
......
......@@ -37,7 +37,7 @@
"react/jsx-uses-react": 2,
"react/jsx-uses-vars": 2,
"react/no-danger": "off",
"react/no-deprecated": 2,
"react/no-deprecated": "warn",
"react/no-did-mount-set-state": 2,
"react/no-did-update-set-state": 2,
"react/no-direct-mutation-state": 2,
......
......@@ -34,7 +34,7 @@
"react/jsx-uses-react": 2,
"react/jsx-uses-vars": 2,
"react/no-danger": 2,
"react/no-deprecated": 2,
"react/no-deprecated": "warn",
"react/no-did-mount-set-state": 2,
"react/no-did-update-set-state": 2,
"react/no-direct-mutation-state": 2,
......
......@@ -34,7 +34,7 @@
"react/jsx-uses-react": 2,
"react/jsx-uses-vars": 2,
"react/no-danger": 2,
"react/no-deprecated": 2,
"react/no-deprecated": "warn",
"react/no-did-mount-set-state": 2,
"react/no-did-update-set-state": 2,
"react/no-direct-mutation-state": 2,
......
......@@ -34,7 +34,7 @@
"react/jsx-uses-react": 2,
"react/jsx-uses-vars": 2,
"react/no-danger": 2,
"react/no-deprecated": 2,
"react/no-deprecated": "warn",
"react/no-did-mount-set-state": 2,
"react/no-did-update-set-state": 2,
"react/no-direct-mutation-state": 2,
......
......@@ -24,7 +24,7 @@
"react/jsx-uses-react": 2,
"react/jsx-uses-vars": 2,
"react/no-danger": "off",
"react/no-deprecated": 2,
"react/no-deprecated": "warn",
"react/no-did-mount-set-state": 2,
"react/no-did-update-set-state": 2,
"react/no-direct-mutation-state": 2,
......
This diff is collapsed.
This diff is collapsed.