From 953e45f62eb68cc0fea91483c442b596878cf649 Mon Sep 17 00:00:00 2001 From: Leendert de Borst Date: Fri, 19 Jul 2024 17:39:39 +0200 Subject: [PATCH 1/7] Add SmtpService test to Github Action after docker build (#111) --- .github/workflows/docker-compose-build.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/docker-compose-build.yml b/.github/workflows/docker-compose-build.yml index 9fe769c0e..1047d4dce 100644 --- a/.github/workflows/docker-compose-build.yml +++ b/.github/workflows/docker-compose-build.yml @@ -47,3 +47,14 @@ jobs: else echo "Service responded with $http_code" fi + - name: Test if localhost:2525 (Email Service) responds + - name: Test if SmtpService responds + run: | + # Test if the service on localhost:25 responds + response=$(curl -s --connect-timeout 5 localhost:2525) + if [ -z "$response" ]; then + echo "SmtpService did not respond on port 25. Check if the SmtpService service is running." + exit 1 + else + echo "SmtpService responded on port 25" + fi From 28275bb6d9a5fdbc52025f62e7f3314432d26b71 Mon Sep 17 00:00:00 2001 From: Leendert de Borst Date: Fri, 19 Jul 2024 20:15:26 +0200 Subject: [PATCH 2/7] Update docker-compose-build.yml (#111) --- .github/workflows/docker-compose-build.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker-compose-build.yml b/.github/workflows/docker-compose-build.yml index 1047d4dce..ab99a7a15 100644 --- a/.github/workflows/docker-compose-build.yml +++ b/.github/workflows/docker-compose-build.yml @@ -47,11 +47,10 @@ jobs: else echo "Service responded with $http_code" fi - - name: Test if localhost:2525 (Email Service) responds - - name: Test if SmtpService responds + - name: Test if localhost:25 (SmtpService) responds run: | # Test if the service on localhost:25 responds - response=$(curl -s --connect-timeout 5 localhost:2525) + response=$(curl -s --connect-timeout 5 localhost:25) if [ -z "$response" ]; then echo "SmtpService did not respond on port 25. Check if the SmtpService service is running." exit 1 From 7ba94b93154693d3e513d10ad2933dbf3265381a Mon Sep 17 00:00:00 2001 From: Leendert de Borst Date: Fri, 19 Jul 2024 20:23:20 +0200 Subject: [PATCH 3/7] Change SMTP port from 25 to 2525 for GH Actions only (#111) --- .github/workflows/docker-compose-build.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker-compose-build.yml b/.github/workflows/docker-compose-build.yml index ab99a7a15..e79e70e14 100644 --- a/.github/workflows/docker-compose-build.yml +++ b/.github/workflows/docker-compose-build.yml @@ -21,7 +21,8 @@ jobs: ./init.sh - name: Set up Docker Compose run: | - # Build the images and start the services + # Change the exposed host port of the SmtpService from 25 to 2525 because port 25 is not allowed in GitHub Actions + sed -i 's/25:25/2525:25/' docker-compose.yml docker compose -f docker-compose.yml up -d - name: Wait for services to be up run: | @@ -47,13 +48,13 @@ jobs: else echo "Service responded with $http_code" fi - - name: Test if localhost:25 (SmtpService) responds + - name: Test if localhost:2525 (SmtpService) responds run: | - # Test if the service on localhost:25 responds - response=$(curl -s --connect-timeout 5 localhost:25) + # Test if the service on localhost:2525 responds + response=$(curl -s --connect-timeout 5 localhost:2525) if [ -z "$response" ]; then - echo "SmtpService did not respond on port 25. Check if the SmtpService service is running." + echo "SmtpService did not respond on port 2525. Check if the SmtpService service is running." exit 1 else - echo "SmtpService responded on port 25" + echo "SmtpService responded on port 2525" fi From 51cd53ee9e3db7453240a7bd726441e592f6246c Mon Sep 17 00:00:00 2001 From: Leendert de Borst Date: Fri, 19 Jul 2024 20:32:48 +0200 Subject: [PATCH 4/7] Change sed command (#111) --- .github/workflows/docker-compose-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-compose-build.yml b/.github/workflows/docker-compose-build.yml index e79e70e14..b38f86518 100644 --- a/.github/workflows/docker-compose-build.yml +++ b/.github/workflows/docker-compose-build.yml @@ -22,7 +22,7 @@ jobs: - name: Set up Docker Compose run: | # Change the exposed host port of the SmtpService from 25 to 2525 because port 25 is not allowed in GitHub Actions - sed -i 's/25:25/2525:25/' docker-compose.yml + sed -i '' 's/25\:25/2525\:25/g' docker-compose.yml docker compose -f docker-compose.yml up -d - name: Wait for services to be up run: | From a639a2581aa0801b68270dc75b8669b5752276c0 Mon Sep 17 00:00:00 2001 From: Leendert de Borst Date: Fri, 19 Jul 2024 20:37:01 +0200 Subject: [PATCH 5/7] Update sed command without macOS fix (#111) --- .github/workflows/docker-compose-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-compose-build.yml b/.github/workflows/docker-compose-build.yml index b38f86518..6f91c3f17 100644 --- a/.github/workflows/docker-compose-build.yml +++ b/.github/workflows/docker-compose-build.yml @@ -22,7 +22,7 @@ jobs: - name: Set up Docker Compose run: | # Change the exposed host port of the SmtpService from 25 to 2525 because port 25 is not allowed in GitHub Actions - sed -i '' 's/25\:25/2525\:25/g' docker-compose.yml + sed -i 's/25\:25/2525\:25/g' docker-compose.yml docker compose -f docker-compose.yml up -d - name: Wait for services to be up run: | From 4c15d64ece8d6215b40e5bae171c75618982091d Mon Sep 17 00:00:00 2001 From: Leendert de Borst Date: Fri, 19 Jul 2024 20:46:35 +0200 Subject: [PATCH 6/7] Change curl to nc to check tcp port (#111) --- .github/workflows/docker-compose-build.yml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docker-compose-build.yml b/.github/workflows/docker-compose-build.yml index 6f91c3f17..9e3d0a6fa 100644 --- a/.github/workflows/docker-compose-build.yml +++ b/.github/workflows/docker-compose-build.yml @@ -50,11 +50,10 @@ jobs: fi - name: Test if localhost:2525 (SmtpService) responds run: | - # Test if the service on localhost:2525 responds - response=$(curl -s --connect-timeout 5 localhost:2525) - if [ -z "$response" ]; then - echo "SmtpService did not respond on port 2525. Check if the SmtpService service is running." - exit 1 - else - echo "SmtpService responded on port 2525" - fi + # Test if the service on localhost:2525 responds + if nc -zv localhost 2525 2>&1 | grep -q 'succeeded'; then + echo "SmtpService did not respond on port 2525. Check if the SmtpService service is running." + exit 1 + else + echo "SmtpService responded on port 2525" + fi From 00b145bcf9c4f90a639ac71609e87dd9e1a53fea Mon Sep 17 00:00:00 2001 From: Leendert de Borst Date: Fri, 19 Jul 2024 20:53:14 +0200 Subject: [PATCH 7/7] Fix nc test if/else (#111) --- .github/workflows/docker-compose-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-compose-build.yml b/.github/workflows/docker-compose-build.yml index 9e3d0a6fa..07b5079b9 100644 --- a/.github/workflows/docker-compose-build.yml +++ b/.github/workflows/docker-compose-build.yml @@ -51,7 +51,7 @@ jobs: - name: Test if localhost:2525 (SmtpService) responds run: | # Test if the service on localhost:2525 responds - if nc -zv localhost 2525 2>&1 | grep -q 'succeeded'; then + if ! nc -zv localhost 2525 2>&1 | grep -q 'succeeded'; then echo "SmtpService did not respond on port 2525. Check if the SmtpService service is running." exit 1 else