Skip to content

Commit 630d5c3

Browse files
committed
add Makefile
1 parent 33713bc commit 630d5c3

File tree

4 files changed

+74
-1
lines changed

4 files changed

+74
-1
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
ideas.txt
2+
todo.txt
33

44
# Byte-compiled / optimized / DLL files
55
__pycache__/

Makefile

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
2+
# ------------- Run with Uvicorn ------------------------------
3+
4+
.PHONY: run
5+
6+
run: ## run App on uvicorn server
7+
uvicorn app.main:app --host 127.0.0.1 --port 1313 --reload
8+
9+
10+
11+
# ------------- Test/Lint ------------------------------------
12+
13+
.PHONY: pre-commit pre-commit-update lint test
14+
15+
pre-commit:
16+
pre-commit run --all-files
17+
18+
pre-commit-update:
19+
pre-commit autoupdate
20+
21+
lint: ## check style with flake8
22+
flake8 app tests
23+
24+
test: ## run tests quickly with the default Python
25+
pytest -v
26+
27+
28+
29+
# ------------- Clean Test/Lint Artifacts ---------------------
30+
31+
.PHONY: clean clean-pyc clean-test
32+
33+
clean: clean-pyc clean-test ## remove all build, test, coverage and Python artifacts
34+
35+
clean-pyc: ## remove Python file artifacts
36+
find . -name '*.pyc' -exec rm -f {} +
37+
find . -name '*.pyo' -exec rm -f {} +
38+
find . -name '*~' -exec rm -f {} +
39+
find . -name '__pycache__' -exec rm -fr {} +
40+
41+
clean-test: ## remove test and coverage artifacts
42+
rm -fr .mypy_cache
43+
rm -fr .pytest_cache
44+
45+
46+
47+
# ------------ Docker -----------------------------------
48+
49+
.PHONY: docker-build docker-run docker-clean
50+
51+
DOCKER_IMAGE = github-trending-api
52+
53+
docker-build: ## build docker image from Dockerfile
54+
docker build -t $(DOCKER_IMAGE) .
55+
56+
docker-run: ## run API docker container
57+
docker run -p 5000:5000 $(DOCKER_IMAGE)
58+
59+
docker-clean: ## remove docker image
60+
docker rmi -f $(DOCKER_IMAGE)
61+
62+
63+
64+
# ------------ Help --------------------------------------
65+
66+
.PHONY: help
67+
68+
help: ## This help.
69+
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
70+
71+
.DEFAULT_GOAL := help

requirements-dev.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# pre-commit, pytest, flake8, mypy, isort, black
2+
# python 3.9
23

34
appdirs==1.4.4
45
astroid==2.5.2

requirements-prod.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# beautifulsoup4, fastapi, lxml, uvicorn, aiohttp
2+
# python 3.9
23

34
aiohttp==3.7.4
45
beautifulsoup4==4.9.3

0 commit comments

Comments
 (0)