-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
117 lines (92 loc) · 3.05 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
# -*- coding: utf-8 -*-
# This file is part of thumbor-wand-engine
# https://github.com/scorphus/thumbor-wand-engine
# Licensed under the MIT license:
# http://www.opensource.org/licenses/mit-license
# Copyright (c) 2020-2022, Pablo S. Blum de Aguiar <scorphus@gmail.com>
SHELL=/bin/bash # helps with the glob below
# Ignore tests that do not include the engine in any way
IGNORE_TESTS := --ignore-glob=*test_{autojpg,format,max_age,quality}.py
# Work around inconsistent pseudo-random number generation across platforms
ifeq ($(shell uname), Darwin)
IGNORE_TESTS += --ignore-glob=*test_noise.py
endif
# Another workaround for a test that should be fixed upstream
IGNORE_TESTS += --ignore-glob=*rgb.py
# list all available targets
list:
@sh -c "$(MAKE) -p no_targets__ | awk -F':' '/^[a-zA-Z0-9][^\$$#\/\\t=]*:([^=]|$$)/ {split(\$$1,A,/ /);for(i in A)print A[i]}' | grep -v '__\$$' | grep -v 'make\[1\]' | grep -v 'Makefile' | sort"
.PHONY: list
# required for list
no_targets__:
# install dependencies and pre-commit hooks
setup:
@PIP_REQUIRE_VIRTUALENV=true pip install -U -e .[tests]
@pre-commit install -f --hook-type pre-commit
@pre-commit install -f --hook-type pre-push
@git submodule update --init --recursive
@PIP_REQUIRE_VIRTUALENV=true pip install -U -e thumbor[tests]
.PHONY: setup
# install dependencies
setup-ci:
@pip install -U -e .[tests]
@pip install -U -e thumbor[tests]
.PHONY: setup-ci
# run isort, black and flake8 for style guide enforcement
isort:
@isort .
.PHONY: isort
black:
@black --config ./pyproject.toml .
.PHONY: black
flake8:
@flake8
.PHONY: flake8
lint: isort black flake8
.PHONY: lint
# clean python object, test and coverage files
pyclean:
@find . -type d -iname '__pycache__' -exec rm -rf \{\} + -print
@find . -type d -iname '.benchmarks' -exec rm -rf \{\} + -print
@find . -type d -iname '.mypy_cache' -exec rm -rf \{\} + -print
@find . -type d -iname '.pytest_cache' -exec rm -rf \{\} + -print
@find . -type d -iname '*.egg-info' -exec rm -rf \{\} + -print
@find . -type f -iname '.coverage' -exec rm -rf \{\} + -print
@find . -type f -name "*.pyc" -delete -print
.PHONY: pyclean
compile_ext:
@cd thumbor && $(MAKE) compile_ext
.PHONY: compile_ext
unit:
@pytest -sv --cov=thumbor_wand_engine tests/
.PHONY: unit
acceptance: compile_ext
@cd thumbor; \
env ENGINE=thumbor_wand_engine pytest -sv \
--cov=thumbor_wand_engine --cov-append \
tests/filters/ $(IGNORE_TESTS)
.PHONY: acceptance
coverage-html: unit acceptance
@coverage html
.PHONY: coverage-html
integration: compile_ext
@pytest -sv integration_tests/
.PHONY: integration
test: unit acceptance integration
.PHONY: test
# packaging targets
dist-clean:
@rm -fr build/*
@rm -fr dist/*
dist-build: dist-clean
@python setup.py sdist bdist_wheel
# upload to real index
dist-real-upload: dist-build
@twine upload dist/*
# upload to test index
dist-test-upload: dist-build
@twine upload --repository testpypi dist/*
# run thumbor with wand engine
run: compile_ext
@ENGINE=thumbor_wand_engine thumbor --use-environment true \
-l debug -d -c thumbor/thumbor/thumbor.conf