This repository has been archived by the owner on Oct 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Makefile
116 lines (84 loc) · 3.27 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
.PHONY: help logs
help: ## This help
@echo "Makefile for managing application:\n"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
###################
# Local Development
###################
build: ## rebuild containers
docker-compose build
up: ## start local dev environment; run migrations; populate database
docker-compose up -d
make s3-bucket
make migrate-up
make populate-db
down: ## stop local dev environment
docker-compose down
restart: ## restart local dev environment
docker-compose restart $(args)
attach: ## attach to webserver process for debugging purposes
docker attach `docker-compose ps -q app`
attach-worker: ## attach to worker process for debugging purposes
docker attach `docker-compose ps -q worker`
requirements: ## generate requirements.txt using piptools
pip-compile --output-file=requirements.txt requirements.in
install: ## install development requirements
pip install -r requirements_dev.txt
s3-bucket: ## create s3 bucket in localstack
docker-compose exec -T localstack bash /tmp/dev_scripts/create_s3_bucket.sh
###################
# Database Commands
###################
migration: ## create migration m="message"
docker-compose exec app flask db migrate -m "$(m)"
migration-empty: ## create empty migration m="message
docker-compose exec app flask db revision -m "$(m)"
migrate-up: ## run all migration
docker-compose exec app flask db upgrade
migrate-down: ## roll back last migration
docker-compose exec app flask db downgrade
dropdb: ## drop all tables in development database
psql -d postgresql://bbdev_user:bbdev_password@localhost:9432/busy-beaver -f ./scripts/database/drop_all_tables.sql
populate-db: ## populate database
docker-compose exec app python scripts/dev/populate_database.py
#########
# Testing
#########
test: ## run tests
docker-compose exec app pytest $(args)
test-cov: ## run tests with coverage.py
docker-compose exec app pytest --cov ./busy_beaver $(args)
test-covhtml: ## run tests and load html coverage report
docker-compose exec app pytest --cov ./busy_beaver --cov-report html && open ./htmlcov/index.html
test-pdb:
docker-compose exec app pytest --pdb -s
test-skipvcr: ## run non-vcr tests
docker-compose exec app pytest -m 'not vcr'
test-curr: ## run all tests marked as `current`
docker-compose exec app pytest -m 'current'
lint: ## run flake8 linter
docker-compose exec app flake8
logs: ## attach to logs
docker-compose logs
#######
# Shell
#######
shell: ## log into into app container -- bash-shell
docker-compose exec app bash
shell-db: ## log into database container -- psql
docker-compose exec db psql -w --username "bbdev_user" --dbname "busy-beaver"
flaskshell: ## open ipython shell with application context
docker-compose exec app flask shell
flaskcli: ## use flask cli to run commands args='args'te
docker-compose exec app flask $(args)
shell-redis: ## log into redis container -- rediscli
docker-compose exec redis redis-cli
###############
# Miscellaneous
###############
changelog: ## create changelog since release v="version"
python scripts/generate_changelog.py --version $(v)
ngrok: ## start ngrok to forward port
ngrok http 5000
pull-upstream: ## pull from upstream master
git pull upstream master