Travis CI
Configure Flaky Tests using Travis CI
Getting Started
You can use the Flaky Tests CLI within your Travis CI workflows to upload and analyze your test results.
The Trunk Flaky Tests CLI currently only supports x86_64 and arm64 for both Linux and macOS. 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 does not use cached test results and does not automatically retry failing tests.
Create a Travis CI Workflow
Create a Travis CI 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 Travis CI 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 Travis CI workflow to download and run the Trunk Uploader binary after you've run your tests. Here is an example of a NodeJS project using Vitest tests.
You can upload test results to Flaky Tests with the trunk-analytics-cli
by running it in a stage after your tests are complete. There are four different OS/arch builds of the CLI in the latest release. Pick the one you need for your testing platform and be sure to download the release on every CI run. Do not bake the CLI into a container or VM. This ensures your CI runs are always using the latest build.
Note that TravisCI requires a recent version of Linux to use the current NodeJS runtimes. You may need to set the dist
to jammy
or later. See this forum note for more details.
In the config about we have added two additional commands to download the latest release of the trunk-analytics-cli
and then run it to upload the test output XML file. The TRUNK_ORG_SLUG and TRUNK_API_TOKEN variables are filled in at runtime by the Travis CI environment variables set earlier.
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