diff --git a/.circleci/config.yml b/.circleci/config.yml index 5cc557870300..6295f00f6213 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -59,7 +59,7 @@ jobs: - run: name: Install submodules command: | - git submodule init && git submodule updated + git submodule init && git submodule update - run: name: Lint @@ -176,8 +176,8 @@ jobs: - run: name: Run Tests command: | - for i in $(seq 1 5); do npm test && s=0 && break || s=$? && sleep 1; done; (exit $s) - + rm -rf ./tests/end-to-end/ui_smarti # Smarti tests run separately + npm test - store_artifacts: path: .screenshots/ @@ -189,7 +189,7 @@ jobs: environment: TEST_MODE: "true" - MONGO_URL: mongodb://localhost:27017/testwithoplog + MONGO_URL: mongodb://localhost:27017/testwithoutplog steps: - attach_workspace: @@ -205,7 +205,53 @@ jobs: - run: name: Run Tests command: | - for i in $(seq 1 5); do npm test && s=0 && break || s=$? && sleep 1; done; (exit $s) + rm -rf ./tests/end-to-end/ui_smarti # Smarti tests run separately + npm test + + - store_artifacts: + path: .screenshots/ + + test-smarti: + <<: *defaults + docker: + - image: circleci/node:8-browsers + - image: circleci/mongo:3.4 + - image: assisitfy/smarti:0.7.0-RC1 + + environment: + TEST_MODE: "true" + MONGO_URL: mongodb://localhost:27017/testsmarti + SPRING_DATA_MONGODB_URI: mongodb://localhost:27017/smarti + SECURITY_CONFIG_MONGO_ADMIN-PASSWORD: admin + + steps: + - attach_workspace: + at: /tmp + + - checkout + + # Enable remote docker host for temporary images (see https://circleci.com/docs/2.0/building-docker-images/ + # - setup_remote_docker: + # docker_layer_caching: true + + # - run: + # name: Build and start Smarti + # command: | + # docker pull assisitfy/smarti:0.7.0-RC1 + # docker build -t smarti-with-stanfordnlp - < .scripts/dockerfile-smarti-with-nlp + # docker run -d --name smarti --net=host smarti-with-stanfordnlp --security.config.mongo.admin-password=admin --spring.data.mongodb.uri=mongodb://localhost/smarti +# + # - run: + # name: NPM install + # command: | + # npm install + + - run: + name: Run Tests + command: | + shopt -s extglob + rm -rf ./tests/end-to-end/!(ui_smarti) # remove all non-Smarti-tests + npm test - store_artifacts: path: .screenshots/ @@ -237,8 +283,7 @@ jobs: name: Publish assets command: | if [[ $CIRCLE_PULL_REQUESTS ]]; then exit 0; fi; - - bash .scripts/check-deploy.sh + bash .scripts/deploy-assistify-chat.sh workflows: version: 2 @@ -260,13 +305,28 @@ workflows: filters: tags: only: /^[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?$/ + branches: + only: + - circle-without-oplog + - test-smarti: + requires: + - build + filters: + tags: + only: /^[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?$/ + branches: + only: + - circle-smarti - deploy: requires: - test-with-oplog - - test-without-oplog + # - test-without-oplog + # - test-smarti filters: branches: - only: develop + only: + - develop + - master tags: only: /^[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?$/ diff --git a/.scripts/check-deploy.sh b/.scripts/check-deploy.sh deleted file mode 100755 index 41d44283f886..000000000000 --- a/.scripts/check-deploy.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env bash - -pip install --user --upgrade awscli -export PATH=$PATH:$HOME/.local/bin - -mkdir -p ~/.aws - -cat > ~/.aws/credentials << EOL -[default] -aws_access_key_id = ${AWS_ACCESS_KEY} -aws_secret_access_key = ${AWS_SECRET_KEY} -EOL - -TARGET_ENVIRONMENT=undefined -if [ ${TRAVIS_BRANCH} = master ] - then - TARGET_ENVIRONMENT=production -else - if [[ ${TRAVIS_BRANCH} == develop ]] || [[ $TRAVIS_BRANCH == "release/"* ]] - then - TARGET_ENVIRONMENT=test - fi -fi - -aws s3api put-object-tagging --region ${AWS_REGION} --bucket ${AWS_BUCKET} --key rocketchat/${BUILD_FILE} --tagging "{ \"TagSet\": [ { \"Key\": \"environment\", \"Value\": \"${TARGET_ENVIRONMENT}\" }, { \"Key\": \"nodejs_version\", \"Value\": \"${NODEJS_VERSION}\" }, { \"Key\": \"nodejs_checksum\", \"Value\": \"${NODEJS_CHECKSUM}\" }, { \"Key\": \"assets\", \"Value\": \"${ASSETS_URL}\" } ] }" diff --git a/.scripts/continueTesting.sh b/.scripts/continueTesting.sh index e03cca19add7..19a0e174e56a 100755 --- a/.scripts/continueTesting.sh +++ b/.scripts/continueTesting.sh @@ -2,7 +2,7 @@ tmpPath=tests/end-to-end/temporary_staged_test stopfile=`find ${tmpPath} -type f | head -1` echo 'Last stop at:' $stopfile -[ -z "$retry_test" ] && retry_test=1 +[ -z "$RETRY_TESTS" ] && RETRY_TESTS=1 stopfile=`find ${tmpPath} -type f | head -1` array=(`find tests/end-to-end/*/*.js -type f`) @@ -15,11 +15,11 @@ rm -rf $tmpPath mkdir -p $tmpPath for file in ${array[@]:$j}; do failed=1 - for i in `seq 1 $retry_test`; do + for i in `seq 1 $RETRY_TESTS`; do echo '-------------- '$i' try ---------------' set -x cp $file $tmpPath - CHIMP_PATH=$tmpPath meteor npm run chimp-path + CHIMP_PATH=$tmpPath npm run chimp-path failed=$? set +x if [ $failed -eq 0 ]; then @@ -30,4 +30,4 @@ for file in ${array[@]:$j}; do exit 1 fi rm $tmpPath/${file##*/} -done \ No newline at end of file +done diff --git a/.scripts/deploy-assistify-chat.sh b/.scripts/deploy-assistify-chat.sh new file mode 100755 index 000000000000..939981b82618 --- /dev/null +++ b/.scripts/deploy-assistify-chat.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash + +function parse_git_hash(){ + git rev-parse --short HEAD 2> /dev/null | sed "s/\(.*\)/\1/" +} + +# Install AWS-CLI - if it's there, this will be done quickly +pip install --user --upgrade awscli +export PATH=$PATH:$HOME/.local/bin # add user-installed aws-cli to path + +# we want this script to work with Travis and CircleCi, so abstract the Environment variables +export BRANCH=${TRAVIS_BRANCH}${CIRCLE_BRANCH} +export COMMIT= $(parse_git_hash) # ${TRAVIS_COMMIT}${CIRCLE_SHA1} will return the long sha which is too long to be readable +export BUILD_FILE=Assistify_Chat_${BRANCH/\//_}_${COMMIT:1}.tar.gz + +export NODEJS_VERSION="8.9.4" +export NODEJS_CHECKSUM="21fb4690e349f82d708ae766def01d7fec1b085ce1f5ab30d9bda8ee126ca8fc" + +# in Circle-Ci, the containers already got a aws-config, so if it exsists, assume it's ok +if [ ! -f ~/.aws/credentials ] + then + mkdir -p ~/.aws + + cat > ~/.aws/credentials << EOL + [default] + aws_access_key_id = ${AWS_ACCESS_KEY} + aws_secret_access_key = ${AWS_SECRET_KEY} + EOL +fi + +# store the build artifact +mv /tmp/build/Rocket.Chat.tar.gz /tmp/build/${BUILD_FILE} +aws s3 cp ${BUILD_FILE} s3://${AWS_BUCKET}/rocketchat/ --region ${AWS_REGION} --acl bucket-owner-full-control + +# For dedicated branches, we tag the artifacts - this should actually be based on git tags +TARGET_ENVIRONMENT=undefined +if [ ${BRANCH} = master ] + then + TARGET_ENVIRONMENT=production + + # publish a new "latest"-file in order to make new clients be created with it + aws s3 cp ${BUILD_FILE} s3://${AWS_BUCKET}/rocketchat/rocket-chat-latest.tar.tgz --region ${AWS_REGION} --acl bucket-owner-full-control + +else + if [[ ${BRANCH} == develop ]] || [[ $BRANCH == "release/"* ]] + then + TARGET_ENVIRONMENT=test + fi +fi + +aws s3api put-object-tagging --region ${AWS_REGION} --bucket ${AWS_BUCKET} --key rocketchat/${BUILD_FILE} --tagging "{ \"TagSet\": [ { \"Key\": \"environment\", \"Value\": \"${TARGET_ENVIRONMENT}\" }, { \"Key\": \"nodejs_version\", \"Value\": \"${NODEJS_VERSION}\" }, { \"Key\": \"nodejs_checksum\", \"Value\": \"${NODEJS_CHECKSUM}\" }, { \"Key\": \"assets\", \"Value\": \"${ASSETS_URL}\" } ] }" diff --git a/.scripts/dockerfile b/.scripts/dockerfile-smarti-with-nlp similarity index 100% rename from .scripts/dockerfile rename to .scripts/dockerfile-smarti-with-nlp diff --git a/.scripts/seperateTesting.sh b/.scripts/seperateTesting.sh index eb8d2fa06412..47e477bb5465 100755 --- a/.scripts/seperateTesting.sh +++ b/.scripts/seperateTesting.sh @@ -2,14 +2,14 @@ tmpPath=tests/end-to-end/temporary_staged_test rm -rf $tmpPath mkdir -p $tmpPath -[ -z "$retry_test" ] && retry_test=1 +[ -z "$RETRY_TESTS" ] && RETRY_TESTS=1 for file in tests/end-to-end/*/*.js; do failed=1 - for i in `seq 1 $retry_test`; do + for i in `seq 1 $RETRY_TESTS`; do echo '-------------- '$i' try ---------------' set -x cp $file $tmpPath - CHIMP_PATH=$tmpPath meteor npm run chimp-path + CHIMP_PATH=$tmpPath npm run chimp-path failed=$? set +x if [ $failed -eq 0 ]; then @@ -20,4 +20,4 @@ for file in tests/end-to-end/*/*.js; do exit 1 fi rm $tmpPath/${file##*/} -done \ No newline at end of file +done diff --git a/.scripts/smarti.sh b/.scripts/smarti.sh index 44836aa2dc15..86e007d569f5 100755 --- a/.scripts/smarti.sh +++ b/.scripts/smarti.sh @@ -2,9 +2,7 @@ docker pull assisitfy/smarti:0.7.0-RC1 -#docker run -d --net=host assisitfy/smarti:0.6.1 - -docker build -t smarti-with-stanfordnlp - < .scripts/dockerfile +docker build -t smarti-with-stanfordnlp - < .scripts/dockerfile-smarti-with-nlp docker run -d --name smarti --net=host smarti-with-stanfordnlp --security.config.mongo.admin-password=admin --spring.data.mongodb.uri=mongodb://localhost/smarti diff --git a/.scripts/start.js b/.scripts/start.js index f42b9c437923..0d0089c4767e 100644 --- a/.scripts/start.js +++ b/.scripts/start.js @@ -67,7 +67,7 @@ function startApp(callback) { function startChimp() { startProcess({ name: 'Chimp', - command: 'retry_test=3 .scripts/seperateTesting.sh', + command: '.scripts/seperateTesting.sh', options: { env: Object.assign({}, process.env, { NODE_PATH: process.env.NODE_PATH + diff --git a/.travis.yml b/.travis.yml index 081317d627db..7748980b43c4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -68,40 +68,43 @@ before_script: - mongo --eval 'rs.status()' - mongo meteor --eval 'db.getCollectionNames()' script: +- shopt -s extglob +- rm -rf ./tests/end-to-end/!(ui_smarti) # remove all non-Smarti-tests - if [[ ! $SKIP_TESTS ]]; then npm test; fi + # - mongo meteor --eval 'db.dropDatabase()' # - unset MONGO_OPLOG_URL # - npm test -before_deploy: -- mkdir -p /tmp/build/rocketchat -- export BUILD_FILE=Assistify_Chat_${TRAVIS_BRANCH/\//_}_${TRAVIS_COMMIT:1}.tar.gz -- mv /tmp/build/Rocket.Chat.tar.gz /tmp/build/rocketchat/${BUILD_FILE} +# before_deploy: +# - mkdir -p /tmp/build/rocketchat +# - export BUILD_FILE=Assistify_Chat_${TRAVIS_BRANCH/\//_}_${TRAVIS_COMMIT:1}.tar.gz +# - mv /tmp/build/Rocket.Chat.tar.gz /tmp/build/rocketchat/${BUILD_FILE} -deploy: -- provider: s3 - access_key_id: $AWS_ACCESS_KEY - secret_access_key: $AWS_SECRET_KEY - local_dir: /tmp/build/ - skip_cleanup: true - on: &1 - repo: assistify/Rocket.Chat - branch: develop - bucket: $AWS_BUCKET - region: $AWS_REGION -- provider: s3 - access_key_id: $AWS_ACCESS_KEY - secret_access_key: $AWS_SECRET_KEY - local_dir: /tmp/build/ - skip_cleanup: true - on: &2 - repo: assistify/Rocket.Chat - branch: master - bucket: $AWS_BUCKET - region: $AWS_REGION +# deploy: +# - provider: s3 +# access_key_id: $AWS_ACCESS_KEY +# secret_access_key: $AWS_SECRET_KEY +# local_dir: /tmp/build/ +# skip_cleanup: true +# on: &1 +# repo: assistify/Rocket.Chat +# branch: develop +# bucket: $AWS_BUCKET +# region: $AWS_REGION +# - provider: s3 +# access_key_id: $AWS_ACCESS_KEY +# secret_access_key: $AWS_SECRET_KEY +# local_dir: /tmp/build/ +# skip_cleanup: true +# on: &2 +# repo: assistify/Rocket.Chat +# branch: master +# bucket: $AWS_BUCKET +# region: $AWS_REGION -after_deploy: -- $TRAVIS_BUILD_DIR/.scripts/check-deploy.sh +# after_deploy: + # - $TRAVIS_BUILD_DIR/.scripts/deploy-assistify-chat.sh env: global: