Skip to content

Commit 9d16f35

Browse files
committed
docs: --tia not for CI
1 parent bfc6d30 commit 9d16f35

3 files changed

Lines changed: 41 additions & 6 deletions

File tree

continuous-integration.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,26 @@ Of course, you may customize the scripts above according to your requirements. F
181181

182182
Once you have created your `.chipperci.yml` file, commit and push the `.chipperci.yml` file so Chipper CI can run your tests. Keep in mind that once you make this commit, your test suite will execute on all new commits.
183183

184+
## The Tia Engine And CI
185+
186+
The [Tia Engine](/docs/tia) re-runs only the tests affected by your latest changes, which makes it a wonderful companion while you work locally. On CI, however, you should not pass the `--tia` flag to the command that runs your test suite:
187+
188+
```bash
189+
./vendor/bin/pest --ci # runs the full suite on every commit
190+
./vendor/bin/pest --ci --tia # replays cached results — not what you want on CI
191+
```
192+
193+
Your pipeline is the place where every test runs against a clean checkout, so it should always execute the full suite. There is one exception: the dedicated workflow that records the shared baseline your team downloads. That job is separate from your test pipeline, and it is the only place `--tia` belongs on CI:
194+
195+
```yaml
196+
- name: Run tests
197+
run: ./vendor/bin/pest --parallel --tia --coverage --fresh
198+
```
199+
200+
For the complete workflow, including how to upload the recorded baseline as an artifact, see [Sharing The Baseline From CI](/docs/tia#sharing-the-baseline-from-ci).
201+
202+
> **Note:** If you enable TIA in your `tests/Pest.php` file, you should use `pest()->tia()->locally()` rather than `always()`, so that TIA is skipped whenever you run Pest with the `--ci` flag.
203+
184204
## Sharding Your Tests
185205

186206
If you have a large test suite, you may wish to shard your tests across multiple CI jobs to speed up execution time. Pest supports test sharding out of the box, allowing you to split your tests into smaller groups that may be run in parallel.

pest5-now-available.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Duration: 3.92s
5050

5151
A replay isn't a shortcut that skips work — each cached test stores everything it produced, including the exact lines and branches it covered, so a replayed run reports the same code coverage as a full run. And the dependency tree understands your whole stack: a migration change re-runs only the tests that queried that table, editing a shared JS component walks Vite's module graph to find every Inertia page that imports it, and a comment-only edit or formatter pass re-runs nothing at all. Pest detects Laravel, Symfony, Livewire, Inertia, and browser assets automatically via Composer.
5252

53-
For teams, you may have CI record the baseline once per merge to `main` so every developer downloads the result and starts replaying immediately. To learn more, check out the [Tia Engine documentation](/docs/tia).
53+
The Tia Engine is built for local development, so you should keep `--tia` out of the command that runs your test suite on CI — your pipeline should always execute the full suite against a clean checkout. The one exception is a dedicated workflow that records the baseline once per merge to `main`, so every developer downloads the result and starts replaying immediately. To learn more, check out the [Tia Engine documentation](/docs/tia).
5454

5555
<a name="the-agent"></a>
5656
## The Agent Plugin

tia.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ To get started, you may add the `--tia` flag to any Pest invocation:
2121
2222
The first run is the **baseline** — the engine enables a coverage driver (PCOV or Xdebug) and records the dependency graph as your tests execute. You may expect a small overhead on this run only.
2323

24+
> **Warning:** The Tia Engine is built for local development, and you should not add `--tia` to the command that runs your test suite on CI. Your pipeline exists to verify every test against a clean checkout, so it should always execute the full suite — the single exception is the dedicated job that records the shared baseline, described in [Sharing The Baseline From CI](#sharing-the-baseline-from-ci).
25+
2426
> **Note:** You don't have to pay this baseline cost on every machine. You may have CI record the baseline once and have every developer download it from GitHub Actions, so their very first `--tia` run replays immediately. See [Sharing The Baseline From CI](#sharing-the-baseline-from-ci) to set this up.
2527
2628
Every subsequent run is a **replay**. The engine compares your working tree against the baseline and re-runs only the tests affected by your changes:
@@ -76,11 +78,11 @@ Pest supports a few flags alongside `--tia`:
7678
| Flag | Behavior |
7779
|---|---|
7880
| `--tia` | Replay if a baseline graph exists, otherwise record. |
79-
| `--no-tia` | Disable TIA for this run, even if `pest()->tia()->always()` is configured. |
81+
| `--no-tia` | Disable TIA for this run, even if `pest()->tia()->locally()` is configured. |
8082
| `--tia --fresh` | Discard any existing graph and re-record from scratch. Use this after large refactors or when the graph feels stale. |
8183
| `--tia --refetch` | Discard the local graph and force a fresh CI baseline fetch, bypassing the 24-hour cooldown that otherwise applies after a fetch found no baseline. |
8284
| `--tia --filtered` | Narrow PHPUnit to only the affected test files rather than loading all tests and replaying cached results for unaffected ones. Automatically disabled when you pass an explicit test path or a `--coverage` report; if no tests are affected, Pest stops and tells you so. |
83-
| `--tia --locally` | Equivalent to `pest()->tia()->always()->locally()` — run TIA automatically on local machines but skip on CI. |
85+
| `--tia --locally` | Equivalent to `pest()->tia()->locally()` — run TIA automatically on local machines but skip on CI. |
8486
| `--tia --baselined` | Opt in to fetching the shared baseline from CI when no local graph exists or the local graph drifts. |
8587
| `--baseline` | Print the absolute path of this project's TIA storage directory and exit. Designed for CI uploads — see [Sharing The Baseline From CI](#sharing-the-baseline-from-ci). |
8688

@@ -100,6 +102,8 @@ Each enabling flag has an environment variable equivalent, useful for CI matrice
100102

101103
Recording the baseline locally may take minutes on large suites. Instead, you may have CI record it once per merge to `main`, and every developer downloads the result.
102104

105+
Recording the baseline is the one job where `--tia` belongs on CI. It should live in a workflow of its own — the pipeline that tests your pull requests and commits continues to run the full suite with `./vendor/bin/pest --ci`, without any TIA flags.
106+
103107
Baseline fetching is opt-in. You may enable it with `--tia --baselined` on the command line, the `PEST_TIA_BASELINED=1` environment variable, or — preferred for teams — by calling `pest()->tia()->baselined()` in `tests/Pest.php`. Once enabled, when Pest detects no local graph (or the local graph is out of date) it uses GitHub's CLI to download the latest successful run of a `tia-baseline.yml` workflow's `pest-tia-baseline` artifact. Pest then validates the fetched graph against your project state — if it matches, it is adopted. Otherwise, it is discarded and a local rebuild proceeds.
104108

105109
> **Note:** Baseline fetching relies on the [GitHub CLI](https://cli.github.com/) (`gh`), so it is only available for repositories hosted on GitHub, and `gh` must be installed and authenticated (`gh auth login`) on the machine doing the fetch. When a fetch cannot proceed — missing CLI, no authentication, a network or rate-limit error, or no baseline artifact yet — Pest reports the reason and falls back to recording a local baseline.
@@ -154,13 +158,24 @@ You may configure TIA behavior in `tests/Pest.php` via `pest()->tia()`:
154158

155159
```php
156160
pest()->tia()
157-
->always() // run TIA on every invocation, no --tia flag needed
158-
->locally() // restrict always() to local environments only
161+
->locally() // run TIA on every local invocation, no --tia flag needed
159162
->baselined() // fetch the shared baseline from CI when no local graph exists
160163
->filtered(); // narrow PHPUnit to only affected test files
161164
```
162165

163-
**`always()`** activates TIA for every `pest` run without requiring the `--tia` flag. Pair it with **`locally()`** to restrict that behavior to local machines — when you pass the `--ci` flag, TIA is skipped automatically. An explicit `--tia` on the command line always takes effect regardless, and `--no-tia` will disable it for a single run.
166+
Typically, you should reach for **`locally()`**. It activates TIA for every `pest` run without requiring the `--tia` flag, and restricts that behavior to local machines — on CI, or whenever you pass the `--ci` flag, TIA is skipped automatically, so your pipeline keeps running the full suite:
167+
168+
```php
169+
pest()->tia()->locally();
170+
```
171+
172+
Alternatively, **`always()`** activates TIA everywhere, CI included. The two are alternatives rather than a pair, so there is no need to chain them — and because the Tia Engine is built for local development, `locally()` is the option you should prefer:
173+
174+
```php
175+
pest()->tia()->always();
176+
```
177+
178+
In either case, an explicit `--tia` on the command line always takes effect, and `--no-tia` will disable TIA for a single run.
164179

165180
**`filtered()`** enables filtered mode, equivalent to `--tia --filtered`. In this mode, Pest narrows PHPUnit to only the affected test files rather than loading the full suite and replaying cached results for unaffected tests:
166181

0 commit comments

Comments
 (0)