# galaxy/integration test entry points.
#
# Targets:
#   preclean          — wipe leftover containers/networks/images from
#                       earlier runs (idempotent).
#   integration       — preclean, then run every test in the module
#                       sequentially (`-p=1 -parallel=1`). Recommended
#                       default for a slow / shared Docker.
#   integration-step  — preclean before each test and run them one at
#                       a time, stopping on the first failure. Use to
#                       isolate a flake or build up to a full pass.
#
# Override knobs:
#   INTEGRATION_TIMEOUT   per-test timeout for `make integration`
#                         (default 15m).
#   STEP_TIMEOUT          per-test timeout for `make integration-step`
#                         (default 5m, exported to runstep.sh).
#
# Both runners disable parallelism so concurrent docker-compose
# bootstraps cannot overload Docker. They also disable the
# testcontainers Ryuk reaper because it does not start cleanly on the
# colima/docker setup we use locally — the `preclean` target removes
# leftover state by label instead, which Ryuk would otherwise handle.

INTEGRATION_TIMEOUT ?= 15m
STEP_TIMEOUT ?= 5m

GO_TEST_FLAGS = -count=1 -timeout=$(INTEGRATION_TIMEOUT) -p=1 -parallel=1

export TESTCONTAINERS_RYUK_DISABLED = true

.PHONY: preclean integration integration-step

preclean:
	@bash scripts/preclean.sh

integration: preclean
	go test $(GO_TEST_FLAGS) ./...

integration-step:
	@STEP_TIMEOUT=$(STEP_TIMEOUT) bash scripts/runstep.sh
