source_files = collaborator/ scripts/ tests/ *.py
test_files = tests/unit/ tests/functional/ tests/scripts/
script_name ?= check_wise_transaction_statuses

# Environment

env:
	poetry install --no-root

clean:
	poetry env remove $$(poetry env info --executable)


# Development

dev:
	poetry run python dev.py

lint:
	poetry run ruff check $(source_files)
	poetry run mypy $(source_files)
	poetry run ruff format --check $(source_files)

format:
	poetry run ruff check --fix $(source_files)
	poetry run ruff format $(source_files)

docker_login:
	aws ecr get-login-password --region us-east-1 | \
	docker login --username AWS \
		--password-stdin 086679231553.dkr.ecr.us-east-1.amazonaws.com

docker_script_run:
	docker compose run --build --env-from-file .env \
		--entrypoint /poetry/bin/poetry dev run python -m scripts.$(script_name)

# Tests

test:
	poetry run py.test $(test_files) --lf

test_coverage:
	poetry run py.test $(test_files) \
		--cov collaborator \
		--cov-report xml:build/coverage.xml \
		--cov-report term \
		--junitxml=build/pyunit.xml

test_integration:
	poetry run py.test tests/integration/


# Jenkins

unit_lint: lint test_coverage

ci_unit_lint: ci_unit_lint_clean
	mkdir -p build
	chmod a+w build
	docker compose up \
		--build \
		--exit-code-from unit-lint \
		--abort-on-container-exit \
		--remove-orphans \
		unit-lint

ci_unit_lint_clean:
	rm -rf build

ci_test_integration:
	docker compose up \
		--build \
		--exit-code-from test-integration \
		--abort-on-container-exit \
		--remove-orphans \
		test-integration
