Every job is one
momentic run command in CI. The examples below use GitHub
Actions. See GitLab CI or
custom setups for other providers. Each job
needs MOMENTIC_API_KEY as a secret; see
GitHub Actions for how to
create it. A failed run exits non-zero, so CI blocks the merge or the release.
Quarantined tests are the exception and do not affect the exit code by default.
Pull request check
Run the tests against the pull request’s preview deployment, so the change runs in a real browser before review. This job starts when Vercel (or any provider that posts a GitHub deployment) marks the preview as ready. It runs only the tests that AI test selection picks from the diff:.github/workflows/pr-tests.yml
deployment_statusfires when the provider reports a deployment. Theifguard runs the job only for a readyPreviewdeployment. Match the environment name your provider posts;environment_urlis its target URL.fetch-depth: 0gives--ai-selectthe full history to diff againstorigin/main. Thedeployment_statusevent carries no pull request base, so--ai-select-basesets it. On apull_requestevent you can omit it. See AI test selection.--url-overridepoints every test at the preview URL. It also replaces a test’s ownurl.- The two
--custom-headersvalues pass Vercel’s protection bypass. Skip them if the preview is public. See Vercel preview auth. --reporter stepsprints one line per step to the CI log.--reporter junitwrites a JUnit XML file toreports/for your CI’s test summary. See JUnit outputs.
--skip-quarantined to skip them, or
--ignore-quarantine to count every status. See
quarantine.
To gate every pull request on a fixed set instead of the diff, label the flows
you would roll back for, such as sign-in and checkout, with critical. Then
replace --ai-select --ai-select-base origin/main with --labels critical.
Keep the label under about ten tests and leave edge cases to the
regression pass.
Add tests in the same pull request
Ask your coding agent to cover the changed journeys with themomentic-spec skill:
.test.yaml files land in the same pull request and CI job.
Review test changes in the pull request
Review the YAML and run evidence using Build with AI. The pull request check uploads results. The GitHub integration posts a status comment with a link to each run. Open the run in results to review its screenshots and trace. Keep credentials in environment variables, not literal test values. To rerun changed tests locally before approving:momentic list --changed and
momentic lint for selection and
validation details.
Regression pass
Run the whole test suite on every merge tomain and on a nightly schedule.
This job shards the suite across four runners and merges the results into one
run group in the dashboard:
.github/workflows/regression.yml
--env stagingselects thestagingenvironment frommomentic.config.yaml, so the same tests run against itsbaseUrland credentials. See environments.- Each shard writes to its own
--output-dir. Theuploadjob merges them so the dashboard shows one run group instead of four. See GitHub Actions. - Add
npx momentic ai triage test-results/merged --yes --timeout-minutes 10after the upload to classify failures on the merged run group and let auto-heal attempt repairs. By default, repairs arrive in a pull request; review and merge it before the next run.
Deploy gate
Run a small set of critical flows against the new production deployment, and roll back if a flow fails. Use test accounts and a payment integration in test mode for the checkout below. Tag the flows with asmoke label:
tests/checkout.test.yaml
.github/workflows/deploy.yml
--labels smokeruns only tests that carry the label. A path (npx momentic run tests/smoke) or--includeand--excludealso work. Theincludeandexcludeglobs inmomentic.config.yamlcontrol discovery, not one run.--retries 1reruns a failed test once before the job fails, so one transient network error does not trigger a rollback.- Run the same job before the deploy against staging with
--url-override "$STAGING_URL"if you want a gate in front of the release too.
- Flows whose failure is an incident: login, checkout, the primary create or submit action.
- One happy path per flow. Leave edge cases to the regression pass.
- End-to-end paths, so one test runs against the real stack.
Related
GitHub Actions
Authentication, sharding, and result upload in detail.
AI test selection
Pick the tests to run from a git diff.
Quarantine
Isolate unstable tests without blocking the rest of the suite.
Environments
Point the same tests at staging or production.