Skip to content

Instantly share code, notes, and snippets.

@hprobotic
Created November 26, 2018 08:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hprobotic/622b873c5d78133e766503b5e2f474ea to your computer and use it in GitHub Desktop.
Save hprobotic/622b873c5d78133e766503b5e2f474ea to your computer and use it in GitHub Desktop.
Bug fix with flask, mysql and tox
  • Fix mysqlclient:
  • Check brew info openssl
version: 2
jobs:
build_and_test_docker_compose:
docker:
- image: circleci/cci-demo-docker-primary:0.0.2
working_directory: ~/reap
environment:
TEST_RESULTS: /tmp/test-results
steps:
- checkout
- run: mkdir -p $TEST_RESULTS
- setup_remote_docker
- run:
name: Install Docker client
command: |
set -x
VER="17.03.0-ce"
curl -L -o /tmp/docker-$VER.tgz https://get.docker.com/builds/Linux/x86_64/docker-$VER.tgz
tar -xz -C /tmp -f /tmp/docker-$VER.tgz
mv /tmp/docker/* /usr/bin
- run:
name: Install Docker Compose
command: |
set -x
curl -L https://github.com/docker/compose/releases/download/1.11.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
- run:
name: Build service
command: make
- run:
name: Start container and run tests
command: |
set -x
docker-compose -f docker-compose.test.yml up --abort-on-container-exit
deploy_frontend_production:
docker:
- image: circleci/node:8.10.0
steps:
- checkout
- run:
name: Install AWS Cli
command: |
sudo apt-get install python-dev python-pip
sudo pip install awscli
- run:
name: Deploy production build to AWS
command: |
set -x
cd frontend && yarn && yarn deploy:prod
deploy_backend_production:
docker:
- image: circleci/node:8.10.0
steps:
- checkout
- run:
name: Installing deployment dependencies
working_directory: /
command: |
sudo apt-get -y -qq update
sudo apt-get install python-pip python-dev build-essential
sudo pip install awsebcli --upgrade
- run:
name: Deploy backend production build to ElasticBeanstalk
command: |
set -x
cd backend && eb deploy production
deploy_frontend_staging:
docker:
- image: circleci/node:8.10.0
steps:
- checkout
- run:
name: Install AWS Cli
command: |
sudo apt-get install python-dev python-pip
sudo pip install awscli
- run:
name: Deploy frontend staging build to AWS
command: |
set -x
cd frontend && yarn && yarn deploy:staging
deploy_backend_staging:
docker:
- image: circleci/node:8.10.0
steps:
- checkout
- run:
name: Installing deployment dependencies
working_directory: /
command: |
sudo apt-get -y -qq update
sudo apt-get install python-pip python-dev build-essential
sudo pip install awsebcli --upgrade
- run:
name: Deploy backend staging build to ElasticBeanstalk
command: |
set -x
cd backend && eb deploy staging
test_frontend:
docker:
- image: circleci/node:8.10.0
steps:
- checkout
- run:
name: Run tests frontend
command: |
set -x
cd frontend && yarn && yarn test
test_backend:
docker:
- image: circleci/python:3.6.4
environment:
PIPENV_VENV_IN_PROJECT: true
- image: circleci/mysql:5.6
environment:
MYSQL_DATABASE: circle_test
steps:
- checkout
- run: sudo chown -R circleci:circleci /usr/local/bin
- run: sudo chown -R circleci:circleci /usr/local/lib/python3.6/site-packages
- restore_cache: # ensure this step occurs *before* installing dependencies
key: deps9-{{ .Branch }}-{{ checksum "backend/Pipfile.lock" }}
- run:
command: |
sudo pip install pipenv
pipenv install
- save_cache:
key: deps9-{{ .Branch }}-{{ checksum "backend/Pipfile.lock" }}
paths:
- ".venv"
- "/usr/local/bin"
- "/usr/local/lib/python3.6/site-packages"
- run:
name: Installing testing dependencies
command: |
sudo apt-get -y -qq update
sudo apt install -y mysql-client
pip install --upgrade tox
- run:
name: Wait for MySQL to be ready
command: dockerize -wait tcp://127.0.0.1:3306 -timeout 120s
- run:
name: Create user 'circleci' in MySQL
command: mysql --host 127.0.0.1 --user root -e "CREATE USER 'circleci'@'127.0.0.1'; GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX ON *.* TO 'circleci'@'127.0.0.1'; FLUSH PRIVILEGES;"
- run:
name: Run tests backend
command: |
set -x
cd backend && tox
- store_test_results:
path: test-results
- store_artifacts:
path: test-results
destination: tr1
workflows:
version: 2
buid_test_and_deploy:
jobs:
- build_and_test_docker_compose
- test_frontend
- test_backend
- deploy_frontend_staging:
filters:
branches:
only:
- develop
requires:
- build_and_test_docker_compose
- test_frontend
- deploy_backend_staging:
filters:
branches:
only:
- develop
requires:
- build_and_test_docker_compose
- test_frontend
- deploy_frontend_production:
filters:
branches:
only:
- deploy
requires:
- build_and_test_docker_compose
- test_frontend
- deploy_backend_production:
filters:
branches:
only:
- deploy
requires:
- build_and_test_docker_compose
- test_frontend
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment