Use Tusk Drift as API tests in your CI/CD pipeline by running your test suite against commits in your pull requests (PRs).
Tusk Drift Cloud offers storage of these tests alongside an additional layer of intelligence on deviations detected:
- Automatic recording of traces based on live traffic in your environment of choice
- Securely store and maintain these traces as API test suites
- Analyze deviations (classification of intended vs. unintended deviations), determine root cause of deviations against your code changes, and suggest fixes
Getting Started
1
Create an account
Create a Tusk account at https://app.usetusk.ai.
2
Connect your repository
Go to the Repositories page on the sidebar and connect the GitHub or GitLab code repository with the service you wish to set up Tusk Drift for.
3
Get your API key
Click on the Settings > API Keys and create a Tusk API key.
Configuration
Haven’t set up a Tusk Drift config? Install our CLI first.
.tusk/config.yaml:
service.id: Please contact support@usetusk.ai to set this up. We’re working on a wizard to enable you to set this up yourself.tusk_api.url: Required for exporting traces and test results to Tusk.recording.sampling_rate: The fraction of live requests to record (a value between 0 and 1). Higher values improve fidelity but adds more overhead on your service. We recommend setting a value between 0.01 - 0.1.recording.export_spans: Whether to export recorded traffic to Tusk. If set tofalse, it will export traces to your machine’s filesystem. For deployed services, set this totrue.recording.enable_env_var_recording: Whether to record and replay environment variables. We recommend setting this totruefor accurate replay behavior if your service’s logic depends on environment variables.
TUSK_API_KEY) in your machine. You may also wish to add this as a GitHub secret so that GitHub Actions workflows can access it securely (see below for an example).
Running Tusk Drift in Your CI/CD Pipeline
- GitHub Actions
Here’s an example of GitHub Actions workflow. Adapt accordingly for your service.
tusk run crash-course:
-c: Load tests from Tusk Drift Cloud-p: Print mode (non-interactive)--ci: Create a Tusk Drift run and upload results to Tusk Drift Cloud
tusk run --help.
Deviation Analysis
When replayed against past recordings, your code change could yield intended deviations (this is good since existing behavior is modified as expected) or unintended deviations (unexpected regressions or bugs). A Tusk Drift run in a CI/CD environment (if the--ci flag is present) exports test results and commit information to Tusk. For each test with a deviation, Tusk correlates the deviation with code changes and performs an analysis, classifying whether it is likely intended/unintended.
If it is unintended, Tusk will provide a root cause analysis and suggest fixes. A PR/MR with unintended deviations will have a “Failed” status and may be blocked from merging.



FAQs
How much of a performance impact will Tusk have on my service?
How much of a performance impact will Tusk have on my service?
With a sampling rate of 0.01, expect to see a ~6.4% performance impact.
How do you handle duplicate requests or ensure a diverse test suite?
How do you handle duplicate requests or ensure a diverse test suite?
Tusk intelligently selects up to 10 unique requests for each endpoint, prioritizing the most diverse ones to ensure comprehensive test coverage. A maximum of 200 unique endpoints are stored for your test suite.
Merging a PR caused some tests to be deleted. What can I do next?
Merging a PR caused some tests to be deleted. What can I do next?
Depending on your traffic volume, you may need to wait for Tusk to replenish tests for these APIs. You also may wish to manually make requests to your service to trigger recordings.