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.
129 lines
4.6 KiB
129 lines
4.6 KiB
version: 2 # use CircleCI 2.0
|
|
jobs: # A basic unit of work in a run
|
|
build: # runs not using Workflows must have a `build` job as entry point
|
|
# directory where steps are run
|
|
# working_directory: ~/circleci-demo-python-django
|
|
docker: # run the steps with Docker
|
|
# CircleCI Python images available at: https://hub.docker.com/r/circleci/python/
|
|
- image: circleci/python:3.9.1
|
|
auth:
|
|
username: $DOCKERHUB_USERNAME
|
|
password: $DOCKERHUB_PASSWORD # context / project UI env-var reference
|
|
environment: # environment variables for primary container
|
|
PIPENV_VENV_IN_PROJECT: true
|
|
DATABASE_URL: postgresql://root@localhost/circle_test?sslmode=disable
|
|
# CircleCI PostgreSQL images available at: https://hub.docker.com/r/circleci/postgres/
|
|
- image: circleci/postgres:9.6.9-alpine
|
|
auth:
|
|
username: $DOCKERHUB_USERNAME
|
|
password: $DOCKERHUB_PASSWORD # context / project UI env-var reference
|
|
environment: # environment variables for the Postgres container.
|
|
POSTGRES_USER: root
|
|
POSTGRES_DB: circle_test
|
|
steps: # steps that comprise the `build` job
|
|
- checkout # check out source code to working directory
|
|
# - run: sudo chown -R circleci:circleci /usr/local/bin
|
|
# - run: sudo chown -R circleci:circleci /usr/local/lib/python3.8/site-packages
|
|
- restore_cache:
|
|
# Read about caching dependencies: https://circleci.com/docs/2.0/caching/
|
|
key: deps9-{{ .Branch }}-{{ checksum "Pipfile.lock" }}
|
|
- run:
|
|
command: |
|
|
export FLASK_APP=autoapp.py
|
|
sudo pip install pipenv
|
|
pipenv install
|
|
- save_cache: # cache Python dependencies using checksum of Pipfile as the cache-key
|
|
key: deps9-{{ .Branch }}-{{ checksum "Pipfile.lock" }}
|
|
paths:
|
|
- "venv"
|
|
- run:
|
|
command: |
|
|
pipenv run python autoapp.py test
|
|
- store_test_results: # Upload test results for display in Test Summary: https://circleci.com/docs/2.0/collect-test-data/
|
|
path: test-results
|
|
- store_artifacts: # Upload test summary for display in Artifacts: https://circleci.com/docs/2.0/artifacts/
|
|
path: test-results
|
|
destination: tr1
|
|
|
|
test:
|
|
docker:
|
|
- image: circleci/python:3.9.1
|
|
- image: circleci/postgres:9.6.5
|
|
environment:
|
|
POSTGRES_USER: myUsr
|
|
POSTGRES_PASSOWRD: somePwd
|
|
POSTGRES_DB: myUsr
|
|
|
|
steps:
|
|
- checkout
|
|
- restore_cache:
|
|
key: deps9-{{ .Branch }}-{{ checksum "Pipfile.lock" }}
|
|
- run:
|
|
name: bd upgrade
|
|
command: |
|
|
pip install --user Flask
|
|
flask db init
|
|
flask db migrate
|
|
flask db upgrade
|
|
flask test
|
|
environment:
|
|
CONDUIT_SECRET: $CONDUIT_SECRET
|
|
FLASK_APP: autoapp.py
|
|
FLASK_DEBUG: 1
|
|
DATABASE_URL: postgresql://myUsr:somePwd@localhost:5432/myUsr
|
|
- run:
|
|
name: flask test
|
|
command: |
|
|
. venv/bin/activate
|
|
sleep 1
|
|
flask test
|
|
environment:
|
|
CONDUIT_SECRET: 'something-really-secret'
|
|
FLASK_APP: autoapp.py
|
|
FLASK_DEBUG: 1
|
|
DATABASE_URL: postgresql://myUsr:somePwd@localhost:5432/myUsr
|
|
|
|
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 main
|
|
|
|
docker_build_push:
|
|
working_directory: /dockerapp
|
|
docker:
|
|
- image: docker:17.05.0-ce-git
|
|
steps:
|
|
- checkout
|
|
- setup_remote_docker
|
|
- run:
|
|
name: Build application Docker image
|
|
command: |
|
|
docker build --cache-from=app -t app .
|
|
- deploy:
|
|
name: Publish application to docker hub
|
|
command: |
|
|
docker login -e $DOCKER_HUB_EMAIL -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD
|
|
docker tag app $DOCKERHUB_USERNAME/my-awesome-ci-expr:$CIRCLE_BUILD_NUM
|
|
docker tag app $DOCKERHUB_USERNAME/my-awesome-ci-expr:latest
|
|
docker push $DOCKERHUB_USERNAME/my-awesome-ci-expr:$CIRCLE_BUILD_NUM
|
|
docker push $DOCKERHUB_USERNAME/my-awesome-ci-expr:latest
|
|
|
|
workflows:
|
|
version: 2
|
|
build-test:
|
|
jobs:
|
|
- build
|
|
# - test:
|
|
# requires:
|
|
# - build
|
|
- heroku:
|
|
requires:
|
|
- build
|
|
- docker_build_push:
|
|
requires:
|
|
- build
|