Yield generated for bb9dc909-4d51-4ec2-83d5-ffa2878afb28
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

97 lines
3.0 KiB

version: 2
jobs:
build:
docker:
- image: circleci/python:3.9-buster-node-browsers
steps:
- checkout
- restore_cache:
key: deps-{{ checksum "requirements/dev.txt"}}-{{ .Environment.CACHE_VERSION }}
- run:
name: Installation des dépendances python
command: |
python3 -m venv venv
. venv/bin/activate
pip install -r requirements/dev.txt
- save_cache:
key: deps-{{ checksum "requirements/dev.txt"}}-{{ .Environment.CACHE_VERSION }}
paths:
- "venv"
flask_tests:
docker:
- image: circleci/python:3.9-buster-node-browsers
environment:
DATABASE_URL: postgresql://gianni:gianni@localhost:5432/postgres
CONDUIT_SECRET: 'something-really-secret'
FLASK_APP: autoapp.py
FLASK_DEBUG: 1
- image: circleci/postgres:9.6.9-alpine
environment:
POSTGRES_USER: gianni
POSTGRES_PASSWORD: gianni
POSTGRES_BD: postgres
steps:
- checkout
- restore_cache:
key: deps-{{ checksum "requirements/dev.txt"}}-{{ .Environment.CACHE_VERSION }}
- run:
name: Attente de postgres
command: dockerize -wait tcp://localhost:5432 -timeout 1m
- run:
name: Tests Flask
command: |
. venv/bin/activate
flask db stamp head
flask db migrate
flask db upgrade
flask test
deploy-heroku:
docker:
- image: buildpack-deps:trusty
steps:
- checkout
- run:
name: Déploiement heroku
command: |
git config --global push.default matching
git push https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git main
- run:
name: Smoke test
command: |
HTTPCODE=`curl -s -o /dev/null -w "%{http_code}" https://$HEROKU_APP_NAME.herokuapp.com/api/articles`
if [ "$HTTPCODE" -ne 200 ];then
echo "heroku app not responding, failing deploy"
exit 1
fi
docker-build-push:
working_directory: /dockerapp
docker:
- image: docker:17.05.0-ce-git
steps:
- checkout
- setup_remote_docker
- run:
name: dockerize the app
command: |
docker build --cache-from=app -t app .
- run:
name: Publication sur dockerhub
command: |
docker login -u $DOCKER_HUB_USERNAME -p $DOCKER_HUB_PASSWORD
docker tag app $DOCKER_HUB_USERNAME/tp-devops-final-api:$CIRCLE_BUILD_NUM
docker tag app $DOCKER_HUB_USERNAME/tp-devops-final-api:latest
docker push $DOCKER_HUB_USERNAME/tp-devops-final-api:$CIRCLE_BUILD_NUM
docker push $DOCKER_HUB_USERNAME/tp-devops-final-api:latest
workflows:
version: 2
tp:
jobs:
- build
- flask_tests:
requires:
- build
- deploy-heroku:
context: Heroku
requires:
- build