-
-
Notifications
You must be signed in to change notification settings - Fork 121
/
Copy pathMakefile
139 lines (117 loc) · 4.22 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# we want bash behaviour in all shell invocations
SHELL := bash
# Run each target in a separate shell
.ONESHELL:
# Fail on error inside any functions or subshells
.SHELLFLAGS := -eu -o pipefail -c
# Remove partially created files on error
.DELETE_ON_ERROR:
# Warn when an undefined variable is referenced
MAKEFLAGS += --warn-undefined-variables
# Disable built-in rules
MAKEFLAGS += --no-builtin-rules
# A catalog of requirements files
REQUIREMENTS?=requirements
help: # Show this help
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@echo " help Show this help"
@echo " requirements-base Compile base requirements"
@echo " requirements-test Compile test requirements"
@echo " requirements-dev Compile dev requirements"
@echo " requirements Compile all requirements"
@echo " install Install the app locally"
@echo " install-front Install frontend"
@echo " install-test Install the app locally with test dependencies"
@echo " install-dev Install the app locally with dev dependencies"
@echo " install-test-dev Install the app locally with test and dev dependencies"
@echo " init-test-dev Install the app locally with test and dev dependencies. Also install pre-commit hooks."
@echo " reinit-test-dev Reinstall pre-commit hooks"
@echo " lint Run linters"
@echo " test Run tests"
@echo " migrate Run migrations"
@echo " revision Create a new migration"
@echo " front Run frontend"
@echo " scrape-repos Scrape repos"
@echo " parse-dependencies Scrape dependencies"
@echo " index-repos Index repos"
@echo " index-dependencies Index dependencies"
requirements-base: # Compile base requirements
python -m piptools compile \
--output-file=requirements/base.txt \
-v \
pyproject.toml
requirements-test: requirements-base # Compile test requirements
python -m piptools compile \
--extra=test \
--output-file=requirements/test.txt \
-v \
pyproject.toml
requirements-dev: requirements-base # Compile dev requirements
python -m piptools compile \
--extra=dev \
--output-file=requirements/dev.txt \
-v \
pyproject.toml
requirements: requirements-base requirements-test requirements-dev # Compile all requirements
.PHONY: requirements
install: # Install the app locally
python -m pip install -r $(REQUIREMENTS)/base.txt .
.PHONY: install
install-test: # Install the app locally with test dependencies
python -m pip install \
-r $(REQUIREMENTS)/base.txt \
-r $(REQUIREMENTS)/test.txt \
--editable .
.PHONY: install-test
install-dev: # Install the app locally with dev dependencies
python -m pip install \
-r $(REQUIREMENTS)/base.txt \
-r $(REQUIREMENTS)/dev.txt \
--editable .
.PHONY: install-dev
install-test-dev: # Install the app locally with test and dev dependencies
python -m pip install \
-r $(REQUIREMENTS)/base.txt \
-r $(REQUIREMENTS)/test.txt \
-r $(REQUIREMENTS)/dev.txt \
--editable .
.PHONY: install-test-dev
install-front: # Install frontend
cd frontend && pnpm install
.PHONY: install-front
init-test-dev: install-test-dev # Install the app locally with test and dev dependencies. Also install pre-commit hooks.
pre-commit install
.PHONY: init-test-dev
reinit-test-dev: init-test-dev # Reinstall pre-commit hooks
pre-commit install --install-hooks --overwrite
.PHONY: reinit-test-dev
lint: # Run linters
pre-commit run --all-files
.PHONY: lint
test: # Run tests
python -m pytest -vv -s --cov=app --cov-report=xml --cov-branch app
.PHONY: test
migrate: # Run migrations
python -m alembic upgrade heads
.PHONY: migrate
revision: # Create a new migration
python -m alembic revision --autogenerate -m "$(message)"
.PHONY: revision
front: install-front # Run frontend
cd frontend && pnpm dev
.PHONY: front
scrape-repos: # Scrape repos
python -m app.scrape scrape-repos
.PHONY: scrape-repos
parse-dependencies: # Scrape dependencies
python -m app.scrape parse-dependencies
.PHONY: parse-dependencies
index-repos: # Index repos
python -m app.index index-repos
.PHONY: index-repos
index-dependencies: # Index dependencies
python -m app.index index-dependencies
.PHONY: index-dependencies
.DEFAULT_GOAL := init-test-dev # Set the default goal to init-dev-test