-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathMakefile
More file actions
73 lines (62 loc) · 2.47 KB
/
Copy pathMakefile
File metadata and controls
73 lines (62 loc) · 2.47 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
PACKAGE_NAME := unstructured-python-client
CURRENT_DIR := $(shell pwd)
ARCH := $(shell uname -m)
DOCKER_IMAGE ?= downloads.unstructured.io/unstructured-io/unstructured-api:latest
INTEGRATION_IGNORE_ARGS := --ignore=_test_unstructured_client/integration/test_platform_workflow_lifecycle.py
INTEGRATION_PYTEST_ARGS := _test_unstructured_client -vv -k integration $(INTEGRATION_IGNORE_ARGS) -o log_cli=true -o log_cli_level=INFO -o log_cli_format="%(asctime)s %(levelname)s %(message)s" --capture=tee-sys --durations=20 --tb=long
PLATFORM_INTEGRATION_PYTEST_ARGS := _test_unstructured_client/integration/test_platform_workflow_lifecycle.py -v -o log_cli=true -o log_cli_level=INFO --durations=20 --tb=long
###########
# Install #
###########
## install: installs all test, dev, and experimental requirements
.PHONY: install
install:
python scripts/prepare_readme.py
uv sync --locked
#################
# Test and Lint #
#################
.PHONY: test
test: test-unit test-integration-docker
.PHONY: test-unit
test-unit:
PYTHONPATH=. uv run pytest -n auto _test_unstructured_client -v -k "unit"
.PHONY: test-contract
test-contract:
PYTHONPATH=. uv run pytest -n auto _test_contract -v
# Assumes you have unstructured-api running on localhost:8000
.PHONY: test-integration
test-integration:
PYTHONPATH=. uv run pytest $(INTEGRATION_PYTEST_ARGS)
# Runs the unstructured-api in docker for tests
.PHONY: test-integration-docker
test-integration-docker:
@bash -lc 'set -euo pipefail; \
container_name=unstructured-api; \
image="${DOCKER_IMAGE}"; \
cleanup() { \
status=$$?; \
if [ $$status -ne 0 ]; then \
echo "integration diagnostics image=$$image container=$$container_name"; \
docker logs "$$container_name" --tail 200 || true; \
fi; \
docker kill "$$container_name" >/dev/null 2>&1 || true; \
exit $$status; \
}; \
trap cleanup EXIT; \
docker stop "$$container_name" >/dev/null 2>&1 || true; \
docker kill "$$container_name" >/dev/null 2>&1 || true; \
echo "starting integration api image=$$image"; \
docker run --name "$$container_name" -p 8000:8000 -d --rm "$$image" --host 0.0.0.0; \
curl -s -o /dev/null --retry 10 --retry-delay 5 --retry-all-errors http://localhost:8000/general/docs; \
PYTHONPATH=. uv run pytest $(INTEGRATION_PYTEST_ARGS)'
.PHONY: test-integration-platform
test-integration-platform:
PYTHONPATH=. uv run pytest $(PLATFORM_INTEGRATION_PYTEST_ARGS)
.PHONY: lint
lint:
uv run pylint --rcfile=pylintrc src
uv run mypy src
.PHONY: publish
publish:
./scripts/publish.sh