-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
170 lines (139 loc) · 6.64 KB
/
Makefile
File metadata and controls
170 lines (139 loc) · 6.64 KB
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
# MAKEFILE
# //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
# General variables
PYTHON = python3
VENV_DIR = .venv
PYTEST_CMD = python -m pytest -vv -rfEsP --maxfail=1 --tb=long --color=yes --code-highlight=yes
PYTEST_CMD_WITH_THREADING = $(PYTEST_CMD) -n 5
.PHONY: help clean clean-build clean-pyc clean-test test install-lint update-lint lint
help:
@echo "-----------------------------------------------------------------------------------------------------------"
@echo "RUN"
@echo " run run the FastAPI app locally"
@echo "-----------------------------------------------------------------------------------------------------------"
@echo "TEST"
@echo " test run all unit and integration tests"
@echo " test-slow-only run only slow tests"
@echo " test-not-slow-only run only tests that are not slow"
@echo " test-only-integration-tests run only integration tests"
@echo " test-only-unit-tests run only unit tests"
@echo "-----------------------------------------------------------------------------------------------------------"
@echo "LINT"
@echo " install-lint install python linting tools"
@echo " update-lint update python linting tools"
@echo " lint run autopep8, ruff, black and other linting tools on staged files"
@echo " lint-all run autopep8, ruff, black and other linting tools on the entire repo"
@echo "-----------------------------------------------------------------------------------------------------------"
@echo "CLEAN"
@echo " clean clean build, test, coverage, python artifacts and AWS outputs"
@echo " clean-build clean python build artifacts"
@echo " clean-pyc clean python file artifacts"
@echo " clean-lint clean python file artifacts"
@echo " clean-test clean python test and coverage artifacts"
@echo "-----------------------------------------------------------------------------------------------------------"
@echo "DATABASE"
@echo " db-current-rev display the current alembic revision of the database"
@echo " db-upgrade-all upgrade the database with all the available alembic revisions"
@echo " db-downgrade-all downgrade the database with all the available alembic revisions"
@echo " db-migrate msg='example' take all python sqlalchemy models and autogenerates migration files"
@echo " msg description of what is being migrated (will be in file name and docstring)"
@echo " db-upgrade rev='ae1' upgrade the database to a specific revision number"
@echo " rev partial/complete revision id of the alembic file or relative integer"
@echo " db-downgrade rev='ae1' upgrade the database to a specific revision number"
@echo " rev partial/complete revision id of the alembic file or relative integer"
run:
uvicorn main:main_app --reload
test:
pytest
test-only-slow-tests:
pytest -m "slow"
test-only-fast-tests:
pytest -m "not slow"
test-only-integration-tests:
pytest -m "integration"
test-only-unit-tests:
pytest -m "not integration"
# Remove all build, test, coverage and python artifacts.
clean: clean-build clean-pyc clean-lint clean-test
# Set up the git hook scripts
install-lint:
pip install pre-commit
pre-commit install
# Update version numbers of each pre-commit hook
update-lint:
pre-commit autoupdate
# Run pre-commit hooks on staged files
# Note: you can run a specific pre-commit by doing:
# `pre-commit run black`
# Note: if you want to run ruff (isort module) manually:
# `ruff check --select I .`
# See docs/fond-dev-guide/content/lint for more.
lint:
pre-commit run
# Run pre-commit hooks on entire repo
lint-all:
pre-commit run -a
# -------------------------------------------------------------------------------------------------
# Database commands
# -------------------------------------------------------------------------------------------------
db-current-rev:
cd v1 && alembic current
db-history:
cd v1 && alembic history
# Usage example:
# make db-migrate msg="create user table"
db-migrate:
cd v1 && alembic revision --autogenerate -m "$(msg)"
db-upgrade-all:
cd v1 && alembic upgrade head
# Usage example:
# make db-upgrade rev="ae1" (upgrade to specific version)
# make db-upgrade rev="+3" (upgrade relative to current version)
db-upgrade:
cd v1 && alembic upgrade "$(rev)"
db-downgrade-all:
cd v1 && alembic downgrade base
# Usage example:
# make db-downgrade rev="ae1" (downgrade to specific version)
# make db-downgrade rev="-3" (downgrade relative to current version)
db-downgrade:
cd v1 && alembic downgrade "$(rev)"
# -------------------------------------------------------------------------------------------------
# OS specific commands - please uncomment the relevant section depending on your OS
# -------------------------------------------------------------------------------------------------
# Windows
# Remove build artifacts
clean-build:
for /d /r %%p in (.eggs, *.egg-info, *.egg) do @if exist "%%p" rmdir /s /q "%%p"
# Remove lint artifacts
clean-lint:
for /d /r %%p in (.ruff_cache, .mypy_cache) do @if exist "%%p" rmdir /s /q "%%p"
# Remove Python file artifacts
clean-pyc:
for /d /r %%p in (__pycache__) do @if exist "%%p" rmdir /s /q "%%p"
for /d /r %%p in (*.pyc, *.pyo, *~) do @if exist "%%p" del /s /f /q "%%p"
# Remove test and coverage artifacts
clean-test:
for /d /r %%p in (.pytest_cache, htmlcov) do @if exist "%%p" rmdir /s /q "%%p"
for /d /r %%p in (.coverage) do @if exist "%%p" del /s /f /q "%%p"
# -------------------------------------------------------------------------------------------------
# MacOS / Linux
# # Remove build artifacts
# clean-build:
# find . -name '.eggs' -exec rm -fr {} +
# find . -name '*.egg-info' -exec rm -fr {} +
# find . -name '*.egg' -exec rm -f {} +
# # Remove Python file artifacts
# clean-pyc:
# find . -name '*.pyc' -exec rm -f {} +
# find . -name '*.pyo' -exec rm -f {} +
# find . -name '*~' -exec rm -f {} +
# find . -name '__pycache__' -exec rm -fr {} +
# # Remove lint artifacts
# clean-lint:
# find . -name '.ruff_cache' -exec rm -fr {} +
# find . -name '.mypy_cache' -exec rm -fr {} +
# # Remove test and coverage artifacts
# clean-test:
# find . -name '.pytest_cache' -exec rm -fr {} +