From 05e41edc1c5081d1251256af93a698ef0a6974b7 Mon Sep 17 00:00:00 2001 From: Peter Motzko Date: Fri, 27 Oct 2023 11:49:42 +0200 Subject: [PATCH] feat(ci): add "ignoreFailures" parameter in gradle test execution And fail the pipeline, when failed tests occurs --- .github/workflows/app-test-coverage-pr.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/app-test-coverage-pr.yml b/.github/workflows/app-test-coverage-pr.yml index 3073c2dfe..5fec6e7b5 100644 --- a/.github/workflows/app-test-coverage-pr.yml +++ b/.github/workflows/app-test-coverage-pr.yml @@ -44,7 +44,7 @@ jobs: env: GITHUB_USERNAME: ${{ vars.GITHUB_ACTOR }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: ./gradlew test + run: ./gradlew test -PtestIgnoreFailures > test_output.txt - name: Get coverage if: always() @@ -70,3 +70,18 @@ jobs: min-coverage-overall: 80 min-coverage-changed-files: 80 title: Coverage Report + + - name: Fail pipeline, when there are failed tests + run: | + RESULT=$(grep FAILED test_output.txt | wc -l | xargs) + + echo "Found 'FAILED' tests: $RESULT" + + if [[ $RESULT -gt 0 ]] + then + echo "Tests failed!" + exit 1 + else + echo "Tests OK!" + exit 0 + fi