forked from alerta/alerta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
139 lines (106 loc) · 2.88 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
#!make
VENV=venv
PYTHON=$(VENV)/bin/python3
PIP=$(VENV)/bin/pip --disable-pip-version-check
FLAKE8=$(VENV)/bin/flake8
MYPY=$(VENV)/bin/mypy
TOX=$(VENV)/bin/tox
PYTEST=$(VENV)/bin/pytest
DOCKER_COMPOSE=docker-compose
PRE_COMMIT=$(VENV)/bin/pre-commit
BUILD=$(VENV)/bin/build
WHEEL=$(VENV)/bin/wheel
TWINE=$(VENV)/bin/twine
GIT=git
.DEFAULT_GOAL:=help
-include .env .env.local .env.*.local
ifndef PROJECT
$(error PROJECT is not set)
endif
PYPI_REPOSITORY ?= pypi
VERSION=$(shell cut -d "'" -f 2 $(PROJECT)/version.py)
all: help
$(VENV):
python3 -m venv $(VENV)
$(FLAKE8): $(VENV)
$(PIP) install flake8
$(MYPY): $(VENV)
$(PIP) install mypy
$(TOX): $(VENV)
$(PIP) install tox
$(PYTEST): $(VENV)
$(PIP) install pytest pytest-cov
$(PRE_COMMIT): $(VENV)
$(PIP) install pre-commit
$(PRE_COMMIT) install
$(BUILD): $(VENV)
$(PIP) install --upgrade build
$(WHEEL): $(VENV)
$(PIP) install --upgrade wheel
$(TWINE): $(VENV)
$(PIP) install --upgrade wheel twine
ifdef TOXENV
toxparams?=-e $(TOXENV)
endif
## install - Install dependencies.
install: $(VENV)
$(PIP) install -r requirements.txt
## hooks - Run pre-commit hooks.
hooks: $(PRE_COMMIT)
$(PRE_COMMIT) run --all-files --show-diff-on-failure
## lint - Lint and type checking.
lint: $(FLAKE8) $(MYPY)
$(FLAKE8) $(PROJECT)/
$(MYPY) $(PROJECT)/
## test - Run all tests.
test: test.unit test.integration
## test.unit - Run unit tests.
test.unit: $(TOX) $(PYTEST)
$(TOX) $(toxparams)
## test.integration - Run integration tests.
test.integration: test.integration.ldap test.integration.saml
test.integration.ldap: $(PYTEST)
$(PIP) install -r requirements-ci.txt
$(DOCKER_COMPOSE) -f docker-compose.ci.yml up -d
$(PYTEST) tests/integration/test_auth_ldap.py $(toxparams)
test.integration.saml: $(PYTEST)
$(PIP) install -r requirements-ci.txt
$(DOCKER_COMPOSE) -f docker-compose.ci.yml up -d
$(PYTEST) tests/integration/test_auth_saml.py $(toxparams)
## test.forwarder - Run forwarder tests.
test.forwarder:
$(DOCKER_COMPOSE) -f tests/integration/fixtures/docker-compose.yml pull
$(DOCKER_COMPOSE) -f tests/integration/fixtures/docker-compose.yml up
## run - Run application.
run:
alertad
## tag - Git tag with current version.
tag:
$(GIT) tag -a v$(VERSION) -m "version $(VERSION)"
$(GIT) push --tags
## build - Build package.
build: $(BUILD)
$(PYTHON) -m build
## upload - Upload package to PyPI.
upload: $(TWINE)
$(TWINE) check dist/*
$(TWINE) upload --repository $(PYPI_REPOSITORY) --verbose dist/*
## clean - Clean source.
clean:
rm -rf $(VENV)
rm -rf .tox
rm -rf dist
rm -rf build
find . -name "*.pyc" -exec rm {} \;
## help - Show this help.
help: Makefile
@echo ''
@echo 'Usage:'
@echo ' make [TARGET]'
@echo ''
@echo 'Targets:'
@sed -n 's/^##//p' $<
@echo ''
@echo 'Add project-specific env variables to .env file:'
@echo 'PROJECT=$(PROJECT)'
.PHONY: help lint test build sdist wheel clean all