fistful-server/Makefile

110 lines
2.2 KiB
Makefile
Raw Normal View History

# HINT
# Use this file to override variables here.
# For example, to run with podman put `DOCKER=podman` there.
-include Makefile.env
# 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)
# Development images
DEV_IMAGE_TAG = $(TEST_CONTAINER_NAME)-dev
DEV_IMAGE_ID = $(file < .image.dev)
DOCKER ?= docker
DOCKERCOMPOSE ?= docker-compose
DOCKERCOMPOSE_W_ENV = DEV_IMAGE_TAG=$(DEV_IMAGE_TAG) $(DOCKERCOMPOSE)
REBAR ?= rebar3
TEST_CONTAINER_NAME ?= testrunner
2018-06-13 13:43:48 +00:00
all: compile
2018-06-13 13:43:48 +00:00
.PHONY: dev-image clean-dev-image wc-shell test
2018-06-13 13:43:48 +00:00
dev-image: .image.dev
2018-06-13 13:43:48 +00:00
.image.dev: Dockerfile.dev .env
env $(DOTENV) $(DOCKERCOMPOSE_W_ENV) build $(TEST_CONTAINER_NAME)
$(DOCKER) image ls -q -f "reference=$(DEV_IMAGE_TAG)" | head -n1 > $@
2019-05-28 13:32:59 +00:00
clean-dev-image:
ifneq ($(DEV_IMAGE_ID),)
$(DOCKER) image rm -f $(DEV_IMAGE_TAG)
rm .image.dev
endif
2018-06-13 13:43:48 +00:00
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)
2018-06-13 13:43:48 +00:00
DOCKERCOMPOSE_RUN = $(DOCKERCOMPOSE_W_ENV) run --rm $(DOCKER_WC_OPTIONS)
# Utility tasks
wc-shell: dev-image
$(DOCKER_RUN) --interactive --tty $(DEV_IMAGE_TAG)
2018-06-13 13:43:48 +00:00
wc-%: dev-image
$(DOCKER_RUN) $(DEV_IMAGE_TAG) make $*
2018-06-13 13:43:48 +00:00
wdeps-shell: dev-image
$(DOCKERCOMPOSE_RUN) $(TEST_CONTAINER_NAME) su; \
$(DOCKERCOMPOSE_W_ENV) down
2018-06-13 13:43:48 +00:00
wdeps-%: dev-image
$(DOCKERCOMPOSE_RUN) -T $(TEST_CONTAINER_NAME) make $*; \
res=$$?; \
$(DOCKERCOMPOSE_W_ENV) down; \
exit $$res
2018-06-13 13:43:48 +00:00
# Rebar tasks
2018-06-13 13:43:48 +00:00
rebar-shell:
$(REBAR) shell
2021-04-15 07:26:11 +00:00
compile:
2018-06-13 13:43:48 +00:00
$(REBAR) compile
xref:
2018-06-13 13:43:48 +00:00
$(REBAR) xref
lint:
$(REBAR) lint
2018-06-13 13:43:48 +00:00
check-format:
2020-12-02 14:43:45 +00:00
$(REBAR) fmt -c
dialyze:
2021-04-26 08:30:10 +00:00
$(REBAR) as test dialyzer
2018-06-13 13:43:48 +00:00
static-check: check-format lint xref dialyze
release:
$(REBAR) as prod release
2021-04-15 07:26:11 +00:00
eunit:
$(REBAR) eunit --cover
2021-04-15 07:26:11 +00:00
common-test:
$(REBAR) ct --cover
cover:
$(REBAR) covertool generate
format:
$(REBAR) fmt -w
2018-06-13 13:43:48 +00:00
clean:
$(REBAR) clean
distclean: clean-dev-image
2018-06-13 13:43:48 +00:00
rm -rf _build
test: eunit common-test
cover-report:
$(REBAR) cover