Skip to content

fix(docs): hash the docs tree in every task that reads it - #3553

Merged
yannickmonney merged 5 commits into
mainfrom
fix/docs-readers-hash-docs-tree
Sep 27, 2026
Merged

yannickmonney merged 5 commits into
mainfrom
fix/docs-readers-hash-docs-tree

Conversation

@yannickmonney

@yannickmonney yannickmonney commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Found on #3517. That PR edited three pages under docs/, and its Unit job replayed the docs tests from the Turbo cache (@tale/docs:test → cache hit, replaying logs 95a3803dc49254bd). Turbo builds a task's hash from the files in that task's own workspace. The root docs/ tree and the root README*.md files are not in any workspace. So a change to them leaves every task hash unchanged, and a broken docs page can pass CI.

The same gap affected every cached task that reads the docs tree:

Task Reads outside its workspace
@tale/docs#test every page (structural suite, i18n docs scan, walk-content), docs/nav.json, docs/redirects.json, root README*.md (readme.test.ts)
@tale/docs#build (and test:prerender, which depends on it) every page (import.meta.glob, search index, prerender), nav.json, redirects.json
@tale/docs#typecheck, @tale/docs#lint (type-aware) nav.json and redirects.json, imported by lib/content/nav.ts and lib/redirects.ts
@tale/cli#test docs/{en,de,fr}/self-hosted/install/cli-install.md (platform-docs.test.ts parses the JSON examples)

services/platform/tests/manual/scripts/check-guide.ts and bun run lint:manual are not Turbo tasks, so they never replay from the cache. Neither reads docs/.

Change

  • services/docs/turbo.json and tools/cli/turbo.json are workspace configs that extend the root config ("extends": ["//"]). They add $TURBO_ROOT$/… globs to the inputs of the tasks listed above and keep $TURBO_DEFAULT$. Everything else is inherited from the root task definitions: dependsOn, outputs and env. I tested a root-level @tale/docs#test entry first; it replaces the whole test definition (the dry run showed dependsOn: []), so it would have been a second copy of that definition.
  • Guards. services/docs/tests/turbo-inputs.test.ts runs turbo run … --dry=json and asserts that every file each @tale/docs task reads is hashed: every page walkDocs() finds, the two JSON maps, and the READMEs readme.test.ts compares. It also checks that the workspace's own package.json is still hashed, so dropping $TURBO_DEFAULT$ fails too. platform-docs.test.ts does the same for @tale/cli#test and the install pages it parses. Each guard lives in the workspace whose turbo.json it checks, so editing that config changes the guard's own hash and re-runs it.
  • README_PATTERN moved into tests/lib/paths.ts, so the README test and the guard use the same pattern.
  • Docs: .agents/repo.md ("A green check is not always a run") now names the fix and the guards, and says that the services' i18n tests reading the packages/ui catalogs fall under the packages/ gap below. services/docs/tests/AGENTS.md lists the new check. tests/manual/reference/automation.md has a row for it.

Verification

  • The guards fail without the change. With services/docs/turbo.json removed, all 4 docs cases fail ("@tale/docs#test reads 431 file(s) turbo does not hash…"). With tools/cli/turbo.json removed, the CLI case fails and lists the three install pages. Both pass with the change.
  • Hash probe (turbo --dry=json) with the change:
    • Editing docs/en/index.md changes the hashes of docs test, build and test:prerender.
    • Editing a cli-install.md also changes @tale/cli#test.
    • Editing nav.json also changes docs typecheck and lint.
    • Editing README.de.md changes docs test only.
    • On main, none of these edits changed any hash.
  • bunx turbo run test --filter=@tale/docs --force: 35 files, 170 tests pass, including the guard. So running Turbo from inside a Turbo task works.
  • bunx turbo run test --filter=@tale/cli --force -- src/lib/config/platform-docs.test.ts: 7 pass.
  • Also ran: type-aware oxlint on the changed files, tsc --noEmit in services/docs and tools/cli, bun run knip:check, bun run lint:manual, and oxfmt (pre-commit).
  • CI check on a docs-only change. Commit f068e5f only added a trailing blank line to docs/en/index.md, and 598030f reverts it. In the Unit job for that probe commit (log), @tale/docs:test shows cache miss, executing d71f1eec9cd26f7d and runs all 35 test files. In the previous run the same task's hash was 3a9b3258bc0605ee. @tale/cli:test (same hash 38179d9656d9ff35), @tale/platform:test, @tale/web:test and @tale/ui:test replayed from the cache, which is correct: that edit is not one of their inputs. The Build job's @tale/docs:build also shows cache miss, executing. Before this change, fix(platform): re-target the pending review when the reviewer changes #3517's docs edits produced cache hit, replaying logs for @tale/docs:test.

Left open

  • An edit under packages/ leaves every dependent workspace's test, typecheck and lint hash unchanged, because none of those tasks depends on ^…. A dry-run probe showed it: editing packages/ui/src/i18n/locales.ts left the hashes of @tale/web#test, @tale/platform#test/typecheck/lint and @tale/docs#test unchanged. The docs i18n test also reads packages/ui/src/i18n/messages. .agents/repo.md now describes this gap. Fixing it means adding a transit-style ^ dependency to those tasks, which re-runs consumers' suites on every package edit. That CI-cost decision needs its own task.
  • Other tasks read root files outside their workspace too, for example CLI tests that read the root compose*.yml. They were not audited here.
  • On a docs-only PR, the E2E workflow's path filter skips the docs Playwright smoke suite, because docs/** is not in e2e.yml's paths. The Build workflow's Docs container test does run.

Turbo keys a task's cache on its own workspace's files, and the root
docs/ tree and READMEs belong to none, so a docs-only change replayed
@tale/docs:test (and the docs build) from the cache: a broken page
could pass CI.

services/docs/turbo.json gives the docs test and build tasks the docs
tree (the test also the root READMEs) and typecheck/lint the nav and
redirect maps they import; tools/cli/turbo.json gives the CLI tests the
install pages they parse. Both extend the root config, so everything
else about those tasks is inherited. A guard in each suite asks
`turbo --dry=json` whether every file the task reads is hashed.
The CLI workflow runs the unit suite on Windows and macOS too: spawn
turbo through `bun x` and compare turbo's `/`-separated input keys.
A trailing blank line on the docs index, reverted in the next commit:
CI on this commit must execute @tale/docs:test, not replay it.
@yannickmonney

Copy link
Copy Markdown
Contributor Author

Docs-only probe result: on f068e5f, whose only change was a trailing blank line in docs/en/index.md, the Unit job (log) shows @tale/docs:test → cache miss, executing d71f1eec9cd26f7d, and all 35 test files passed. The previous commit's hash was 3a9b3258bc0605ee. @tale/cli:test, @tale/platform:test, @tale/web:test and @tale/ui:test replayed from the cache as expected. @tale/docs:build also shows cache miss, executing. 598030f reverts the probe, so the net diff does not touch docs/.

@yannickmonney
yannickmonney merged commit 0d42447 into main Sep 27, 2026
56 checks passed
@yannickmonney
yannickmonney deleted the fix/docs-readers-hash-docs-tree branch September 27, 2026 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant