Skip to content

Instantly share code, notes, and snippets.

@lays147
Created March 16, 2021 18:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lays147/aca7fe194676523e42bb7ee875e60816 to your computer and use it in GitHub Desktop.
Save lays147/aca7fe194676523e42bb7ee875e60816 to your computer and use it in GitHub Desktop.
Make your dev life easier with Make
version: "3"
services:
postgres:
image: postgis/postgis
volumes:
- ./volumes/data-postgresql:/var/lib/postgresql/data
env_file: .env
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5
postgres-gui:
image: dpage/pgadmin4:latest
ports:
- 8082:80
env_file: .env
volumes:
- ./volumes/data-pgadmin:/root/.pgadmin
links:
- postgres
api:
image: partner-api:latest
ports:
- "${PORT}:${PORT}"
depends_on:
- postgres
env_file: .env
environment:
- POSTGRES_HOST=postgres
command: --port ${PORT}
SHELL := /bin/bash
create_env:
( \
python3 -m venv .venv; \
source .venv/bin/activate; \
pip3 install -r requirements.txt; \
pip install -r dev-requirements.txt; \
)
build:
docker build --tag=partner-api:latest --file=Dockerfile .
install:
pip install -r requirements.txt
install-dev:
pip install -r dev-requirements.txt
start:
uvicorn partner_api.main:app --reload
db:
docker run --name pg --env-file .env -p 5432:5432 -d postgis/postgis
echo wait 20 seconds to guarantee that db is ready
sleep 20
delete_db:
docker stop pg
docker rm pg
run: build
docker-compose up
stop:
docker-compose stop
test:
tox -e test
compliance:
tox -e compliance
format:
tox -e format
diff:
tox -e diff
[tox]
envlist = py38
skipsdist = true
[testenv]
description= Test environment
[testenv:test]
deps =
-rrequirements.txt
-rdev-requirements.txt
commands =
make db
pytest --cov-report term-missing --cov=partner_api --ignore volumes
commands_post =
make delete_db
whitelist_externals =
make
[testenv:compliance]
description= Run compliance tests
deps =
flake8
flake8-bandit
flake8-bugbear
flake8-builtins
flake8-comprehensions
flake8-string-format
black
pydocstyle
commands =
flake8
black --check .
pydocstyle
[testenv:diff]
description= Run test only for changed files
deps =
-rrequirements.txt
-rdev-requirements
commands = pytest --picked
[testenv:format]
description= Format the project with black
deps = black
commands = black partner_api/ tests/
[flake8]
exclude =
.venv,
.git,
.tox,
dist,
doc,
*lib/python*,
*egg,
build,
max-complexity = 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment