diff --git a/.github/workflows/server-build.yml b/.github/workflows/server-build.yml index 3abc74258c..e0f5d6fe1a 100644 --- a/.github/workflows/server-build.yml +++ b/.github/workflows/server-build.yml @@ -183,11 +183,16 @@ jobs: args+=("-DtestResultFile=$PWD/failed-server-tests.txt") if ! mvn test "${args[@]}"; then if [[ -s failed-server-tests.txt ]]; then - { - echo "## Failed tests" + content="$( + echo "## Failed server tests" echo sed 's/^/- /' 'failed-server-tests.txt' - } >> "$GITHUB_STEP_SUMMARY" + )" + echo "$content" >> "$GITHUB_STEP_SUMMARY" + # Add a comment to the PR with the list of failed tests. + curl --header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + --data "$(jq -n --arg body "$content" '$ARGS.named')" \ + "https://api.github.com/repos/$GITHUB_REPOSITORY/issues/${{ inputs.pr }}/comments" fi exit 1 fi diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/TestResultLoggerExtension.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/TestResultLoggerExtension.java index 2a9a009dea..ccdc67563a 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/TestResultLoggerExtension.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/TestResultLoggerExtension.java @@ -6,8 +6,8 @@ import org.junit.jupiter.api.extension.TestWatcher; import java.io.FileWriter; import java.io.IOException; -import java.util.ArrayList; -import java.util.List; +import java.util.Collection; +import java.util.TreeSet; /** * The TestWatcher interface is used to react to the execution of tests. @@ -20,7 +20,7 @@ import java.util.List; */ public class TestResultLoggerExtension implements TestWatcher, AfterAllCallback { - private final List failedTests = new ArrayList<>(); + private final Collection failedTests = new TreeSet<>(); /** * This method is called after all the tests are run. It writes the failed tests to a file.