# OS agnostic: every recipe is a single uv invocation, so it behaves the same
# under cmd.exe, PowerShell and POSIX shells. Requires GNU make and uv.

UV ?= uv
ARGS ?=

.DEFAULT_GOAL := help
.PHONY: help install build run test clean

help:
	@echo Targets:
	@echo   make install    - sync the virtual environment including dev dependencies
	@echo   make build      - build the sdist and wheel into dist/
	@echo   make run        - run bd-jira-sync, pass arguments via ARGS
	@echo   make test       - run the test suite, pass arguments via ARGS
	@echo   make clean      - remove build artefacts and caches
	@echo   Quote ARGS so make does not consume the leading dashes, for example:
	@echo   make run ARGS="MASTER-1 --license --security --send"
	@echo   make test ARGS="-k license -v"

install:
	$(UV) sync --all-groups

build:
	$(UV) build

run:
	$(UV) run bd-jira-sync $(ARGS)

test:
	$(UV) run pytest $(ARGS)

clean:
	$(UV) run python -c "import pathlib, shutil; [shutil.rmtree(p, ignore_errors=True) for p in ['dist', 'build', '.pytest_cache']]; [shutil.rmtree(p, ignore_errors=True) for p in pathlib.Path('.').rglob('__pycache__')]"
