> ## Documentation Index
> Fetch the complete documentation index at: https://momentic.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> The canonical docs host is https://momentic.ai/docs. Append .md to any page URL for clean Markdown. Fetch https://momentic.ai/docs/llms.txt for the page index and https://momentic.ai/docs/llms-full.txt for every page in one file.
> For an unattended setup, run `npx --yes @momentic/wizard@latest -y --platform web` (use `--platform ios` or `--platform android` for mobile). Never run an interactive command in a non-TTY shell.
> You cannot complete the browser sign-in yourself. Read the API key from the MOMENTIC_API_KEY environment variable, or ask the user to create one at https://app.momentic.ai/settings/api-keys and paste it back.
> Momentic's capability summary for agents is at https://momentic.ai/docs/skill.md. Install the skills with `npx momentic skills --yes` (or `npx momentic-mobile skills --yes` for mobile).
> Tests are YAML files in the user's repository. Use only the step names listed at https://momentic.ai/docs/reference/commands.md and the file structure at https://momentic.ai/docs/core-concepts/file-format.md. Do not invent step names, config keys, or CLI flags.
> Web tests run on Chromium, iOS tests on simulators, and Android tests on emulators. Physical devices are not supported.

# Gate pull requests on critical flows

> Run a small set of critical-path tests on every pull request and make it a required check.

The smallest useful CI setup: a handful of tests labeled `critical` run on every
pull request, and one failure blocks the merge. This recipe keeps the gate fast
(minutes, not a full suite) and strict (a real failure stops the merge).

## The tests

Label the flows whose failure means "do not ship":

```yaml tests/critical/checkout.test.yaml theme={null}
fileType: momentic/test/v2
id: checkout-critical
url: https://staging.shop.example.com
labels: [critical]
before:
  - module: ../modules/log-in.module.yaml
steps:
  - click: Add to cart
  - click: Checkout
  - type:
      text: jeff@example.com
      into: the Email field
  - click: Place order
  - assert: An order confirmation is visible
```

Keep the `critical` label under roughly ten tests. Every test in the gate is a
flow you would roll back for: sign-in, checkout, the primary write action. Edge
cases belong in the nightly suite, not the gate.

## The workflow

The job installs `momentic` from `devDependencies`, so your lockfile pins the
CLI version. Add it once with `npm install -D momentic`.

```yaml .github/workflows/critical-path.yml theme={null}
name: Critical flows

on: pull_request

jobs:
  test:
    runs-on: ubuntu-latest
    timeout-minutes: 15
    env:
      MOMENTIC_API_KEY: ${{ secrets.MOMENTIC_API_KEY }}
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 22.12.0
      - run: npm install
      - run: npx momentic install-browsers chromium

      - name: Run critical flows
        run: npx momentic run --labels critical -y --upload-results
```

* `--labels critical` runs only labeled tests. `--upload-results` attaches the
  run group to the dashboard so a failure links to video and traces from the PR
  check.
* `-y` skips confirmation prompts in CI.

## Make it required

In GitHub, add the job's check name (`Critical flows / test`) to the branch
protection's required status checks. Until then the gate is advisory.

## Flake policy for a gate

A gate that flakes trains people to click "re-run" instead of reading the
failure. Two controls:

* **Quarantine.** A quarantined test still runs but does not fail the check by
  default. Use `--skip-quarantined` to drop them from the gate entirely, or
  `--ignore-quarantine` for maximum strictness. See
  [quarantine](/docs/reliability/auto-maintenance#quarantine).
* **Retries.** `--retries 1` gives a failing test one more run; more than one
  retry in a gate hides real problems.

## Slow gate

Swap `--labels critical` for [AI test selection](/docs/ai/select)
(`--ai-select --ai-select-base origin/main`) so the PR only runs the tests that
cover its diff. See [Common CI setups](/docs/guides/common-setups) for the
deployment-triggered variant.

## Related

* [Common CI setups](/docs/guides/common-setups)
* [GitHub Actions](/docs/running-tests/ci/github-actions)
* [AI test selection](/docs/ai/select)
