1- .PHONY : all test tests test_watch test_coverage test_profile docs docs-strict docs-serve docs-update-cards docs-check-cards docs-watch-cards pre_commit help
1+ .PHONY : help
2+ .PHONY : test test-parallel test-serial test-benchmark test-watch test-coverage test-profile warm-fastembed-cache
3+ .PHONY : docs docs-strict docs-serve docs-update-cards docs-check-cards docs-watch-cards docs-check-redirects
4+ .PHONY : pre-commit
25
3- # Default target executed when no specific target is provided to make.
4- all : help
6+ .DEFAULT_GOAL := help
57
6- # Define a variable for the test file path.
7- TEST_FILE ?= tests/
8+ TEST ?=
9+ ARGS ?=
10+ WORKERS ?= auto
11+ # pytest-xdist --dist strategy for $(PYTEST) -n $(WORKERS) --dist $(DIST) $(ARGS) $(TEST).
12+ # worksteal dynamically rebalances queued tests; override DIST when debugging or grouping matters.
13+ DIST ?= worksteal
14+
15+ PYTEST ?= poetry run pytest
16+ # These targets assume a Unix-like shell for env -u; use bash, Git Bash, or WSL on Windows.
17+ UNIT_TEST_ENV ?= env -u OPENAI_API_KEY -u NVIDIA_API_KEY \
18+ -u LIVE_TEST -u LIVE_TEST_MODE -u TEST_LIVE_MODE
19+
20+ FASTEMBED_CACHE ?= .cache/fastembed
21+ FASTEMBED_MODEL ?= sentence-transformers/all-MiniLM-L6-v2
22+ FASTEMBED_ENV ?= env FASTEMBED_CACHE_PATH=$(FASTEMBED_CACHE )
823
924test :
10- poetry run pytest $(TEST_FILE )
25+ $(UNIT_TEST_ENV ) $(PYTEST ) -n $(WORKERS ) --dist $(DIST ) $(ARGS ) $(TEST )
26+
27+ test-parallel : test
28+
29+ test-serial :
30+ $(PYTEST ) $(ARGS ) $(TEST )
1131
12- tests :
13- poetry run pytest $( TEST_FILE )
32+ test-benchmark :
33+ $( PYTEST ) $( ARGS ) benchmark/tests
1434
15- test_watch :
16- poetry run ptw --snapshot-update --now . -- -vv $(TEST_FILE )
35+ test-watch :
36+ poetry run ptw --snapshot-update --now . -- -vv $(ARGS ) $( TEST )
1737
18- test_coverage :
19- poetry run pytest --cov= $( TEST_FILE ) --cov- report=term-missing
38+ test-coverage :
39+ $( UNIT_TEST_ENV ) $( PYTEST ) -n $( WORKERS ) --dist $( DIST ) --cov=nemoguardrails --cov- report=xml:coverage.xml $( ARGS ) $( TEST )
2040
21- test_profile :
22- poetry run pytest -vv tests/ --profile-svg
41+ test-profile :
42+ $(PYTEST ) -vv --profile-svg $(ARGS ) $(TEST )
43+
44+ warm-fastembed-cache :
45+ $(FASTEMBED_ENV ) poetry run python -c ' from fastembed import TextEmbedding; model = TextEmbedding("$(FASTEMBED_MODEL)"); next(model.embed(["warmup"]))'
2346
2447docs :
2548 poetry run sphinx-build -b html docs _build/docs
@@ -42,25 +65,38 @@ docs-watch-cards:
4265docs-check-redirects :
4366 cd docs && poetry run python scripts/validate_redirects.py
4467
45- pre_commit :
46- pre-commit install
47- pre-commit run --all-files
48-
49-
50- # HELP
68+ pre-commit :
69+ poetry run pre-commit install
70+ poetry run pre-commit run --all-files
5171
5272help :
53- @echo ' ----'
54- @echo ' test - run unit tests'
55- @echo ' tests - run unit tests'
56- @echo ' test TEST_FILE=<test_file> - run all tests in given file'
57- @echo ' test_watch - run unit tests in watch mode'
58- @echo ' test_coverage - run unit tests with coverage'
59- @echo ' docs - build docs, if you installed the docs dependencies'
60- @echo ' docs-strict - build docs with warnings as errors (used in CI)'
61- @echo ' docs-serve - serve docs locally with auto-rebuild on changes'
62- @echo ' docs-update-cards - update grid cards in index files from linked pages'
63- @echo ' docs-check-cards - check if grid cards are up to date (dry run)'
64- @echo ' docs-watch-cards - watch for file changes and auto-update cards'
65- @echo ' docs-check-redirects - validate that all redirect targets exist'
66- @echo ' pre_commit - run pre-commit hooks'
73+ @printf ' %s\n' \
74+ ' ' \
75+ ' Usage:' \
76+ ' make test [TEST=path] [WORKERS=auto] [ARGS="-q --tb=short"]' \
77+ ' make test-serial [TEST=path] [ARGS="-q"]' \
78+ ' make test-benchmark [ARGS="-q"]' \
79+ ' make test-parallel [TEST=path] [WORKERS=auto] [ARGS="-q --tb=short"]' \
80+ ' make test-watch [TEST=path]' \
81+ ' ' \
82+ ' Tests:' \
83+ ' test Run pytest.ini testpaths with pytest-xdist' \
84+ ' test-parallel Alias for test' \
85+ ' test-serial Run pytest without xdist or env filtering' \
86+ ' test-benchmark Run benchmark tooling tests' \
87+ ' test-watch Run pytest in watch mode' \
88+ ' test-coverage Run pytest with coverage' \
89+ ' test-profile Run pytest with profiling' \
90+ ' warm-fastembed-cache Prime the repo-local FastEmbed cache' \
91+ ' ' \
92+ ' Docs:' \
93+ ' docs Build docs' \
94+ ' docs-strict Build docs with warnings as errors' \
95+ ' docs-serve Serve docs locally' \
96+ ' docs-update-cards Update generated docs cards' \
97+ ' docs-check-cards Check generated docs cards' \
98+ ' docs-watch-cards Watch and update generated docs cards' \
99+ ' docs-check-redirects Validate docs redirects' \
100+ ' ' \
101+ ' Maintenance:' \
102+ ' pre-commit Install and run pre-commit hooks'
0 commit comments