* feat(tia): make default watch fallbacks configurable
* test(tia): cover driverless fallback and update suite snapshots
* fix: align help types and coverage guards with PHPStan
---------
Co-authored-by: Punyapal Shah <mrpunyapal@gmail.com>
* fix(tia): link files a test reads as text, not only files it executes
* fix(tia): report dangling symlinks as links while reads are captured
`is_link()` stats with STREAM_URL_STAT_LINK | STREAM_URL_STAT_QUIET.
The `file_exists()` precheck in `ReadCapture::url_stat()` follows the
link, so a dangling symlink returned false before reaching `lstat()`,
and `is_link()` reported false while a test recorded.
Handle STREAM_URL_STAT_LINK first and always answer it through
`lstat()`. A quiet stat of a path that is neither a link nor a file
still returns false without a warning.
The regression test covers a link to an existing file and a dangling
link.
* test(tia): skip the read-capture feature tests without a coverage driver
The fixture runs record a graph from coverage, so with CI's
`coverage: none` all five cases failed. Skip them when
`Coverage::isAvailable()` is false, as CoveragePiggyback does.
* chore: style
* Refresh read capture test snapshots
---------
Co-authored-by: Punyapal Shah <53343069+MrPunyapal@users.noreply.github.com>
Co-authored-by: Punyapal Shah <mrpunyapal@gmail.com>
* fix: check each target in negated toUse
A skipped class in expect([...]) made the positive rule fail,
so the negation passed even when another class used the dependency.
Fixes#1751
* test: update snapshots for notToUse
Negated toUse coverage adds 6 tests and 24 assertions,
so the success snapshot and parallel totals were stale.
---------
Co-authored-by: Tiago Santos <tsantos@lynixt.pt>
Co-authored-by: Punyapal Shah <mrpunyapal@gmail.com>
The GitLab baseline lookup listed the project's 100 most recent
successful jobs and filtered them client-side by name and ref. GitLab's
jobs endpoint has no server-side ref or name filter, so that single page
is the entire search space -- and on a busy project it covers very little
wall-clock time. On a self-hosted instance the window measured 82
minutes, while baselines were published roughly once a day. The lookup
therefore returned null almost always, and every developer silently fell
back to recording a local baseline.
Query pipelines instead, which does filter by ref and status server-side,
then walk the default branch's successful pipelines newest-first until
one contains a successful job with the configured name.
This also aligns the lookup with what the download actually resolves.
`glab job artifact <ref> <job>` reads from the latest successful
*pipeline* for the ref, so a successful job inside a failed pipeline was
never downloadable even when the old lookup returned it.
* fix(tia): show git's error instead of asking to install git when it fails
* fix(tia): detect a missing git binary with ExecutableFinder
Only report MissingDependency when git can't be found on PATH or there
is no repository. Any other failure shows git's error output, or the
exit code when git printed nothing.
---------
Co-authored-by: Mohannad Elemary <20709195+MohannadElemary@users.noreply.github.com>
Co-authored-by: Punyapal Shah <53343069+MrPunyapal@users.noreply.github.com>
* fix(tia): detect renames in both porcelain status columns
git status --porcelain emits worktree renames as " R new\0old". The parser only checked the first status column, so the paired source path was read as a standalone record and truncated by substr(3). The broken path then made git check-ignore exit 128, which surfaced as MissingDependency("Tia mode", "git").
* Fix worktree rename test style
---------
Co-authored-by: Punyapal Shah <53343069+MrPunyapal@users.noreply.github.com>
Co-authored-by: Punyapal Shah <mrpunyapal@gmail.com>
* Add default failure messages to the remaining string expectations
* test: update parallel snapshot count for the new default-message cases
---------
Co-authored-by: Punyapal Shah <mrpunyapal@gmail.com>
* fix(tia): drop the coverage cache on structural drift
A coverage run cannot rebuild the graph, so a composer.lock change left the previous coverage.bin.gz in place and the next merge failed.
* style(tests): satisfy rector dry-run
* style: remove the source comment
Repository instructions prohibit source comments.
---------
Co-authored-by: Tiago Santos <tsantos@lynixt.pt>
* fix(tia): skip locally() when the process is on CI
locally() only looked at --ci, so a CI job that followed the docs and
ran plain pest replayed cached results.
Fixes#1970
* test(tia): clear CI variables so the local assertion passes on CI
* test: update snapshots for TIA CI detection
---------
Co-authored-by: Tiago Santos <tsantos@lynixt.pt>
Co-authored-by: Punyapal Shah <mrpunyapal@gmail.com>
A fetched baseline can be recorded at a commit that the local clone does not have, or that the current branch does not contain. The changed files cannot be listed then, and the replay treated the changed set as empty: every test was replayed as passed.
Stop with an error that names the commit and says how to recover.
* fix: allow --init without a tests directory
Boot aborted before TIA state was registered, and shutdown then
tried to construct the plugin. That hid the real error behind
"State cannot be resolved" on a fresh install.
Closes#1934
* fix: detect --init anywhere in the arguments
Flags before --init were still treated as a normal run and failed when tests/ did not exist.
* fix: drop duplicate Kernel::$booted and share --init check
5.3.1 already gates plugin termination on boot, so the rebase must
not declare $booted again. --init and --init=value now share
HandleArguments::hasArgument, and the success snapshot includes
the new init tests.
* test: fix init suite expectations
Parallel total omitted the four --init tests, which
failed the success snapshot. Rector requires toBeFile().
---------
Co-authored-by: Tiago Santos <tsantos@lynixt.pt>
* refactor: extract shared CI detection utility
Consolidate duplicated CI environment detection logic from
Snapshot and BaselineSync into a shared Pest\Support\Ci class.
This reduces duplication and provides a single source of truth
for CI detection, including comprehensive environment variable
checks for all major CI providers.
* fix(tia): persist state on detached HEAD
Allow detached checkouts to write, delete, and rebuild TIA state so
baseline publishers and local detached workflows produce a usable graph.
Resolve the writable baseline from the Git branch, CI branch metadata, or
a stable workspace key. Keep the default branch as the read fallback so
local workspaces can use a published baseline without changing it.
Extract BaselineSync into a provider architecture with an abstract
BaseRemote class and concrete GitHubRemote/GitLabRemote implementations.
GitLab support uses the glab CLI to fetch TIA baselines from CI
pipelines. The GitLabRemote queries the GitLab API for the latest
successful job matching the configured name on the default branch,
then downloads artifacts via `glab job artifact`.
Self-hosted GitLab instances are supported automatically: any
non-GitHub remote is detected as GitLab when the glab CLI is
installed, with authentication validated at fetch time.
Key changes:
- BaseRemote abstract class holds shared logic: CLI existence/auth
checks, error classification, git remote URL parsing, and default
branch resolution
- GitHubRemote extracts existing gh CLI logic unchanged
- GitLabRemote adds glab CLI support with default job name
`tia-baseline`, configurable via `->baselined(job: "name")`
- BaselineSync becomes a provider-agnostic orchestrator that iterates
registered remotes to detect the matching CI provider
- Configuration::baselined() accepts optional `job` parameter for
GitLab job name customization
- GitLab job query filters by both job name and default branch ref
to ensure cache key matches downloaded artifact
When phpunit.xml has <coverage> and <source> sections, PHPUnit
auto-initializes its code coverage driver which takes over
xdebug's coverage APIs. TIA's recorder then gets empty data
from xdebug_get_code_coverage(), resulting in zero recorded
edges and no graph being saved.
Inject --no-coverage into the arguments when TIA enters its
own recording mode (not piggybacking on an explicit coverage
report). This tells PHPUnit to ignore XML-configured coverage
reports, leaving xdebug free for TIA's per-test recording.
Having <coverage> and <source> in phpunit.xml is standard for
any project that generates coverage reports. Without this fix,
users must manually pass --no-coverage alongside --tia, which
is an unnecessary footgun.