chore: Remove the Makefile backup target (#3000)

* 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
This commit is contained in:
Brennan Kinney 2023-01-13 10:13:42 +13:00 committed by GitHub
parent a7e6439a39
commit 1650cdf76f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 171 deletions

View file

@ -15,7 +15,7 @@ BATS_PARALLEL_JOBS ?= 2
# --- Generic Targets ---------------------------
# -----------------------------------------------
all: lint build backup generate-accounts tests clean
all: lint build generate-accounts tests clean
build:
@ DOCKER_BUILDKIT=1 docker build \
@ -28,14 +28,9 @@ 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
backup:
# if backup directory exist, clean hasn't been called, therefore
# we shouldn't overwrite it. It still contains the original content.
-@ [[ ! -d testconfig.bak ]] && cp -rp test/config testconfig.bak || :
# `docker ps`: Remove any lingering test containers
# `.gitignore`: Remove `test/duplicate_configs` and files copied via `make generate-accounts`
clean:
# remove test containers and restore test/config directory
-@ [[ -d testconfig.bak ]] && { sudo rm -rf test/config ; mv testconfig.bak test/config ; } || :
-@ 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
@ -53,7 +48,9 @@ tests/serial: ALWAYS_RUN
tests/parallel/set%: ALWAYS_RUN
@ shopt -s globstar ; ./test/bats/bin/bats $(BATS_FLAGS) \
--no-parallelize-within-files --jobs $(BATS_PARALLEL_JOBS) test/$@/**/*.bats
--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