1#!/bin/bash 2# 3# Pre-test hook executed by the DokuWiki test workflow before PHPUnit runs. 4# 5# It starts a Mailpit SMTP server so IntegrationTest can deliver a real mail 6# through the plugin and verify it via Mailpit's HTTP API. The connection details 7# are exported to the PHPUnit step through $GITHUB_ENV. Setting MAILPIT_HOST is what 8# enables the test - it then requires Mailpit to be reachable or fails. 9# 10# Mailpit is started with an auto-generated self-signed certificate (the "sans:" 11# syntax) so it offers STARTTLS. The smtp_allow_insecure test needs this and fails 12# (it does not skip) when the server does not speak TLS. 13# 14set -e 15 16# start Mailpit: SMTP on 1025, HTTP API/web UI on 8025, STARTTLS with a self-signed cert 17docker run -d --name mailpit -p 1025:1025 -p 8025:8025 axllent/mailpit:latest \ 18 --smtp-tls-cert sans:localhost --smtp-tls-key sans:localhost 19 20# wait until Mailpit is ready to accept connections 21echo "Waiting for Mailpit to become ready..." 22ready=0 23for _ in $(seq 1 30); do 24 if curl -sf http://127.0.0.1:8025/readyz >/dev/null 2>&1; then 25 ready=1 26 break 27 fi 28 sleep 1 29done 30if [ "$ready" -ne 1 ]; then 31 echo "Mailpit did not become ready in time" >&2 32 docker logs mailpit || true 33 exit 1 34fi 35echo "Mailpit is ready" 36 37# expose the connection details to the PHPUnit step 38{ 39 echo "MAILPIT_HOST=127.0.0.1" 40 echo "MAILPIT_SMTP_PORT=1025" 41 echo "MAILPIT_HTTP_PORT=8025" 42} >> "$GITHUB_ENV" 43