Skip to content

Commit

Permalink
ci: run mail tests in workflow
Browse files Browse the repository at this point in the history
Resolves #658
  • Loading branch information
YC committed Jul 11, 2024
1 parent fe672bb commit d26f8b7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ jobs:
npm -g install newman
./testing/run_api_tests.sh
- name: Mail Tests
run: ./testing/run_mail_test.sh

migration:
name: Migration tests
runs-on: ubuntu-latest
Expand Down
10 changes: 4 additions & 6 deletions testing/run_api_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -o nounset -o pipefail -o errexit
DB_TYPE=${1-sqlite}

if ! command -v newman &> /dev/null; then
echo "Newman could not be found. Run 'npm install -g newman' first."
echo "newman could not be found. Run 'npm install -g newman' first."
exit 1
fi

Expand Down Expand Up @@ -135,7 +135,6 @@ start_wakapi_background "../wakapi" "$config"
kill_wakapi

# Only sqlite has data

if [ "$DB_TYPE" == "sqlite" ]; then
echo "Creating database and schema ..."
sqlite3 wakapi_testing.db < schema.sql
Expand All @@ -145,10 +144,9 @@ if [ "$DB_TYPE" == "sqlite" ]; then
start_wakapi_background "../wakapi" "$config"
echo "Running test collection ..."
if ! newman run "wakapi_api_tests.postman_collection.json"; then
exit_code=$?
echo "newman failed with exit code $exit_code"
exit "$exit_code"
echo "newman failed"
exit 1
fi

kill_wakapi
fi

16 changes: 12 additions & 4 deletions testing/run_mail_tests.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
#!/bin/bash
set -o nounset -o errexit -o pipefail

cleanup() {
echo "Stopping and removing smtpdev ..."
docker stop smtp4dev_wakapi &> /dev/null || true
docker rm -f smtp4dev_wakapi &> /dev/null
}
trap cleanup EXIT

cleanup

echo "Starting smtp4dev in Docker ..."
docker run -d --rm -p 2525:25 -p 8080:80 --name smtp4dev_wakapi rnwood/smtp4dev

echo "Running tests ..."
go test -run TestSmtpTestSuite ../services/mail

echo "Killing container again ..."
docker stop smtp4dev_wakapi
script_dir=$(dirname "${BASH_SOURCE[0]}")
go test -count=1 -run TestSmtpTestSuite "$script_dir/../services/mail"

0 comments on commit d26f8b7

Please sign in to comment.