Run tests from GitHub Actions and other CI
Run Testmode tests from a pipeline: the Testmode AI GitHub Action with its inputs and outputs, and the same script for GitLab, CircleCI, Jenkins or any CI with bash, curl and jq.
Run your Testmode tests from CI, for example after every deploy to staging, and fail the build when a test fails. You need a project API key.
GitHub Actions
Section titled “GitHub Actions”-
Create an API key and add it to your repository as the secret
TESTMODE_API_KEY(Settings > Secrets and variables > Actions in GitHub). -
Save a workflow such as
.github/workflows/testmode.yml:name: Testmodeon:push:branches: [main]workflow_dispatch:jobs:e2e:runs-on: ubuntu-lateststeps:- uses: amber-digital-bv/testmode-ai-action@v1with:api-key: ${{ secrets.TESTMODE_API_KEY }}environment: Stagingtest-plan: Smoke -
Push. The job starts the run, waits for it, prints each test’s result, and fails when a test fails.
Settings > Project > API & CI shows this snippet filled in with the environment and plan you pick. The action is Testmode AI on the GitHub Marketplace.
Inputs
Section titled “Inputs”| Input | Default | Meaning |
|---|---|---|
api-key |
(required) | The project API key, from a secret |
environment |
The project’s default environment | Environment name or id |
test-plan |
Test plan name or id | |
test-case-ids |
Test case ids, separated by commas or spaces | |
tags |
Run every enabled test case with any of these tags | |
name |
<workflow> #<run> · <branch> · <sha> |
The run’s name in Testmode |
wait |
true |
Wait for the run and fail the job unless it passed. false returns once it is queued. |
timeout-minutes |
30 |
Stop waiting after this long. The run itself goes on. |
api-url |
https:// |
Only for another deployment |
Give exactly one of test-plan, test-case-ids or tags. Names match exactly, ignoring case; pass the id when two share a name.
Outputs and exit
Section titled “Outputs and exit”The action sets run-id, run-url and status (PASSED, FAILED, CANCELED, SKIPPED, or QUEUED when not waiting), and writes a job summary with each test. The step succeeds when the run passed, or once it is queued with wait: false; it fails when the run didn’t pass or waiting timed out, and when the run couldn’t be started or read.
Run after a deploy
Section titled “Run after a deploy”jobs: deploy: runs-on: ubuntu-latest steps: - run: ./deploy-staging.sh e2e: needs: deploy runs-on: ubuntu-latest steps: - uses: amber-digital-bv/testmode-ai-action@v1 with: api-key: ${{ secrets.TESTMODE_API_KEY }} environment: Staging tags: smokeTell Self-driving what you deployed
Section titled “Tell Self-driving what you deployed”With Self-driving on (Pro and Startup), report each deploy so it reviews what changed: which tests need fixing or adding, and what to map. Add a step after the deploy:
- name: Tell Testmode about the deploy run: | curl -fsS -X POST https://api.testmode.ai/v1/deploys \ -H "Authorization: Bearer ${{ secrets.TESTMODE_API_KEY }}" \ -H "Content-Type: application/json" \ -d "{\"environment\": \"Staging\", \"version\": \"${{ github.sha }}\"}"See Report a deploy for the other fields. On Free the call is refused with 402, and curl -f fails the step, so add it once the organization is on a plan.
Other CI
Section titled “Other CI”The action’s script runs unchanged in any CI with bash, curl and jq. Set the key and what to run as environment variables:
export TESTMODE_API_KEY=tmk_... # from your CI's secret storeexport TESTMODE_TEST_PLAN="Smoke" # or TESTMODE_TAGS / TESTMODE_TEST_CASE_IDSexport TESTMODE_ENVIRONMENT="Staging" # optionalcurl -fsSL https://raw.githubusercontent.com/amber-digital-bv/testmode-ai-action/v1/run.sh | bashIt exits 0 when the run passed, 1 when it didn’t pass or waiting timed out, and 2 when the run couldn’t be started or read. The script’s header lists every setting.
Prefer your own calls? Use the REST API directly.
Good practice
Section titled “Good practice”- Run against a test environment. Tests do what their steps say, including orders and messages. Testmode treats every environment alike, so what keeps live data safe is a login that can do no harm, or running on staging.
- Give busy pipelines their own keys. One key allows 60 requests a minute, and a waiting job polls every 15 seconds.
- Name runs after the change, such as the pull request, so Test runs shows which change a result belongs to. The action does this by default.
- Every action costs a credit, like a run from the app. The action works on every plan, Free too, within its limits: on Free one test runs at a time, and at most 30 runs start an hour and 100 a day.