ci: stop the test cache self-invalidating, and drop duplicate PR runs - #30
Merged
Conversation
`test` listed `$TURBO_ROOT$/plugins/**` as an input, which pulled each
plugin's *run artefacts* into the hash — vitest's
`node_modules/.vite/vitest/*/results.json` and turbo's own
`.turbo/turbo-test.log`. Running the suite rewrote those files, so the next
run hashed differently and all 43 packages missed. Running tests was what
invalidated the test cache; it never settled above 2/43. The files are
gitignored, but explicit input globs don't consult gitignore the way
`$TURBO_DEFAULT$` does, so `git status` stayed clean while the hash moved.
Negative globs don't help here (they resolve per-package and the paths are
cross-package), so the directory glob is replaced with a whitelist of the
source shapes a plugin actually has — markdown, entry `.js`, package.json,
and the eight content directories. Artefact directories can no longer match.
Dependency semantics are unchanged: editing any plugin source still
invalidates every dependent package's test.
pnpm test, twice, no edits between: 2/43 cached, 49s → 43/43, 0.3s
editing plugins/narrator/PLUGIN.md: 2/43 cached (correctly invalidated)
CI now caches `.turbo/cache` so it can benefit from that at all — it was
running cold every time.
Also scope the CI push trigger to main. A `*-dev` branch with an open PR ran
the same commit twice, because the PR ref and the branch ref hash to
different concurrency groups and neither cancels the other.
The release workflow's macOS job gets the Electron binary cache the Windows
job already had.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CI-only change. No version bump, no release —
docs/CHANGELOG.mdand the version badges are untouched.The problem
turbo run testnever cached. Two consecutive runs with no edits in between:testlisted$TURBO_ROOT$/plugins/**as an input, which pulled each plugin's run artefacts into the hash. Diffing two run summaries:Those are vitest's result cache and turbo's own task log. Running the suite rewrites them, so the next run hashes differently and all 43 packages miss — running tests was the thing invalidating the test cache.
They are gitignored, but explicit input globs don't consult gitignore the way
$TURBO_DEFAULT$does. That's whygit statusstayed clean while the hash moved, and why this was invisible.The fix
Negative globs (
!.../node_modules/**) don't work here — inputs resolve per package and these are cross-package paths; verified, still 21/43. So the directory glob is replaced with a whitelist of the source shapes a plugin actually has: markdown, entry.js,package.json, and the eight content directories (hookslibruntimesschemasserverteststoolsui). Artefact directories can no longer match.Verification
Dependency semantics are unchanged — editing any plugin source still invalidates every dependent package's test. The full suite passed on the run that actually executed (43 successful, 0 failed).
actionlintand prettier pass.Also here
.turbo/cache. It ran cold every time, so none of the above would have reached CI otherwise.main. A*-devbranch with an open PR ran the same commit twice — the PR ref and the branch ref hash to different concurrency groups, so neither cancelled the other. Seen on the v0.0.21 release: runs30162296595(push) and30162298111(pull_request), same commit, ~5.5 min each. The PR run covers dev branches; the push trigger stays as the post-merge guard on main.Expected effect
Cold on the first run either way. From the second run on, a change touching one package replays the rest from cache instead of re-running them — the 155s
Teststep and 134sBuildstep should collapse to whatever actually changed.中文摘要:纯 CI 改动,不发版。
test的 inputs 把plugins/**整个目录纳入哈希,连带 vitest 的 results.json 和 turbo 自己写的 turbo-test.log 也算了进去 —— 跑测试这个动作本身就让测试缓存失效,所以一直是 2/43。改成源文件白名单后 43/43 全命中(49s → 0.3s),且改插件源码仍能正确失效。另外给 CI 加了.turbo/cache缓存、把 push 触发收到只剩 main(消除 PR 双跑),并给 release 的 macOS job 补上 Windows job 早就有的 Electron 缓存。