1
1
Fork 0
mirror of https://github.com/docker-mailserver/docker-mailserver synced 2024-05-21 02:56:06 +02:00
docker-mailserver/Makefile
Brennan Kinney 19e96b5131
fix: `update-check.sh` should query GH Releases (#3666)
* fix: Source `VERSION` from image ENV

Now CI builds triggered from tagged releases will always have the correct version. No need for manually updating a separate file.

* fix: Query latest GH release tag

Compare to the remote GH release tag published, rather than contents of a `VERSION` file.

`VERSION` file remains in source for now as prior releases still rely on it for an update notification.

* chore: Switch from `yq` to `jaq`

- Can more easily express a string subslice.
- Lighter weight: 9.3M vs 1.7M.
- Drawback, no YAML input/output support.

If `yq` is preferred, the `v` prefix could be removed via BASH easily enough.

* chore: Add entry to `CHANGELOG.md`

* ci: `VERSION` has no relevance to `:edge`

* docs: Update build guide + simplify `make build`

---------

Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2023-11-30 10:21:26 +13:00

73 lines
2.5 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: ALWAYS_RUN
@ docker build --tag $(IMAGE_NAME) .
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: ALWAYS_RUN
-@ 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[@]}"
# -----------------------------------------------
# --- 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 ; $(REPOSITORY_ROOT)/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: ALWAYS_RUN eclint hadolint bashcheck shellcheck
hadolint: ALWAYS_RUN
@ ./test/linting/lint.sh hadolint
bashcheck: ALWAYS_RUN
@ ./test/linting/lint.sh bashcheck
shellcheck: ALWAYS_RUN
@ ./test/linting/lint.sh shellcheck
eclint: ALWAYS_RUN
@ ./test/linting/lint.sh eclint