From 2fea9d8149c7b65465532966bf8fffbb74c186a2 Mon Sep 17 00:00:00 2001 From: MTLantoine Date: Mon, 18 Jan 2021 18:17:32 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20deploy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .circleci/config.yml | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 31f9b74..8d3e7de 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,8 +2,8 @@ version: 2 jobs: install: docker: - - image: circleci/python:3.9.1 - - image: circleci/postgres:9.6.5 + - image: cimg/python:3.9.1 + - image: circleci/postgres:9.6.2 environment: POSTGRES_DB: example POSTGRES_USER: circleci @@ -13,30 +13,29 @@ jobs: working_directory: ~/repo steps: - checkout + - setup_remote_docker - 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 + - run: + name: install python and dependencies command: pip install -r requirements/dev.txt - # Upgrade dependencies for sqlalchemy and Flask-SQLAlchemy to pass unit tests - run: - command: pip install sqlalchemy --upgrade && pip install Flask-SQLAlchemy --upgrade - - run: - name: Setup dababase + command: pip install sqlalechmy --upgrade && pip install Flask-SQLAlchemy --upgrade + - run: + name: db upgrade environment: FLASK_APP: /home/circleci/repo/autoapp.py - FLASK_DEBUG: 0 + FLASK_DEBUG: 0 command: flask db upgrade - - run: - name: Flask test + - run: + name: flask test environment: FLASK_APP: /home/circleci/repo/autoapp.py FLASK_DEBUG: 0 command: flask test - back-deploy-heroku: + + deploy: docker: - image: buildpack-deps:trusty steps: @@ -47,12 +46,13 @@ jobs: - run: name: Smoke Test command: | - HTTPCODE=`curl -s -o /dev/null -w "%{http_code}" https://$HEROKU_APP_NAME.herokuapp.com/` + HTTPCODE=`curl -s -o /dev/null -w "%{http_code}" https://devops-project-back.herokuapp.com/api/articles` if [[ "$HTTPCODE" -ne 200 ]]; then echo "heroku app not responding, failing deploy" \ exit 1; \ fi - docker-build-and-push: + + build-push: docker: - image: docker:17.05.0-ce-git steps: @@ -70,14 +70,16 @@ jobs: docker tag app $DOCKER_HUB_USER_ID/devops-project-back:latest docker push $DOCKER_HUB_USER_ID/devops-project-back:$CIRCLE_BUILD_NUM docker push $DOCKER_HUB_USER_ID/devops-project-back:latest + +version: 2.1 workflows: version: 2 - build-test: + devopsTP4: jobs: - install - - back-deploy-heroku: + - deploy: requires: - install - - docker-build-and-push: + - build-push: requires: - install \ No newline at end of file