#!/usr/bin/make -f

# See debhelper(7) (uncomment to enable).
# Output every command that modifies files on the build system.
#export DH_VERBOSE = 1

override_dh_auto_test:
# ciuser is used because tox and PostgreSQL cannot be run as root.
# localtmp is recreated from scratch so the step is idempotent on reused
# CI workspaces (a leftover localtmp used to make `mkdir` fail the build).
ifeq ($(CI),true)
	echo "This is running in automated ci infrastructure"
	adduser --disabled-password --gecos "" ciuser
	rm -rf $(CURDIR)/localtmp
	mkdir -p $(CURDIR)/localtmp
	chown -R ciuser:ciuser $(CURDIR)
	su ciuser -c "env TMPDIR=$(CURDIR)/localtmp tox"
else
	tox
endif

%:
	dh $@ --with python3 --buildsystem=pybuild

override_dh_auto_build:
	dh_auto_build
	tox -e docs
