Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
123 lines (101 loc) · 3.97 KB
/
Copy pathMakefile
File metadata and controls
123 lines (101 loc) · 3.97 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
.PHONY: all install nopyc clean test test-integration test-integration-sites download-integration-output generate-region-data docs check local validate-release bump-version upload install-waf install-browser
SHELL := /usr/bin/env bash
PYTHON_BIN ?= python
PROJECT_VENV ?= venv
INTEGRATION_TEST_RERUN ?= 2
INTEGRATION_TEST_RERUN_DELAY ?= 300
INTEGRATION_TEST_FAIL_FAST ?= false
PYTEST_EXTRA_ARGS ?=
INTEGRATION_OUTPUT_DIR ?= build/integration-test-output
INTEGRATION_RUN_ID ?= $(shell gh run list --workflow integration.yml --limit 1 --json databaseId --jq '.[0].databaseId')
SSH_KEY ?= ~/.ssh/id_rsa
WAF_EXTRAS := capsolver,anticaptcha,2captcha
all: local check test
venv:
$(PYTHON_BIN) -m pip install virtualenv --user
$(PYTHON_BIN) -m virtualenv $(PROJECT_VENV)
install: venv
@( \
source $(PROJECT_VENV)/bin/activate; \
python -m pip install .; \
)
install-waf:
@( \
source $(PROJECT_VENV)/bin/activate; \
python -m pip install ".[$(WAF_EXTRAS)]"; \
)
install-browser:
@( \
source $(PROJECT_VENV)/bin/activate; \
python -m pip install ".[browser]"; \
playwright install chromium --with-deps; \
)
nopyc:
find . -name '*.pyc' | xargs rm -f || true
find . -name __pycache__ | xargs rm -rf || true
clean: nopyc
rm -rf build dist *.egg-info $(PROJECT_VENV) tests/.*config
test: install
@( \
source $(PROJECT_VENV)/bin/activate; \
python -m pip install ".[dev]"; \
coverage run -m pytest -v --ignore=tests/integration -o junit_suite_name=unit && coverage report && coverage xml && coverage html; \
)
test-integration: install
@( \
source $(PROJECT_VENV)/bin/activate; \
python -m pip install ".[dev,integration]"; \
pytest -v --ignore=tests/unit --ignore=tests/integration/test_integration_sites.py -o junit_suite_name=integration --reruns ${INTEGRATION_TEST_RERUN} --reruns-delay ${INTEGRATION_TEST_RERUN_DELAY} $(if $(filter true,${INTEGRATION_TEST_FAIL_FAST}),-x) ${PYTEST_EXTRA_ARGS}; \
)
test-integration-sites: install
@( \
source $(PROJECT_VENV)/bin/activate; \
python -m pip install ".[dev,integration]"; \
pytest -v -rs tests/integration/test_integration_sites.py -o junit_suite_name=integration-sites ${PYTEST_EXTRA_ARGS}; \
)
download-integration-output:
@( \
rm -rf $(INTEGRATION_OUTPUT_DIR) && \
gh run download $(INTEGRATION_RUN_ID) -n integration-test-output -D $(INTEGRATION_OUTPUT_DIR) && \
age -d -i $(SSH_KEY) $(INTEGRATION_OUTPUT_DIR)/integration-test-output.tar.gz.age | tar xzf - -C $(INTEGRATION_OUTPUT_DIR) && \
rm $(INTEGRATION_OUTPUT_DIR)/integration-test-output.tar.gz.age && \
echo "Integration test output from run $(INTEGRATION_RUN_ID) is in $(INTEGRATION_OUTPUT_DIR)"; \
)
generate-region-data: install
@( \
source $(PROJECT_VENV)/bin/activate; \
python scripts/generate-region-data.py; \
)
docs: install
@( \
source $(PROJECT_VENV)/bin/activate; \
python -m pip install ".[docs]"; \
sphinx-build -M html docs build/docs -n -E; \
)
check: install
@( \
source $(PROJECT_VENV)/bin/activate; \
python -m pip install ".[dev,docs]"; \
mypy amazonorders && flake8; \
)
local:
@rm -rf *.egg-info dist
@( \
$(PYTHON_BIN) -m pip install --upgrade pip && \
$(PYTHON_BIN) -m pip install --upgrade build && \
$(PYTHON_BIN) -m build && \
$(PYTHON_BIN) -m pip install "$$(ls dist/*.tar.gz)"; \
)
validate-release:
@if [[ "${VERSION}" == "" ]]; then echo "VERSION is not set" & exit 1 ; fi
@if [[ $$(grep "__version__ = \"${VERSION}\"" amazonorders/__init__.py) == "" ]] ; then echo "Version not bumped in amazonorders/__init__.py" & exit 1 ; fi
@if [[ $$(grep -F "==$$(echo "${VERSION}" | cut -d. -f1-2).*" README.md) == "" ]] ; then echo "README.md wildcard pin not bumped" & exit 1 ; fi
bump-version:
@if [[ "${VERSION}" == "" ]]; then echo "VERSION is not set" & exit 1 ; fi
@bash .github/scripts/bump-wildcard-pins.sh "${VERSION}" docs/index.rst README.md SECURITY.md
upload: local
@( \
$(PYTHON_BIN) -m pip install --upgrade twine && \
$(PYTHON_BIN) -m build && \
$(PYTHON_BIN) -m twine upload dist/*; \
)