mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
1650cdf76f
* chore: Remove `backup` target from Makefile - The `backup` target is no longer serving any value to us. It was made redundant with changes added in Oct 2020. - `clean` target inline docs revised. - `.gitignore` remove test lines that are no longer valid. * chore: Parallel test target split to multi-line * tests(fix): Test `setup.sh` with temporary config dir The `no_containers.bats` test has many redundant test cases already covered by `setup-cli`. They're basically identical. Removed all but one. This removes some config dirs that were being explicitly created instead of using the test helper to generate a directory that can be used to test the `-p` option instead. * ci: Ensure tests are run when `Makefile` is modified
72 lines
2.4 KiB
Makefile
72 lines
2.4 KiB
Makefile
SHELL := /bin/bash
|
|
.SHELLFLAGS += -e -u -o pipefail
|
|
|
|
export REPOSITORY_ROOT := $(CURDIR)
|
|
export IMAGE_NAME ?= mailserver-testing:ci
|
|
export NAME ?= $(IMAGE_NAME)
|
|
|
|
MAKEFLAGS += --no-print-directory
|
|
BATS_FLAGS ?= --timing
|
|
BATS_PARALLEL_JOBS ?= 2
|
|
|
|
.PHONY: ALWAYS_RUN
|
|
|
|
# -----------------------------------------------
|
|
# --- Generic Targets ---------------------------
|
|
# -----------------------------------------------
|
|
|
|
all: lint build generate-accounts tests clean
|
|
|
|
build:
|
|
@ DOCKER_BUILDKIT=1 docker build \
|
|
--tag $(IMAGE_NAME) \
|
|
--build-arg VCS_VERSION=$(shell git rev-parse --short HEAD) \
|
|
--build-arg VCS_REVISION=$(shell cat VERSION) \
|
|
.
|
|
|
|
generate-accounts: ALWAYS_RUN
|
|
@ cp test/config/templates/postfix-accounts.cf test/config/postfix-accounts.cf
|
|
@ cp test/config/templates/dovecot-masters.cf test/config/dovecot-masters.cf
|
|
|
|
# `docker ps`: Remove any lingering test containers
|
|
# `.gitignore`: Remove `test/duplicate_configs` and files copied via `make generate-accounts`
|
|
clean:
|
|
-@ 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
|
|
-@ while read -r LINE; do [[ $${LINE} =~ test/.+ ]] && sudo rm -rf $${LINE}; done < .gitignore
|
|
|
|
# -----------------------------------------------
|
|
# --- Tests ------------------------------------
|
|
# -----------------------------------------------
|
|
|
|
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)
|
|
@ for DIR in tests/{serial,parallel/set{1,2,3}} ; do $(MAKE) generate-accounts "$${DIR}" ; done
|
|
|
|
tests/serial: ALWAYS_RUN
|
|
@ shopt -s globstar ; ./test/bats/bin/bats $(BATS_FLAGS) test/$@/*.bats
|
|
|
|
tests/parallel/set%: ALWAYS_RUN
|
|
@ shopt -s globstar ; ./test/bats/bin/bats $(BATS_FLAGS) \
|
|
--no-parallelize-within-files \
|
|
--jobs $(BATS_PARALLEL_JOBS) \
|
|
test/$@/**/*.bats
|
|
|
|
test/%: ALWAYS_RUN
|
|
@ shopt -s globstar nullglob ; ./test/bats/bin/bats $(BATS_FLAGS) test/tests/**/{$*,}.bats
|
|
|
|
# -----------------------------------------------
|
|
# --- Lints -------------------------------------
|
|
# -----------------------------------------------
|
|
|
|
lint: eclint hadolint shellcheck
|
|
|
|
hadolint:
|
|
@ ./test/linting/lint.sh hadolint
|
|
|
|
shellcheck:
|
|
@ ./test/linting/lint.sh shellcheck
|
|
|
|
eclint:
|
|
@ ./test/linting/lint.sh eclint
|