|
|
|
@ -4,46 +4,118 @@ |
|
|
|
# |
|
|
|
version: 2 |
|
|
|
jobs: |
|
|
|
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.8.5 |
|
|
|
auth: |
|
|
|
username: $DOCKER_HUB_USER_ID |
|
|
|
password: $DOCKER_HUB_PWD # 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: $DOCKER_HUB_USER_ID |
|
|
|
password: $DOCKER_HUB_PWD # 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 |
|
|
|
build: |
|
|
|
docker: |
|
|
|
# specify the version you desire here |
|
|
|
# use `-browsers` prefix for selenium tests, e.g. `3.6.1-browsers` |
|
|
|
- image: circleci/python:3.6.4 |
|
|
|
|
|
|
|
# Specify service dependencies here if necessary |
|
|
|
# CircleCI maintains a library of pre-built images |
|
|
|
# documented at https://circleci.com/docs/2.0/circleci-images/ |
|
|
|
# - image: circleci/postgres:9.4 |
|
|
|
|
|
|
|
working_directory: ~/repo |
|
|
|
|
|
|
|
steps: |
|
|
|
- checkout |
|
|
|
|
|
|
|
# Download and cache dependencies |
|
|
|
- restore_cache: |
|
|
|
key: deps-{{ .Branch }}-{{ checksum "requirements/dev.txt" }} |
|
|
|
keys: |
|
|
|
- v3-dependencies-{{ checksum "requirements/dev.txt" }}-{{ checksum "requirements/prod.txt" }} |
|
|
|
- v3-dependencies- |
|
|
|
# fallback to using the latest cache if no exact match is found |
|
|
|
|
|
|
|
- run: |
|
|
|
name: install dependencies |
|
|
|
command: | |
|
|
|
export FLASK_APP=autoapp.py |
|
|
|
pip install -r requirements/dev.txt --user |
|
|
|
flask db upgrade |
|
|
|
python3 -m venv venv |
|
|
|
. venv/bin/activate |
|
|
|
pip install -r requirements/dev.txt |
|
|
|
environment: |
|
|
|
CONDUIT_SECRET: 'something-really-secret' |
|
|
|
FLASK_APP: /home/circleci/repo/autoapp.py |
|
|
|
FLASK_DEBUG: 1 |
|
|
|
|
|
|
|
- save_cache: |
|
|
|
paths: |
|
|
|
- venv |
|
|
|
key: v3-dependencies-{{ checksum "requirements/dev.txt" }}-{{ checksum "requirements/prod.txt" }} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test: |
|
|
|
docker: |
|
|
|
# specify the version you desire here |
|
|
|
# use `-browsers` prefix for selenium tests, e.g. `3.6.1-browsers` |
|
|
|
- image: circleci/python:3.6.4 |
|
|
|
# Specify service dependencies here if necessary |
|
|
|
# CircleCI maintains a library of pre-built images |
|
|
|
# documented at https://circleci.com/docs/2.0/circleci-images/ |
|
|
|
- image: postgres:9.6.2-alpine |
|
|
|
environment: |
|
|
|
POSTGRES_USER: myUsr |
|
|
|
POSTGRES_PASSOWRD: somePwd |
|
|
|
POSTGRES_DB: myUsr |
|
|
|
|
|
|
|
working_directory: ~/repo |
|
|
|
|
|
|
|
steps: |
|
|
|
- checkout |
|
|
|
|
|
|
|
# Download and cache dependencies |
|
|
|
- restore_cache: |
|
|
|
keys: |
|
|
|
- v3-dependencies-{{ checksum "requirements/dev.txt" }}-{{ checksum "requirements/prod.txt" }} |
|
|
|
- v3-dependencies- |
|
|
|
# fallback to using the latest cache if no exact match is found |
|
|
|
|
|
|
|
- run: |
|
|
|
name: bd upgrade |
|
|
|
command: | |
|
|
|
. venv/bin/activate |
|
|
|
sleep 1 |
|
|
|
flask db upgrade |
|
|
|
environment: |
|
|
|
CONDUIT_SECRET: 'something-really-secret' |
|
|
|
FLASK_APP: /home/circleci/repo/autoapp.py |
|
|
|
DATABASE_URL: postgresql://myUsr:somePwd@localhost:5432/myUsr |
|
|
|
FLASK_DEBUG: 1 |
|
|
|
POSTGRES_USER: postgres |
|
|
|
POSTGRES_DB: bdtest |
|
|
|
POSTGRES_PASSWORD: somePwd |
|
|
|
POSTGRES_PORT: 5432 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# run tests! |
|
|
|
# this example uses Django's built-in test-runner |
|
|
|
# other common Python testing frameworks include pytest and nose |
|
|
|
# https://pytest.org |
|
|
|
# https://nose.readthedocs.io |
|
|
|
- run: |
|
|
|
name: run tests |
|
|
|
command: | |
|
|
|
. venv/bin/activate |
|
|
|
flask db migrate |
|
|
|
flask test |
|
|
|
environment: |
|
|
|
CONDUIT_SECRET: 'something-really-secret' |
|
|
|
FLASK_DEBUG: 0 |
|
|
|
FLASK_APP: /home/circleci/repo/autoapp.py |
|
|
|
DATABASE_URL: postgresql://myUsr:somePwd@localhost:5432/myUsr |
|
|
|
FLASK_DEBUG: 1 |
|
|
|
POSTGRES_USER: postgres |
|
|
|
POSTGRES_DB: bdtest |
|
|
|
POSTGRES_PASSWORD: somePwd |
|
|
|
POSTGRES_PORT: 5432 |
|
|
|
|
|
|
|
- save_cache: |
|
|
|
key: deps-{{ .Branch }}-{{ checksum "requirements/dev.txt" }} |
|
|
|
paths: |
|
|
|
- "venv" |
|
|
|
- venv |
|
|
|
key: v3-dependencies-{{ checksum "requirements/dev.txt" }}-{{ checksum "requirements/prod.txt" }} |
|
|
|
|
|
|
|
back-deploy-heroku: |
|
|
|
docker: |
|
|
|
- image: buildpack-deps:trusty |
|
|
|
@ -79,6 +151,9 @@ workflows: |
|
|
|
build-back-deploy: |
|
|
|
jobs: |
|
|
|
- build |
|
|
|
- test: |
|
|
|
requires: |
|
|
|
- build |
|
|
|
- back-deploy-heroku: |
|
|
|
requires: |
|
|
|
- build |
|
|
|
|