2022-10-03 11:27:41 +00:00
|
|
|
# HINT
|
|
|
|
# Use this file to override variables here.
|
|
|
|
# For example, to run with podman put `DOCKER=podman` there.
|
|
|
|
-include Makefile.env
|
2016-06-26 17:42:40 +00:00
|
|
|
|
2022-10-03 11:27:41 +00:00
|
|
|
# NOTE
|
|
|
|
# Variables specified in `.env` file are used to pick and setup specific
|
|
|
|
# component versions, both when building a development image and when running
|
|
|
|
# CI workflows on GH Actions. This ensures that tasks run with `wc-` prefix
|
|
|
|
# (like `wc-dialyze`) are reproducible between local machine and CI runners.
|
|
|
|
DOTENV := $(shell grep -v '^\#' .env)
|
|
|
|
|
|
|
|
DOCKER ?= docker
|
|
|
|
REBAR ?= rebar3
|
|
|
|
TEST_CONTAINER_NAME ?= woody
|
|
|
|
|
|
|
|
all: compile
|
|
|
|
|
|
|
|
# Development images
|
|
|
|
|
|
|
|
DEV_IMAGE_TAG = $(TEST_CONTAINER_NAME)-dev
|
|
|
|
DEV_IMAGE_ID = $(file < .image.dev)
|
|
|
|
|
|
|
|
.PHONY: dev-image clean-dev-image wc-shell test
|
|
|
|
|
|
|
|
dev-image: .image.dev
|
|
|
|
|
|
|
|
.image.dev: Dockerfile.dev .env
|
|
|
|
$(DOCKER) build . -f Dockerfile.dev --tag $(DEV_IMAGE_TAG) $(DOTENV:%=--build-arg %)
|
|
|
|
$(DOCKER) image ls -q -f "reference=$(DEV_IMAGE_TAG)" | head -n1 > $@
|
|
|
|
|
|
|
|
clean-dev-image:
|
|
|
|
ifneq ($(DEV_IMAGE_ID),)
|
|
|
|
$(DOCKER) image rm -f $(DEV_IMAGE_TAG)
|
|
|
|
rm .image.dev
|
|
|
|
endif
|
|
|
|
|
|
|
|
DOCKER_WC_OPTIONS := -v $(PWD):$(PWD) --workdir $(PWD)
|
|
|
|
DOCKER_WC_EXTRA_OPTIONS ?= --rm
|
|
|
|
DOCKER_RUN = $(DOCKER) run -t $(DOCKER_WC_OPTIONS) $(DOCKER_WC_EXTRA_OPTIONS)
|
|
|
|
|
|
|
|
# Utility tasks
|
|
|
|
|
|
|
|
wc-shell: dev-image
|
|
|
|
$(DOCKER_RUN) --interactive --tty $(DEV_IMAGE_TAG)
|
|
|
|
|
|
|
|
wc-%: dev-image
|
|
|
|
$(DOCKER_RUN) $(DEV_IMAGE_TAG) make $*
|
|
|
|
|
|
|
|
# Rebar tasks
|
|
|
|
|
|
|
|
rebar-shell:
|
|
|
|
$(REBAR) shell
|
2016-06-26 17:42:40 +00:00
|
|
|
|
2022-01-21 12:10:58 +00:00
|
|
|
compile:
|
2016-06-26 17:42:40 +00:00
|
|
|
$(REBAR) compile
|
|
|
|
|
2022-01-21 12:10:58 +00:00
|
|
|
xref:
|
2016-04-14 07:40:33 +00:00
|
|
|
$(REBAR) xref
|
|
|
|
|
2022-01-21 12:10:58 +00:00
|
|
|
lint:
|
|
|
|
$(REBAR) lint
|
2016-06-26 17:42:40 +00:00
|
|
|
|
2022-10-03 11:27:41 +00:00
|
|
|
check-format:
|
2021-01-15 12:35:41 +00:00
|
|
|
$(REBAR) fmt -c
|
|
|
|
|
2022-10-03 11:27:41 +00:00
|
|
|
dialyze:
|
|
|
|
$(REBAR) as test dialyzer
|
|
|
|
|
|
|
|
release:
|
|
|
|
$(REBAR) as prod release
|
|
|
|
|
|
|
|
eunit:
|
|
|
|
$(REBAR) eunit --cover
|
|
|
|
|
|
|
|
common-test:
|
|
|
|
$(REBAR) ct --cover
|
|
|
|
|
|
|
|
cover:
|
|
|
|
$(REBAR) covertool generate
|
|
|
|
|
2021-01-15 12:35:41 +00:00
|
|
|
format:
|
|
|
|
$(REBAR) fmt -w
|
|
|
|
|
2016-04-14 07:40:33 +00:00
|
|
|
clean:
|
|
|
|
$(REBAR) clean
|
|
|
|
|
2022-10-03 11:27:41 +00:00
|
|
|
distclean: clean-build-image
|
|
|
|
rm -rf _build
|
2016-04-14 07:40:33 +00:00
|
|
|
|
2022-10-03 11:27:41 +00:00
|
|
|
test: eunit common-test
|
2016-06-26 17:42:40 +00:00
|
|
|
|
2022-10-03 11:27:41 +00:00
|
|
|
cover-report:
|
2022-01-21 12:10:58 +00:00
|
|
|
$(REBAR) cover
|
|
|
|
|
2019-12-11 16:07:16 +00:00
|
|
|
bench:
|
2019-12-31 09:52:56 +00:00
|
|
|
$(REBAR) as test bench -m bench_woody_event_handler -n 1000
|
|
|
|
$(REBAR) as test bench -m bench_woody_formatter -n 10
|
|
|
|
erl -pa _build/test/lib/*/ebin _build/test/lib/woody/test -noshell \
|
|
|
|
-s benchmark_memory_pressure run \
|
|
|
|
-s erlang halt
|