Overview
This article provides troubleshooting steps for customers who encounter a parallel run failure when using the Rerun Failed Tests feature in CircleCI. Specifically, this issue occurs when a rerun fails due to the persist_to_workspace step not finding any contents in the specified directory. We will guide you through the necessary steps to avoid this failure and ensure a successful rerun.
Issue: Parallel rerun failure
If your job runs tests in parallel and persists files to a workspace, you may encounter a parallel run failure during a rerun. This failure occurs when the persist_to_workspace step cannot find any contents in the specified directory. The reason behind this issue is that the parallel run does not always execute tests on a rerun if there are not enough tests to distribute across all parallel runs.
To avoid this failure, follow the steps below:
-
Add mkdir command: Before running any tests, add a
mkdir
command to set up the directory (or directories) that will eventually be persisted to a workspace. This ensures that the directory exists even if no tests are executed during a parallel rerun.steps: - checkout - run: mkdir no_files_here - run: #test command with circleci tests run that populates no_files_here if tests are run - store_test_results: path: ./test-results - store_artifacts: path: ./test-results - persist_to_workspace: root: . paths: - no_files_here
-
Verify directory population: On a rerun, if the parallel run executes tests, the
no_files_here
directory will be populated. If no tests are executed, the persist_to_workspace step will not fail because theno_files_here
directory already exists.
By following these steps, you can prevent the parallel run failure when rerunning tests.
Comments
Article is closed for comments.