version: 2 jobs: install: docker: - image: circleci/python:3.9.1 - image: circleci/postgres:9.6.5 environment: POSTGRES_DB: example POSTGRES_USER: circleci POSTGRES_PASSWORD: somePwd POSTGRES_PORT: 5432 DATABASE_URL: postgresql://circleci:somePwd@localhost:5432/example working_directory: ~/repo steps: - checkout - restore_cache: keys: - dependencies-{{ checksum "requirements/dev.txt" }}-{{ checksum "requirements/prod.txt" }} # fallback to using the latest cache if no exact match is found - dependencies- - run: name: Install dependencies command: | python3 -m venv venv . venv/bin/activate pip install -r requirements/dev.txt - run: name: Setup dababase environment: FLASK_APP: /home/circleci/repo/autoapp.py FLASK_DEBUG: 0 command: | . venv/bin/activate flask db upgrade # - run: # name: Flask test # environment: # FLASK_APP: /home/circleci/repo/autoapp.py # FLASK_DEBUG: 0 # command: | # . venv/bin/activate # flask test back-deploy-heroku: docker: - image: buildpack-deps:trusty steps: - checkout - run: name: Heroku Deploy command: git push https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git HEAD:main - run: name: Smoke Test command: | HTTPCODE=`curl -s -o /dev/null -w "%{http_code}" https://$HEROKU_APP_NAME.herokuapp.com/` if [[ "$HTTPCODE" -ne 200 ]]; then echo "heroku app not responding, failing deploy" \ exit 1; \ fi workflows: version: 2 build-test: jobs: - install - back-deploy-heroku: requires: - install