Skip to main content
Use the CLI to push test files and the API to start and inspect a run. egma run create returns after starting the run; its exit code is not a test result. This example uses one policy: every simulation must complete, and every grader selected for it must pass. Flagged missing agent evidence, missing grades, grading errors, cancellation, execution failures, and timeouts fail the CI job. This is the policy in the example, not an overall verdict assigned by Egma.

Prepare the CI job

Set up a supported agent connection, create a suite, and commit egma/config.yaml, its suite.yaml, and your test files. Configure the graders you want to enforce before running CI. From your signed-in repository, create a project API key:
Store the returned secret in your CI secret store as EGMA_API_KEY. Set these job variables: Use Node.js 22 or later and install the CLI in the job. Run this job only on trusted changes that can access your secret and test connection. Serialize jobs that push to the same Egma project so they do not replace each other’s test content.

Save the runner

Save this as scripts/egma-ci.mjs. It uses Node’s built-in fetch, follows all pages, and pins the suite’s test versions when creating the run.
scripts/egma-ci.mjs

Run it

After your CI system supplies the variables above, execute these commands from the repository root. Stop the job if either command fails:
The API creates the run from the saved suite. expectedTestVersions makes run creation fail if that suite changes between the snapshot and creation. A run keeps its grader plan and thresholds, so the script checks those frozen values against the latest grades. The runner requires agentPovComplete to be true and agentPovIncomplete to be false. This checks for a final agent record without a degradation flag. It does not prove that the current grades used late evidence. If evidence arrives after grading, regrade the simulation before using its grades to make a release decision.

Handle a failed job

Open the printed results URL. For a failed grade, inspect its rationale and transcript. For an execution failure, inspect the simulation’s failure reason. For a grading error, fix the cause before starting a new CI run or regrading the existing simulation. The runner waits for up to 15 minutes, with a short extra window to request cancellation if execution is still active. If your CI system kills the process first, cancel the run from its results page or with egma run cancel. Use a new EGMA_CI_RUN_KEY label for a new CI attempt. The label is not an idempotency key. The runner does not retry run creation. If the response is lost, check Runs before submitting again because each accepted request creates another run. The API reference documents the complete request and response contracts. This runner does not use the combined score as a release decision.