CircleCI
Configure Flaky Tests using CircleCI
Getting Started
You can use the analytics test uploader within your CircleCI workflows to upload and analyze your test results.
The Trunk Flaky Tests Uploader currently only supports Linux x64 and macOS for Intel and Arm. If you have another use case, please get in touch with support at https://slack.trunk.io. For the best results, you'll need to validate that your test invocation doesn't use cached test results and doesn't automatically retry failing tests.
Create a CircleCI Workflow
Create a CircleCI workflow (or modify an existing one) to run the tests that you want to monitor. The workflow should produce a test report in JUnit XML format. Most testing frameworks support XML output. See Testing Framework Configuration for guides for common testing frameworks. Make sure that your test invocation doesn't use cached test results, and doesn't automatically retry failing tests.
Find Organization Slug and Token
Next you will need your Trunk organization slug and token. Navigate to app.trunk.io. Once logged in navigate to Settings -> Manage -> Organization. Copy your organization slug. You can find your Trunk token by navigating to Settings → Manage Organization → Organization API Token and clicking "View." Copy this token. Make sure you are getting your organization token, not your project/repo token.
Set Project Environment Variables
In your CircleCI project settings under Environment Variables, create new variables for your Trunk org as TRUNK_ORG_SLUG
and the api token as TRUNK_API_TOKEN
.
Add Uploader to Testing Workflow
Now update your CircleCI workflow to download and run the test uploader binary after you've run your tests. Here is an example of a NodeJS project using JUnit tests.
In the config about we have added a second run
step fo the test-node
job. This step downloads the latest release of the trunk-analytics-uploader
, makes it executable, then runs it to upload the test output xml file. The TRUNK_ORG_SLUG and TRUNK_API_TOKEN variables are filled in at runtime by the CircleCI environment variables set earlier. Note that the when
property is set to always
because it should run whether or not the actual tests in the previous run
step succeed.
If you're interested in better understanding this binary or want to contribute to it, you can find the open source repo here.
Last updated