2022-11-25 21:58:16 +00:00
|
|
|
SHELL := /bin/bash
|
|
|
|
.SHELLFLAGS += -e -u -o pipefail
|
2020-09-05 14:19:12 +00:00
|
|
|
|
2022-11-25 21:58:16 +00:00
|
|
|
export REPOSITORY_ROOT := $(CURDIR)
|
|
|
|
export IMAGE_NAME ?= mailserver-testing:ci
|
|
|
|
export NAME ?= $(IMAGE_NAME)
|
|
|
|
|
2023-01-03 06:00:13 +00:00
|
|
|
MAKEFLAGS += --no-print-directory
|
|
|
|
BATS_FLAGS ?= --timing
|
|
|
|
BATS_PARALLEL_JOBS ?= 2
|
|
|
|
|
2022-11-25 21:58:16 +00:00
|
|
|
.PHONY: ALWAYS_RUN
|
2015-10-18 19:02:46 +00:00
|
|
|
|
2021-06-08 01:20:20 +00:00
|
|
|
# -----------------------------------------------
|
2022-10-16 19:08:04 +00:00
|
|
|
# --- Generic Targets ---------------------------
|
2021-06-08 01:20:20 +00:00
|
|
|
# -----------------------------------------------
|
2021-01-16 09:16:05 +00:00
|
|
|
|
2023-01-12 21:13:42 +00:00
|
|
|
all: lint build generate-accounts tests clean
|
2016-04-13 19:43:25 +00:00
|
|
|
|
2023-01-21 23:15:12 +00:00
|
|
|
build: ALWAYS_RUN
|
2022-10-16 19:08:04 +00:00
|
|
|
@ DOCKER_BUILDKIT=1 docker build \
|
|
|
|
--tag $(IMAGE_NAME) \
|
2022-10-14 07:48:28 +00:00
|
|
|
--build-arg VCS_VERSION=$(shell git rev-parse --short HEAD) \
|
|
|
|
--build-arg VCS_REVISION=$(shell cat VERSION) \
|
2022-09-21 07:31:28 +00:00
|
|
|
.
|
2015-10-18 19:02:46 +00:00
|
|
|
|
2022-11-25 21:58:16 +00:00
|
|
|
generate-accounts: ALWAYS_RUN
|
2022-10-16 19:08:04 +00:00
|
|
|
@ cp test/config/templates/postfix-accounts.cf test/config/postfix-accounts.cf
|
|
|
|
@ cp test/config/templates/dovecot-masters.cf test/config/dovecot-masters.cf
|
|
|
|
|
2023-01-12 21:13:42 +00:00
|
|
|
# `docker ps`: Remove any lingering test containers
|
|
|
|
# `.gitignore`: Remove `test/duplicate_configs` and files copied via `make generate-accounts`
|
2023-01-21 23:15:12 +00:00
|
|
|
clean: ALWAYS_RUN
|
2023-01-25 08:16:22 +00:00
|
|
|
-@ while read -r LINE; do CONTAINERS+=("$${LINE}"); done < <(docker ps -qaf name='^(dms-test|mail)_.*') ; \
|
|
|
|
for CONTAINER in "$${CONTAINERS[@]}"; do docker rm -f "$${CONTAINER}"; done
|
|
|
|
-@ while read -r LINE; do [[ $${LINE} =~ test/.+ ]] && FILES+=("/mnt$${LINE#test}"); done < .gitignore ; \
|
|
|
|
docker run --rm -v "$(REPOSITORY_ROOT)/test/:/mnt" alpine ash -c "rm -rf $${FILES[@]}"
|
2021-01-16 09:16:05 +00:00
|
|
|
|
2021-06-08 01:20:20 +00:00
|
|
|
# -----------------------------------------------
|
2022-11-25 21:58:16 +00:00
|
|
|
# --- Tests ------------------------------------
|
2021-06-08 01:20:20 +00:00
|
|
|
# -----------------------------------------------
|
2018-03-21 18:55:41 +00:00
|
|
|
|
2022-11-25 21:58:16 +00:00
|
|
|
tests: ALWAYS_RUN
|
|
|
|
# See https://github.com/docker-mailserver/docker-mailserver/pull/2857#issuecomment-1312724303
|
|
|
|
# on why `generate-accounts` is run before each set (TODO/FIXME)
|
2023-01-03 06:00:13 +00:00
|
|
|
@ for DIR in tests/{serial,parallel/set{1,2,3}} ; do $(MAKE) generate-accounts "$${DIR}" ; done
|
2022-11-25 21:58:16 +00:00
|
|
|
|
|
|
|
tests/serial: ALWAYS_RUN
|
2023-01-03 06:00:13 +00:00
|
|
|
@ shopt -s globstar ; ./test/bats/bin/bats $(BATS_FLAGS) test/$@/*.bats
|
2022-11-25 21:58:16 +00:00
|
|
|
|
|
|
|
tests/parallel/set%: ALWAYS_RUN
|
2023-01-21 23:15:12 +00:00
|
|
|
@ shopt -s globstar ; $(REPOSITORY_ROOT)/test/bats/bin/bats $(BATS_FLAGS) \
|
2023-01-12 21:13:42 +00:00
|
|
|
--no-parallelize-within-files \
|
|
|
|
--jobs $(BATS_PARALLEL_JOBS) \
|
|
|
|
test/$@/**/*.bats
|
2019-08-07 00:24:56 +00:00
|
|
|
|
2022-11-25 21:58:16 +00:00
|
|
|
test/%: ALWAYS_RUN
|
2023-01-03 06:00:13 +00:00
|
|
|
@ shopt -s globstar nullglob ; ./test/bats/bin/bats $(BATS_FLAGS) test/tests/**/{$*,}.bats
|
2022-11-25 21:58:16 +00:00
|
|
|
|
|
|
|
# -----------------------------------------------
|
|
|
|
# --- Lints -------------------------------------
|
|
|
|
# -----------------------------------------------
|
2020-09-05 14:19:12 +00:00
|
|
|
|
2023-01-21 23:15:12 +00:00
|
|
|
lint: ALWAYS_RUN eclint hadolint shellcheck
|
2020-10-04 17:34:15 +00:00
|
|
|
|
2023-01-21 23:15:12 +00:00
|
|
|
hadolint: ALWAYS_RUN
|
2020-10-04 17:34:15 +00:00
|
|
|
@ ./test/linting/lint.sh hadolint
|
|
|
|
|
2023-01-21 23:15:12 +00:00
|
|
|
shellcheck: ALWAYS_RUN
|
2020-10-04 17:34:15 +00:00
|
|
|
@ ./test/linting/lint.sh shellcheck
|
2020-09-24 12:54:21 +00:00
|
|
|
|
2023-01-21 23:15:12 +00:00
|
|
|
eclint: ALWAYS_RUN
|
2020-10-04 17:34:15 +00:00
|
|
|
@ ./test/linting/lint.sh eclint
|