# The standard targets of a youSleep analysis project.
#
#   make verify                 build the image and run the conformance check
#   make run RECORDING=x.edf    run the image by hand on a recording
#   make record                 record the expected output for regression runs
#   make check                  validate the configuration only

CONFIG    := {{ slug }}.yaml
IMAGE     := {{ image }}:dev
RECORDING ?= night.edf
EXPECTED  := conformance/expected-events.json.gz
VERIFY_ARGS ?=

.PHONY: build manifest run verify record check clean

build:  ## Build the image
	docker build -t $(IMAGE) .

manifest:  ## Write the manifest the platform would write for RECORDING
	yousleep-manifest --recording $(RECORDING) --config $(CONFIG) > manifest.json

run: build manifest  ## Run the image by hand; the events document lands in ./output-events.json.gz
	docker run --rm --network none -v "$(CURDIR):/local" $(IMAGE) --manifest-file /local/manifest.json

verify: build  ## The conformance check, against the recorded output when there is one
	yousleep-verify --image $(IMAGE) --config $(CONFIG) \
		$(if $(wildcard $(EXPECTED)),--expected $(EXPECTED),) $(VERIFY_ARGS)

record: build  ## Record this build's output as the expected document
	yousleep-verify --image $(IMAGE) --config $(CONFIG) --expected $(EXPECTED) --record

check:  ## Validate the configuration without running anything
	yousleep-verify --image $(IMAGE) --config $(CONFIG) --config-only

clean:
	rm -f manifest.json output-events.json.gz
