Skip to content

Commit d07a07f

Browse files
committed
Fail with 255 in case of exception
Signed-off-by: eduponz <eduardoponz@eprosima.com>
1 parent bacdc81 commit d07a07f

3 files changed

Lines changed: 23 additions & 14 deletions

File tree

resources/flakiness_report.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,25 @@ def parse_options() -> argparse.Namespace:
6464

6565
if __name__ == "__main__":
6666

67-
args = parse_options()
67+
try:
68+
args = parse_options()
6869

69-
archive = FlakyTestsArchive(
70-
args.junit_archive,
71-
args.window_size,
72-
args.delete_old_files
73-
)
70+
archive = FlakyTestsArchive(
71+
args.junit_archive,
72+
args.window_size,
73+
args.delete_old_files
74+
)
75+
76+
if args.markdown_file:
77+
FlakyTestsMdPublisher.publish(archive, args.markdown_file)
7478

75-
if args.markdown_file:
76-
FlakyTestsMdPublisher.publish(archive, args.markdown_file)
79+
if args.json_file:
80+
FlakyTestsJSONPublisher.publish(archive, args.json_file)
7781

78-
if args.json_file:
79-
FlakyTestsJSONPublisher.publish(archive, args.json_file)
82+
ret = 0 if archive.flaky_test_count == 0 else 1
83+
exit(ret)
8084

81-
ret = 0 if archive.flaky_test_count == 0 else 1
82-
exit(ret)
85+
except Exception as e:
86+
# Exit with 255 error so that the action can fail
87+
print(e)
88+
exit(255)

ubuntu/flakiness_report/action.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ runs:
8787
8888
echo "Flakiness report generated"
8989
90-
if [[ "${{ inputs.fail_on_flaky_tests }}" != "True" ]]
90+
# A 255 exit code indicates that an exception occurred in the script, we want to fail in that case
91+
if [ "${{ inputs.fail_on_flaky_tests }}" != "True" ] && [ "$EXIT_CODE" != "255" ]
9192
then
9293
echo "Ignoring flaky tests failures"
9394
EXIT_CODE=0

windows/flakiness_report/action.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ runs:
7474
7575
$EXIT_CODE = $LASTEXITCODE
7676
77-
if ("${{ inputs.fail_on_flaky_tests }}" -ne "True") {
77+
# A 255 exit code indicates that an exception occurred in the script, we want to fail in that case
78+
if ("${{ inputs.fail_on_flaky_tests }}" -ne "True" -and $EXIT_CODE -ne 255) {
79+
Write-Output "Ignoring flaky tests failures"
7880
$EXIT_CODE = 0
7981
}
8082

0 commit comments

Comments
 (0)