-
Notifications
You must be signed in to change notification settings - Fork 73
Expand file tree
/
Copy pathMakefile
More file actions
102 lines (80 loc) · 2.69 KB
/
Makefile
File metadata and controls
102 lines (80 loc) · 2.69 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
PACKAGE_NAME := unstructured_inference
CURRENT_DIR := $(shell pwd)
.PHONY: help
help: Makefile
@sed -n 's/^\(## \)\([a-zA-Z]\)/\2/p' $<
###########
# Install #
###########
## install: install all dependencies via uv
.PHONY: install
install:
@uv sync --locked --all-groups
## install-lint: install only lint dependencies (no project deps)
.PHONY: install-lint
install-lint:
@uv sync --locked --only-group lint
## lock: update and lock all dependencies
.PHONY: lock
lock:
@uv lock --upgrade
#################
# Test and Lint #
#################
export CI ?= false
## test: runs all unittests (excluding slow)
.PHONY: test
test:
CI=$(CI) uv run --locked --no-sync pytest -n auto -m "not slow" test_${PACKAGE_NAME} --cov=${PACKAGE_NAME} --cov-report term-missing
## test-slow: runs all unittests (including slow)
.PHONY: test-slow
test-slow:
CI=$(CI) uv run --locked --no-sync pytest -n auto test_${PACKAGE_NAME} --cov=${PACKAGE_NAME} --cov-report term-missing
## check: runs all linters and checks
.PHONY: check
check: check-ruff check-version
## check-ruff: runs ruff linter
.PHONY: check-ruff
check-ruff:
uv run --locked --no-sync ruff check .
uv run --locked --no-sync ruff format --check .
## check-scripts: run shellcheck
.PHONY: check-scripts
check-scripts:
scripts/shellcheck.sh
## check-version: run check to ensure version in CHANGELOG.md matches version in package
.PHONY: check-version
check-version:
# Fail if syncing version would produce changes
scripts/version-sync.sh -c \
-s CHANGELOG.md \
-f ${PACKAGE_NAME}/__version__.py semver
## tidy: auto-format and fix lint issues
.PHONY: tidy
tidy:
uv run --locked --no-sync ruff format .
uv run --locked --no-sync ruff check --fix-only --show-fixes .
## version-sync: update __version__.py with most recent version from CHANGELOG.md
.PHONY: version-sync
version-sync:
scripts/version-sync.sh \
-s CHANGELOG.md \
-f ${PACKAGE_NAME}/__version__.py semver
## check-coverage: check test coverage meets threshold
.PHONY: check-coverage
check-coverage:
uv run --locked --no-sync coverage report --fail-under=90
##########
# Docker #
##########
DOCKER_IMAGE ?= unstructured-inference:dev
.PHONY: docker-build
docker-build:
DOCKER_IMAGE=${DOCKER_IMAGE} ./scripts/docker-build.sh
.PHONY: docker-test
docker-test: docker-build
docker run --rm \
-v ${CURRENT_DIR}/test_unstructured_inference:/home/test_unstructured_inference \
-v ${CURRENT_DIR}/sample-docs:/home/sample-docs \
$(DOCKER_IMAGE) \
bash -c "pytest -n auto $(if $(TEST_NAME),-k $(TEST_NAME),) test_unstructured_inference"