Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions .circleci/create_circleci_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,18 +223,27 @@ def to_dict(self):
# failure.
test_command = f"({test_command}) || true"
else:
test_command += " | tee tests_output.txt"
test_command += " | tee tests_output.txt || true"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This step will always succeed. This is not ideal, but it's necessary for the next step (Check test results) to run (when some tests fail).

steps.append({"run": {"name": "Run tests", "command": test_command}})

check_test_command = f'if [ -s reports/tests_{self.name}/failures_short.txt ]; '
check_test_command += 'then echo "Some test failed!"; echo ""; '
check_test_command += f'cat reports/tests_{self.name}/failures_short.txt; '
check_test_command += 'echo ""; echo ""; '

py_command = f'import os; fp = open("reports/tests_{self.name}/summary_short.txt"); failed = os.linesep.join([x for x in fp.read().split(os.linesep) if x.startswith("FAILED ")]); fp.close(); fp = open("summary_short.txt", "w"); fp.write(failed); fp.close()'
check_test_command += f"$(python3 -c '{py_command}'); "

check_test_command += f'cat summary_short.txt; echo ""; exit -1; '
check_test_command += f'elif [ -s reports/tests_{self.name}/stats.txt ]; then echo "All tests pass!"; '

# return code `124` means the previous (pytest run) step is timeout
if self.name == "pr_documentation_tests":
checkout_doctest_command = 'if [ -s reports/tests_pr_documentation_tests/failures_short.txt ]; '
checkout_doctest_command += 'then echo "some test failed"; '
checkout_doctest_command += 'cat reports/tests_pr_documentation_tests/failures_short.txt; '
checkout_doctest_command += 'cat reports/tests_pr_documentation_tests/summary_short.txt; exit -1; '
checkout_doctest_command += 'elif [ -s reports/tests_pr_documentation_tests/stats.txt ]; then echo "All tests pass!"; '
checkout_doctest_command += 'elif [ -f 124.txt ]; then echo "doctest timeout!"; else echo "other fatal error)"; exit -1; fi;'
steps.append({"run": {"name": "Check doctest results", "command": checkout_doctest_command}})
check_test_command += 'elif [ -f 124.txt ]; then echo "doctest timeout!"; '

check_test_command += 'else echo "other fatal error"; echo ""; exit -1; fi;'

steps.append({"run": {"name": "Check test results", "command": check_test_command}})
Comment on lines +229 to +246

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit ugly, but just to show the failed (and only failed) tests.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far I put failures_short.tx. We can use failures_long.tx if you prefer.


steps.append({"store_artifacts": {"path": "~/transformers/tests_output.txt"}})
steps.append({"store_artifacts": {"path": "~/transformers/reports"}})
Expand Down Expand Up @@ -594,7 +603,7 @@ def create_circleci_config(folder=None):
job.tests_to_run = [f"examples/{framework}"]
else:
job.tests_to_run = [f for f in example_tests.split(" ") if f.startswith(f"examples/{framework}")]

if len(job.tests_to_run) > 0:
jobs.append(job)

Expand Down