diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 000000000..dde03d4c9 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,103 @@ +version: 2 + +# Python image to run aws utilities +python_env: &python_env + docker: + - image: circleci/python:2.7-stretch-browsers + +# Instructions of installing aws utilities +install_awscli: &install_awscli + name: "Install awscli" + command: | + sudo pip install awscli awsebcli --upgrade + aws --version + eb --version + +# Instructinos of deployment +deploy_steps: &deploy_steps + - attach_workspace: + at: . + - run: *install_awscli + - setup_remote_docker + - run: ./deploy.sh $DEPLOY_ENV + + +jobs: + build: + machine: true + environment: + CXX: g++-4.8 + steps: + - run: + name: Install g++-4.8 + command: | + sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y + sudo apt-get update -y + sudo apt-get install g++-4.8 -y + - run: + name: Install node-5.12.0 + command: | + curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | sudo bash + source ~/.bashrc + nvm install 5.12.0 + node --version + npm --version + nvm --version + + - checkout + - restore_cache: + key: node-modules-{{ checksum "package-lock.json" }} + - run: npm install + - save_cache: + key: node-modules-{{ checksum "package-lock.json" }} + paths: + - node_modules + - run: ls node_modules/* + - run: npm run lint && npm run build + - run: npm test + - persist_to_workspace: + root: . + paths: + - ./ + + deploy_prod: + <<: *python_env + environment: + DEPLOY_ENV: "PROD" + steps: *deploy_steps + + deploy_dev: + <<: *python_env + environment: + DEPLOY_ENV: "DEV" + steps: *deploy_steps + + deploy_qa: + <<: *python_env + environemtn: + DEPLOY_ENV: "QA" + steps: *deploy_steps + +workflows: + version: 2 + build-and-deploy: + jobs: + - build + - deploy_dev: + filters: + branches: + only: [ dev, dev-circleci2 ] + requires: + - build + - deploy_prod: + filters: + branches: + only: master + requires: + - build + - deploy_qa: + filters: + branches: + only: qa-integration + requires: + - build diff --git a/circle.yml b/circle.yml deleted file mode 100644 index 233a8d388..000000000 --- a/circle.yml +++ /dev/null @@ -1,42 +0,0 @@ -machine: - node: - version: 5.12.0 - environment: - CXX: g++-4.8 - -dependencies: - pre: - - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y - - sudo apt-get update -y - - sudo apt-get install g++-4.8 -y - override: - - node --version - - npm --version - - nvm --version - - npm install - -compile: - override: - - ls node_modules/* - - npm run lint && npm run build - -test: - override: - - npm test - -deployment: - development: - branch: dev - owner: appirio-tech - commands: - - ./deploy.sh DEV - qa: - branch: qa-integration - owner: appirio-tech - commands: - - ./deploy.sh QA - production: - branch: master - owner: appirio-tech - commands: - - ./deploy.sh PROD diff --git a/deploy.sh b/deploy.sh index ddd31b56b..c48b41799 100755 --- a/deploy.sh +++ b/deploy.sh @@ -15,16 +15,16 @@ configure_aws_cli() { } deploy_s3bucket() { - aws s3 sync --dryrun ${HOME}/${CIRCLE_PROJECT_REPONAME}/dist s3://${AWS_S3_BUCKET} --cache-control max-age=0,s-maxage=86400 --exclude "*.txt" --exclude "*.js" --exclude "*.css" - result=`aws s3 sync ${HOME}/${CIRCLE_PROJECT_REPONAME}/dist s3://${AWS_S3_BUCKET} --cache-control max-age=0,s-maxage=86400 --exclude "*.txt" --exclude "*.js" --exclude "*.css"` + aws s3 sync --dryrun ${HOME}/project/dist s3://${AWS_S3_BUCKET} --cache-control max-age=0,s-maxage=86400 --exclude "*.txt" --exclude "*.js" --exclude "*.css" + result=`aws s3 sync ${HOME}/project/dist s3://${AWS_S3_BUCKET} --cache-control max-age=0,s-maxage=86400 --exclude "*.txt" --exclude "*.js" --exclude "*.css"` if [ $? -eq 0 ]; then echo "All html, font, image, map, and media files are Deployed without gzip encoding!" else echo "Deployment Failed - $result" exit 1 fi - aws s3 sync --dryrun ${HOME}/${CIRCLE_PROJECT_REPONAME}/dist s3://${AWS_S3_BUCKET} --cache-control max-age=0,s-maxage=86400 --exclude "*" --include "*.txt" --include "*.js" --include "*.css" --content-encoding gzip - result=`aws s3 sync ${HOME}/${CIRCLE_PROJECT_REPONAME}/dist s3://${AWS_S3_BUCKET} --cache-control max-age=0,s-maxage=86400 --exclude "*" --include "*.txt" --include "*.js" --include "*.css" --content-encoding gzip` + aws s3 sync --dryrun ${HOME}/project/dist s3://${AWS_S3_BUCKET} --cache-control max-age=0,s-maxage=86400 --exclude "*" --include "*.txt" --include "*.js" --include "*.css" --content-encoding gzip + result=`aws s3 sync ${HOME}/project/dist s3://${AWS_S3_BUCKET} --cache-control max-age=0,s-maxage=86400 --exclude "*" --include "*.txt" --include "*.js" --include "*.css" --content-encoding gzip` if [ $? -eq 0 ]; then echo "All txt, css, and js files are Deployed! with gzip" else @@ -34,14 +34,17 @@ deploy_s3bucket() { } -echo -e "application/font-woff\t\t\t\twoff2" >> /etc/mime.types -echo -e "application/font-sfnt\t\t\t\tttf" >> /etc/mime.types -echo -e "application/json\t\t\t\tmap" >> /etc/mime.types +#sudo chmod 666 /etc/mime.types +#echo -e "application/font-woff\t\t\t\twoff2" >> /etc/mime.types +#echo -e "application/font-sfnt\t\t\t\tttf" >> /etc/mime.types +#echo -e "application/json\t\t\t\tmap" >> /etc/mime.types + cat /etc/mime.types | grep -i woff cat /etc/mime.types | grep -i ico cat /etc/mime.types | grep -i map cat /etc/mime.types | grep -i ttf +cat /etc/mime.types | grep -i woff2 configure_aws_cli deploy_s3bucket diff --git a/package.json b/package.json index c55c5051b..8ecb59bc2 100644 --- a/package.json +++ b/package.json @@ -75,6 +75,9 @@ "tc-angular-ellipsis": "0.1.6", "topcoder-app-r": "https://github.com/appirio-tech/topcoder-app-r.git#0.0.1", "xml2js": "0.4.17", - "zepto": "1.0.1" + "zepto": "1.0.1", + "estraverse": "4.1.0", + "bluebird": "2.9.2", + "tapable": "1.0.0" } }