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
|
|
|
|
2015-10-18 19:02:46 +00:00
|
|
|
build:
|
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`
|
2021-01-16 09:16:05 +00:00
|
|
|
clean:
|
2023-01-03 06:00:13 +00:00
|
|
|
-@ for CONTAINER in $$(docker ps -a --filter name='^dms-test_.*|^mail_.*|^hadolint$$|^eclint$$|^shellcheck$$' | sed 1d | cut -f 1-1 -d ' '); do docker rm -f $${CONTAINER}; done
|
2022-10-16 19:08:04 +00:00
|
|
|
-@ while read -r LINE; do [[ $${LINE} =~ test/.+ ]] && sudo rm -rf $${LINE}; done < .gitignore
|
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-09 07:54:04 +00:00
|
|
|
@ shopt -s globstar ; ./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
|
|
|
|
2020-10-04 17:34:15 +00:00
|
|
|
lint: eclint hadolint shellcheck
|
|
|
|
|
|
|
|
hadolint:
|
|
|
|
@ ./test/linting/lint.sh hadolint
|
|
|
|
|
2020-09-05 14:19:12 +00:00
|
|
|
shellcheck:
|
2020-10-04 17:34:15 +00:00
|
|
|
@ ./test/linting/lint.sh shellcheck
|
2020-09-24 12:54:21 +00:00
|
|
|
|
|
|
|
eclint:
|
2020-10-04 17:34:15 +00:00
|
|
|
@ ./test/linting/lint.sh eclint
|