@codyswann/lisa 5.4.0 → 5.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -3
- package/all/copy-contents/gitignore +16 -0
- package/all/copy-contents/scripts/lisa-mutation.sh +4 -6
- package/all/copy-overwrite/scripts/fetch-test-access-map.d.mts +71 -0
- package/all/copy-overwrite/scripts/fetch-test-access-map.mjs +674 -0
- package/all/copy-overwrite/scripts/lib/affected-tests.mjs +818 -0
- package/all/copy-overwrite/scripts/lib/automation-provenance-local.mjs +22 -1
- package/all/copy-overwrite/scripts/lib/build-marker.mjs +410 -0
- package/all/copy-overwrite/scripts/lib/gate-pass-cache.mjs +537 -0
- package/all/copy-overwrite/scripts/lib/kill-marks.mjs +1 -2
- package/all/copy-overwrite/scripts/lib/lisa-cleanup-sweep-processes.mjs +3 -4
- package/all/copy-overwrite/scripts/lib/npm-update-controller-broker.mjs +1 -1
- package/all/copy-overwrite/scripts/lib/npm-update-gate-hooks.mjs +2 -1
- package/all/copy-overwrite/scripts/lib/npm-update-helper-inventory.mjs +8 -1
- package/all/copy-overwrite/scripts/lib/npm-update-hosted-hook.mjs +1 -1
- package/all/copy-overwrite/scripts/lib/npm-update-tool-launcher.mjs +1 -1
- package/all/copy-overwrite/scripts/lib/push-admission.mjs +158 -0
- package/all/copy-overwrite/scripts/lib/push-gate-defaults.d.mts +34 -0
- package/all/copy-overwrite/scripts/lib/push-gate-defaults.mjs +147 -0
- package/all/copy-overwrite/scripts/lib/push-timing.mjs +323 -0
- package/all/copy-overwrite/scripts/lib/rspec-selection.mjs +672 -0
- package/all/copy-overwrite/scripts/lisa-affected-tests.mjs +566 -0
- package/all/copy-overwrite/scripts/lisa-gates.mjs +29 -0
- package/all/copy-overwrite/scripts/lisa-lint-staged-preflight.mjs +10 -1
- package/all/copy-overwrite/scripts/lisa-push-timing-report.mjs +153 -0
- package/all/copy-overwrite/scripts/lisa-rspec-select.mjs +982 -0
- package/all/copy-overwrite/scripts/lisa-run-gates.mjs +231 -6
- package/all/copy-overwrite/scripts/npm-updater-helper-graph.json +105 -17
- package/all/deletions.json +11 -2
- package/cdk/create-only/vitest.config.local.ts +1 -7
- package/cdk/package-lisa/package.lisa.json +4 -4
- package/dist/cli/admit-cmd.d.ts +21 -0
- package/dist/cli/admit-cmd.d.ts.map +1 -0
- package/dist/cli/admit-cmd.js +142 -0
- package/dist/cli/admit-cmd.js.map +1 -0
- package/dist/cli/check-cmd.d.ts +72 -0
- package/dist/cli/check-cmd.d.ts.map +1 -0
- package/dist/cli/check-cmd.js +316 -0
- package/dist/cli/check-cmd.js.map +1 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +6 -4
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/lisa-test-run-admission.d.ts +18 -0
- package/dist/cli/lisa-test-run-admission.d.ts.map +1 -0
- package/dist/cli/lisa-test-run-admission.js +62 -0
- package/dist/cli/lisa-test-run-admission.js.map +1 -0
- package/dist/cli/lisa-test-run-payload.d.ts +37 -0
- package/dist/cli/lisa-test-run-payload.d.ts.map +1 -0
- package/dist/cli/lisa-test-run-payload.js +55 -0
- package/dist/cli/lisa-test-run-payload.js.map +1 -0
- package/dist/cli/lisa-test-run-shard-files.d.ts +89 -0
- package/dist/cli/lisa-test-run-shard-files.d.ts.map +1 -0
- package/dist/cli/lisa-test-run-shard-files.js +239 -0
- package/dist/cli/lisa-test-run-shard-files.js.map +1 -0
- package/dist/cli/lisa-test-run-shard.d.ts +6 -2
- package/dist/cli/lisa-test-run-shard.d.ts.map +1 -1
- package/dist/cli/lisa-test-run-shard.js +25 -13
- package/dist/cli/lisa-test-run-shard.js.map +1 -1
- package/dist/cli/lisa-test-run.d.ts +1 -1
- package/dist/cli/lisa-test-run.d.ts.map +1 -1
- package/dist/cli/lisa-test-run.js +47 -10
- package/dist/cli/lisa-test-run.js.map +1 -1
- package/dist/cli/update-check-hook.d.ts.map +1 -1
- package/dist/cli/update-check-hook.js +3 -0
- package/dist/cli/update-check-hook.js.map +1 -1
- package/dist/configs/vitest/base.d.ts +58 -135
- package/dist/configs/vitest/base.d.ts.map +1 -1
- package/dist/configs/vitest/base.js +76 -228
- package/dist/configs/vitest/base.js.map +1 -1
- package/dist/configs/vitest/cdk.d.ts.map +1 -1
- package/dist/configs/vitest/cdk.js +3 -2
- package/dist/configs/vitest/cdk.js.map +1 -1
- package/dist/configs/vitest/coverage-include-global-setup.d.ts.map +1 -1
- package/dist/configs/vitest/coverage-include-global-setup.js +3 -4
- package/dist/configs/vitest/coverage-include-global-setup.js.map +1 -1
- package/dist/configs/vitest/coverage-reports-directory.d.ts +27 -5
- package/dist/configs/vitest/coverage-reports-directory.d.ts.map +1 -1
- package/dist/configs/vitest/coverage-reports-directory.js +47 -10
- package/dist/configs/vitest/coverage-reports-directory.js.map +1 -1
- package/dist/configs/vitest/harper-fabric.d.ts.map +1 -1
- package/dist/configs/vitest/harper-fabric.js +3 -2
- package/dist/configs/vitest/harper-fabric.js.map +1 -1
- package/dist/configs/vitest/nestjs.d.ts.map +1 -1
- package/dist/configs/vitest/nestjs.js +3 -2
- package/dist/configs/vitest/nestjs.js.map +1 -1
- package/dist/configs/vitest/phaser.d.ts.map +1 -1
- package/dist/configs/vitest/phaser.js +3 -2
- package/dist/configs/vitest/phaser.js.map +1 -1
- package/dist/configs/vitest/refusal-announcement.d.ts +51 -0
- package/dist/configs/vitest/refusal-announcement.d.ts.map +1 -0
- package/dist/configs/vitest/refusal-announcement.js +97 -0
- package/dist/configs/vitest/refusal-announcement.js.map +1 -0
- package/dist/configs/vitest/socket-safe-temp-base.d.ts +3 -4
- package/dist/configs/vitest/socket-safe-temp-base.d.ts.map +1 -1
- package/dist/configs/vitest/socket-safe-temp-base.js +7 -6
- package/dist/configs/vitest/socket-safe-temp-base.js.map +1 -1
- package/dist/configs/vitest/typescript.d.ts.map +1 -1
- package/dist/configs/vitest/typescript.js +3 -2
- package/dist/configs/vitest/typescript.js.map +1 -1
- package/dist/core/admission-decision.d.ts +110 -0
- package/dist/core/admission-decision.d.ts.map +1 -0
- package/dist/core/admission-decision.js +91 -0
- package/dist/core/admission-decision.js.map +1 -0
- package/dist/core/admission-lock.d.ts +69 -0
- package/dist/core/admission-lock.d.ts.map +1 -0
- package/dist/core/admission-lock.js +278 -0
- package/dist/core/admission-lock.js.map +1 -0
- package/dist/core/admission-settings.d.ts +69 -0
- package/dist/core/admission-settings.d.ts.map +1 -0
- package/dist/core/admission-settings.js +204 -0
- package/dist/core/admission-settings.js.map +1 -0
- package/dist/core/admission-state.d.ts +50 -0
- package/dist/core/admission-state.d.ts.map +1 -0
- package/dist/core/admission-state.js +168 -0
- package/dist/core/admission-state.js.map +1 -0
- package/dist/core/admission.d.ts +70 -0
- package/dist/core/admission.d.ts.map +1 -0
- package/dist/core/admission.js +205 -0
- package/dist/core/admission.js.map +1 -0
- package/dist/core/lisa-owned-hash-ledger.d.ts.map +1 -1
- package/dist/core/lisa-owned-hash-ledger.js +318 -0
- package/dist/core/lisa-owned-hash-ledger.js.map +1 -1
- package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
- package/dist/core/project-config-push-gate.d.ts +66 -0
- package/dist/core/project-config-push-gate.d.ts.map +1 -0
- package/dist/core/project-config-push-gate.js +82 -0
- package/dist/core/project-config-push-gate.js.map +1 -0
- package/dist/core/project-config.d.ts +4 -0
- package/dist/core/project-config.d.ts.map +1 -1
- package/dist/core/project-config.js +14 -9
- package/dist/core/project-config.js.map +1 -1
- package/dist/core/upstream-evidence-manifest.d.ts.map +1 -1
- package/dist/core/upstream-evidence-manifest.js +197 -123
- package/dist/core/upstream-evidence-manifest.js.map +1 -1
- package/expo/package-lisa/package.lisa.json +2 -2
- package/harper-fabric/package-lisa/package.lisa.json +4 -4
- package/nestjs/create-only/vitest.config.local.ts +1 -7
- package/nestjs/package-lisa/package.lisa.json +4 -4
- package/npm-package/package-lisa/package.lisa.json +4 -4
- package/package.json +12 -11
- package/phaser/package-lisa/package.lisa.json +4 -4
- package/plugins/lisa/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa/.codex-plugin/skills/lisa-drive-pr-to-merge/SKILL.md +16 -3
- package/plugins/lisa/.codex-plugin/skills/lisa-git-submit-pr/SKILL.md +1 -1
- package/plugins/lisa/.codex-plugin/skills/lisa-implement/SKILL.md +1 -1
- package/plugins/lisa/skills/lisa-drive-pr-to-merge/SKILL.md +16 -3
- package/plugins/lisa/skills/lisa-git-submit-pr/SKILL.md +1 -1
- package/plugins/lisa/skills/lisa-implement/SKILL.md +1 -1
- package/plugins/lisa-agy/plugin.json +1 -1
- package/plugins/lisa-agy/skills/lisa-drive-pr-to-merge/SKILL.md +16 -3
- package/plugins/lisa-agy/skills/lisa-git-submit-pr/SKILL.md +1 -1
- package/plugins/lisa-agy/skills/lisa-implement/SKILL.md +1 -1
- package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-agy/plugin.json +1 -1
- package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-copilot/skills/lisa-drive-pr-to-merge/SKILL.md +16 -3
- package/plugins/lisa-copilot/skills/lisa-git-submit-pr/SKILL.md +1 -1
- package/plugins/lisa-copilot/skills/lisa-implement/SKILL.md +1 -1
- package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cursor/skills/lisa-drive-pr-to-merge/SKILL.md +16 -3
- package/plugins/lisa-cursor/skills/lisa-git-submit-pr/SKILL.md +1 -1
- package/plugins/lisa-cursor/skills/lisa-implement/SKILL.md +1 -1
- package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-devin/skills/lisa-drive-pr-to-merge/SKILL.md +16 -3
- package/plugins/lisa-devin/skills/lisa-git-submit-pr/SKILL.md +1 -1
- package/plugins/lisa-devin/skills/lisa-implement/SKILL.md +1 -1
- package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-agy/plugin.json +1 -1
- package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-agy/plugin.json +1 -1
- package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-agy/plugin.json +1 -1
- package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-agy/plugin.json +1 -1
- package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-agy/plugin.json +1 -1
- package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-agy/plugin.json +1 -1
- package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/src/base/skills/lisa-drive-pr-to-merge/SKILL.md +16 -3
- package/plugins/src/base/skills/lisa-git-submit-pr/SKILL.md +1 -1
- package/plugins/src/base/skills/lisa-implement/SKILL.md +1 -1
- package/rails/copy-overwrite/Gemfile.lisa +8 -0
- package/rails/copy-overwrite/lefthook.yml +25 -11
- package/rails/copy-overwrite/scripts/lisa-rails-gates.mjs +686 -0
- package/rails/copy-overwrite/scripts/lisa-rspec-shards.mjs +2 -2
- package/rails/copy-overwrite/scripts/lisa_crystalball_recorder.rb +239 -0
- package/rails/copy-overwrite/scripts/lisa_rspec_partial_coverage.rb +83 -0
- package/scripts/build-unless-marked.mjs +83 -0
- package/scripts/check-plugins-sync.sh +22 -5
- package/scripts/classify-markdown-assertions.mjs +141 -0
- package/scripts/integration-shard-build.mjs +143 -0
- package/scripts/lib/history-scanner-suites.mjs +19 -0
- package/scripts/lib/markdown-assertions/classify.mjs +289 -0
- package/scripts/lib/markdown-assertions/context.mjs +53 -0
- package/scripts/lib/markdown-assertions/corpus.mjs +222 -0
- package/scripts/lib/markdown-assertions/manifest-cull.mjs +86 -0
- package/scripts/lib/markdown-assertions/record-setup.mjs +265 -0
- package/scripts/lib/markdown-assertions/record.mjs +115 -0
- package/scripts/lib/markdown-assertions/record.vitest.config.mjs +24 -0
- package/scripts/lib/markdown-assertions/sites.mjs +273 -0
- package/scripts/lib/markdown-assertions/test-cull.mjs +768 -0
- package/scripts/lib/markdown-assertions/tokens.mjs +158 -0
- package/scripts/lib/shell-guard-trace.mjs +6 -0
- package/scripts/lib/test-access-map-setup.mjs +40 -0
- package/scripts/lib/test-access-map-tracer.mjs +205 -0
- package/scripts/lib/test-access-map.d.mts +72 -0
- package/scripts/lib/test-access-map.mjs +395 -0
- package/scripts/lib/test-timings-reporter.d.mts +17 -0
- package/scripts/lib/test-timings-reporter.mjs +99 -0
- package/scripts/plan-integration-shards.mjs +300 -0
- package/scripts/test-timing-report.d.mts +41 -0
- package/scripts/test-timing-report.mjs +361 -0
- package/scripts/two-channel-couplings.json +132 -36
- package/scripts/verify-npm-advisories-4333.mjs +3 -12
- package/typescript/copy-overwrite/.prettierignore +12 -0
- package/typescript/create-only/vitest.config.local.ts +1 -7
- package/typescript/package-lisa/package.lisa.json +4 -4
- package/all/copy-overwrite/scripts/lisa-scratch-run.sh +0 -1078
- package/dist/cli/lisa-test-run-bootstrap.d.ts +0 -3
- package/dist/cli/lisa-test-run-bootstrap.d.ts.map +0 -1
- package/dist/cli/lisa-test-run-bootstrap.js +0 -229
- package/dist/cli/lisa-test-run-bootstrap.js.map +0 -1
- package/dist/cli/lisa-test-run-ipc.d.ts +0 -49
- package/dist/cli/lisa-test-run-ipc.d.ts.map +0 -1
- package/dist/cli/lisa-test-run-ipc.js +0 -226
- package/dist/cli/lisa-test-run-ipc.js.map +0 -1
- package/dist/cli/lisa-test-run-process-group.d.ts +0 -30
- package/dist/cli/lisa-test-run-process-group.d.ts.map +0 -1
- package/dist/cli/lisa-test-run-process-group.js +0 -140
- package/dist/cli/lisa-test-run-process-group.js.map +0 -1
- package/dist/cli/lisa-test-run-reaper.d.ts +0 -3
- package/dist/cli/lisa-test-run-reaper.d.ts.map +0 -1
- package/dist/cli/lisa-test-run-reaper.js +0 -195
- package/dist/cli/lisa-test-run-reaper.js.map +0 -1
- package/dist/cli/lisa-test-run-runtime.d.ts +0 -46
- package/dist/cli/lisa-test-run-runtime.d.ts.map +0 -1
- package/dist/cli/lisa-test-run-runtime.js +0 -123
- package/dist/cli/lisa-test-run-runtime.js.map +0 -1
- package/dist/cli/lisa-test-run-supervisor.d.ts +0 -13
- package/dist/cli/lisa-test-run-supervisor.d.ts.map +0 -1
- package/dist/cli/lisa-test-run-supervisor.js +0 -265
- package/dist/cli/lisa-test-run-supervisor.js.map +0 -1
- package/dist/configs/vitest/fleet-admission-global-setup.d.ts +0 -34
- package/dist/configs/vitest/fleet-admission-global-setup.d.ts.map +0 -1
- package/dist/configs/vitest/fleet-admission-global-setup.js +0 -123
- package/dist/configs/vitest/fleet-admission-global-setup.js.map +0 -1
- package/dist/configs/vitest/fleet-admission.d.ts +0 -129
- package/dist/configs/vitest/fleet-admission.d.ts.map +0 -1
- package/dist/configs/vitest/fleet-admission.js +0 -239
- package/dist/configs/vitest/fleet-admission.js.map +0 -1
- package/dist/configs/vitest/scratch-authority.d.ts +0 -25
- package/dist/configs/vitest/scratch-authority.d.ts.map +0 -1
- package/dist/configs/vitest/scratch-authority.js +0 -107
- package/dist/configs/vitest/scratch-authority.js.map +0 -1
- package/dist/configs/vitest/scratch-bound-cleanup-programs.d.ts +0 -5
- package/dist/configs/vitest/scratch-bound-cleanup-programs.d.ts.map +0 -1
- package/dist/configs/vitest/scratch-bound-cleanup-programs.js +0 -219
- package/dist/configs/vitest/scratch-bound-cleanup-programs.js.map +0 -1
- package/dist/configs/vitest/scratch-bound-cleanup.d.ts +0 -28
- package/dist/configs/vitest/scratch-bound-cleanup.d.ts.map +0 -1
- package/dist/configs/vitest/scratch-bound-cleanup.js +0 -155
- package/dist/configs/vitest/scratch-bound-cleanup.js.map +0 -1
- package/dist/configs/vitest/scratch-bound-root-cleanup.d.ts +0 -17
- package/dist/configs/vitest/scratch-bound-root-cleanup.d.ts.map +0 -1
- package/dist/configs/vitest/scratch-bound-root-cleanup.js +0 -149
- package/dist/configs/vitest/scratch-bound-root-cleanup.js.map +0 -1
- package/dist/configs/vitest/scratch-global-setup.d.ts +0 -258
- package/dist/configs/vitest/scratch-global-setup.d.ts.map +0 -1
- package/dist/configs/vitest/scratch-global-setup.js +0 -505
- package/dist/configs/vitest/scratch-global-setup.js.map +0 -1
- package/dist/configs/vitest/scratch-leak-setup.d.ts +0 -2
- package/dist/configs/vitest/scratch-leak-setup.d.ts.map +0 -1
- package/dist/configs/vitest/scratch-leak-setup.js +0 -108
- package/dist/configs/vitest/scratch-leak-setup.js.map +0 -1
- package/dist/configs/vitest/scratch-namespace-authority.d.ts +0 -80
- package/dist/configs/vitest/scratch-namespace-authority.d.ts.map +0 -1
- package/dist/configs/vitest/scratch-namespace-authority.js +0 -291
- package/dist/configs/vitest/scratch-namespace-authority.js.map +0 -1
- package/dist/configs/vitest/scratch-owner.d.ts +0 -131
- package/dist/configs/vitest/scratch-owner.d.ts.map +0 -1
- package/dist/configs/vitest/scratch-owner.js +0 -297
- package/dist/configs/vitest/scratch-owner.js.map +0 -1
- package/dist/configs/vitest/scratch-route-profile.d.ts +0 -46
- package/dist/configs/vitest/scratch-route-profile.d.ts.map +0 -1
- package/dist/configs/vitest/scratch-route-profile.js +0 -233
- package/dist/configs/vitest/scratch-route-profile.js.map +0 -1
- package/dist/configs/vitest/scratch-run-root-compatibility.d.ts +0 -33
- package/dist/configs/vitest/scratch-run-root-compatibility.d.ts.map +0 -1
- package/dist/configs/vitest/scratch-run-root-compatibility.js +0 -137
- package/dist/configs/vitest/scratch-run-root-compatibility.js.map +0 -1
- package/dist/configs/vitest/scratch-run-root-intent.d.ts +0 -66
- package/dist/configs/vitest/scratch-run-root-intent.d.ts.map +0 -1
- package/dist/configs/vitest/scratch-run-root-intent.js +0 -183
- package/dist/configs/vitest/scratch-run-root-intent.js.map +0 -1
- package/dist/configs/vitest/scratch-setup.d.ts +0 -46
- package/dist/configs/vitest/scratch-setup.d.ts.map +0 -1
- package/dist/configs/vitest/scratch-setup.js +0 -226
- package/dist/configs/vitest/scratch-setup.js.map +0 -1
- package/dist/configs/vitest/scratch-supervision-intent.d.ts +0 -8
- package/dist/configs/vitest/scratch-supervision-intent.d.ts.map +0 -1
- package/dist/configs/vitest/scratch-supervision-intent.js +0 -125
- package/dist/configs/vitest/scratch-supervision-intent.js.map +0 -1
- package/dist/configs/vitest/scratch-supervision-protocol.d.ts +0 -12
- package/dist/configs/vitest/scratch-supervision-protocol.d.ts.map +0 -1
- package/dist/configs/vitest/scratch-supervision-protocol.js +0 -230
- package/dist/configs/vitest/scratch-supervision-protocol.js.map +0 -1
- package/dist/configs/vitest/scratch-supervision.d.ts +0 -69
- package/dist/configs/vitest/scratch-supervision.d.ts.map +0 -1
- package/dist/configs/vitest/scratch-supervision.js +0 -244
- package/dist/configs/vitest/scratch-supervision.js.map +0 -1
- package/dist/configs/vitest/scratch-sweep.d.ts +0 -66
- package/dist/configs/vitest/scratch-sweep.d.ts.map +0 -1
- package/dist/configs/vitest/scratch-sweep.js +0 -82
- package/dist/configs/vitest/scratch-sweep.js.map +0 -1
- package/dist/configs/vitest/scratch-tmpdir-trust.d.ts +0 -48
- package/dist/configs/vitest/scratch-tmpdir-trust.d.ts.map +0 -1
- package/dist/configs/vitest/scratch-tmpdir-trust.js +0 -194
- package/dist/configs/vitest/scratch-tmpdir-trust.js.map +0 -1
- package/dist/configs/vitest/scratch.d.ts +0 -19
- package/dist/configs/vitest/scratch.d.ts.map +0 -1
- package/dist/configs/vitest/scratch.js +0 -34
- package/dist/configs/vitest/scratch.js.map +0 -1
- package/dist/configs/vitest/synthesis-scratch-reclaim.d.ts +0 -86
- package/dist/configs/vitest/synthesis-scratch-reclaim.d.ts.map +0 -1
- package/dist/configs/vitest/synthesis-scratch-reclaim.js +0 -226
- package/dist/configs/vitest/synthesis-scratch-reclaim.js.map +0 -1
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Plan Lisa's sharded integration run from recorded timings (CodySwannGT/lisa#4599).
|
|
4
|
+
*
|
|
5
|
+
* `quality.yml`'s `🧮 Plan Integration-Test Shards` job runs this in Lisa's own
|
|
6
|
+
* CI when `integration_test_shards` is above 1. It finds the newest run that
|
|
7
|
+
* uploaded `test-timings-*-integration*` artifacts (#4592) through the Actions
|
|
8
|
+
* API, reads every file's duration, and assigns files to legs
|
|
9
|
+
* longest-processing-time-first: the longest remaining item goes to the leg
|
|
10
|
+
* with the least planned time. It prints each leg's planned seconds and writes
|
|
11
|
+
* the plan every leg applies through `lisa-test-run` (`LISA_TEST_SHARD_PLAN`,
|
|
12
|
+
* `src/cli/lisa-test-run-shard-files.ts`).
|
|
13
|
+
*
|
|
14
|
+
* The history-scanner suites are one item, so they land in one leg and a
|
|
15
|
+
* sharded run downloads the pinned scanner at most once: their project's
|
|
16
|
+
* global setup runs only in an invocation whose selection holds one of them.
|
|
17
|
+
* The planner still writes a plan when no timings can be found (an expired
|
|
18
|
+
* artifact, a token that cannot read the Actions API). Every file then weighs
|
|
19
|
+
* the same and the group still shares one leg, because Vitest's own
|
|
20
|
+
* `--shard` would run that global setup in every leg.
|
|
21
|
+
*
|
|
22
|
+
* Lisa-only: callers have no timings artifacts, and without this script the
|
|
23
|
+
* plan job hands their legs to the runner's own `--shard=<i>/<n>`.
|
|
24
|
+
*
|
|
25
|
+
* Usage:
|
|
26
|
+
* node scripts/plan-integration-shards.mjs --shards <n> [--repo owner/name]
|
|
27
|
+
* [--timings <downloaded artifacts>] [--out <plan.json>] [--github-output <file>]
|
|
28
|
+
* @module plan-integration-shards
|
|
29
|
+
*/
|
|
30
|
+
import { execFileSync } from "node:child_process";
|
|
31
|
+
import * as fs from "node:fs";
|
|
32
|
+
import * as os from "node:os";
|
|
33
|
+
import * as path from "node:path";
|
|
34
|
+
|
|
35
|
+
import { HISTORY_SCANNER_SUITES } from "./lib/history-scanner-suites.mjs";
|
|
36
|
+
import { invokedAsScript } from "./lib/invoked-as-script.mjs";
|
|
37
|
+
import { collectTimings } from "./test-timing-report.mjs";
|
|
38
|
+
|
|
39
|
+
/** The schema token `lisa-test-run` requires of a plan. */
|
|
40
|
+
export const SHARD_PLAN_SCHEMA = "lisa.test-shard-plan/v1";
|
|
41
|
+
|
|
42
|
+
const REPOSITORY = "CodySwannGT/lisa";
|
|
43
|
+
const ARTIFACT_NAME = /^test-timings-(\d+)-\d+-integration(?:-shard-\d+)?$/;
|
|
44
|
+
const LISTING_JQ =
|
|
45
|
+
".artifacts[] | {name, runId: .workflow_run.id, createdAt: .created_at, expired}";
|
|
46
|
+
const PAGE_SIZE = 100;
|
|
47
|
+
const MAX_PAGES = 10;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* One decimal place, so a plan prints and compares cleanly.
|
|
51
|
+
* @param {number} value - Seconds
|
|
52
|
+
* @returns {number} Rounded seconds
|
|
53
|
+
*/
|
|
54
|
+
function round(value) {
|
|
55
|
+
return Math.round(value * 10) / 10;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The median of a list, or `fallback` when it is empty.
|
|
60
|
+
* @param {ReadonlyArray<number>} values - Values
|
|
61
|
+
* @param {number} fallback - Answer for no values
|
|
62
|
+
* @returns {number} Median
|
|
63
|
+
*/
|
|
64
|
+
function median(values, fallback) {
|
|
65
|
+
if (values.length === 0) return fallback;
|
|
66
|
+
const sorted = values.toSorted((a, b) => a - b);
|
|
67
|
+
const middle = Math.floor(sorted.length / 2);
|
|
68
|
+
return sorted.length % 2 === 1
|
|
69
|
+
? (sorted[middle] ?? fallback)
|
|
70
|
+
: ((sorted[middle - 1] ?? 0) + (sorted[middle] ?? 0)) / 2;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Assign timed files and groups to shards, longest first.
|
|
75
|
+
* @param {object} input - Inputs
|
|
76
|
+
* @param {number} input.total - Shard count
|
|
77
|
+
* @param {ReadonlyArray<{ file: string, seconds: number }>} input.timings - Per-file seconds
|
|
78
|
+
* @param {ReadonlyArray<ReadonlyArray<string>>} input.groups - Files that share one leg
|
|
79
|
+
* @returns {{ schema: string, total: number, assignments: Record<string, number>, seconds: number[], defaultSeconds: number, groups: Array<{ files: string[], shard: number }> }} Plan
|
|
80
|
+
*/
|
|
81
|
+
export function planShards({ total, timings, groups }) {
|
|
82
|
+
const seconds = new Map(timings.map(entry => [entry.file, entry.seconds]));
|
|
83
|
+
const defaultSeconds = round(
|
|
84
|
+
median(
|
|
85
|
+
timings.map(entry => entry.seconds),
|
|
86
|
+
1
|
|
87
|
+
)
|
|
88
|
+
);
|
|
89
|
+
const grouped = new Set(groups.flat());
|
|
90
|
+
const items = [
|
|
91
|
+
...groups.map((files, index) => ({
|
|
92
|
+
key: `group ${index}`,
|
|
93
|
+
group: index,
|
|
94
|
+
files: [...files],
|
|
95
|
+
seconds: files.reduce(
|
|
96
|
+
(sum, file) => sum + (seconds.get(file) ?? defaultSeconds),
|
|
97
|
+
0
|
|
98
|
+
),
|
|
99
|
+
})),
|
|
100
|
+
...timings
|
|
101
|
+
.filter(entry => !grouped.has(entry.file))
|
|
102
|
+
.map(entry => ({
|
|
103
|
+
key: entry.file,
|
|
104
|
+
group: -1,
|
|
105
|
+
files: [entry.file],
|
|
106
|
+
seconds: entry.seconds,
|
|
107
|
+
})),
|
|
108
|
+
].toSorted((a, b) => b.seconds - a.seconds || a.key.localeCompare(b.key));
|
|
109
|
+
const loads = Array.from({ length: total }, () => 0);
|
|
110
|
+
const assignments = {};
|
|
111
|
+
const groupShards = groups.map(() => 1);
|
|
112
|
+
for (const item of items) {
|
|
113
|
+
const index = loads.indexOf(Math.min(...loads));
|
|
114
|
+
loads[index] = (loads[index] ?? 0) + item.seconds;
|
|
115
|
+
if (item.group >= 0) groupShards[item.group] = index + 1;
|
|
116
|
+
for (const file of item.files)
|
|
117
|
+
if (seconds.has(file)) assignments[file] = index + 1;
|
|
118
|
+
}
|
|
119
|
+
return {
|
|
120
|
+
schema: SHARD_PLAN_SCHEMA,
|
|
121
|
+
total,
|
|
122
|
+
assignments,
|
|
123
|
+
seconds: loads.map(round),
|
|
124
|
+
defaultSeconds,
|
|
125
|
+
groups: groups.map((files, index) => ({
|
|
126
|
+
files: [...files],
|
|
127
|
+
shard: groupShards[index] ?? 1,
|
|
128
|
+
})),
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* One line per shard: planned files and seconds.
|
|
134
|
+
* @param {ReturnType<typeof planShards>} plan - Plan
|
|
135
|
+
* @returns {string[]} Lines
|
|
136
|
+
*/
|
|
137
|
+
export function formatPlan(plan) {
|
|
138
|
+
return plan.seconds.map((seconds, index) => {
|
|
139
|
+
const files = Object.values(plan.assignments).filter(
|
|
140
|
+
shard => shard === index + 1
|
|
141
|
+
).length;
|
|
142
|
+
return `shard ${index + 1}/${plan.total}: ${files} planned file${files === 1 ? "" : "s"}, ${seconds.toFixed(1)} s planned`;
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* The newest run that uploaded unexpired integration timings.
|
|
148
|
+
* @param {string} repo - owner/name
|
|
149
|
+
* @param {{ run: (command: string, args: ReadonlyArray<string>) => string }} deps - Command runner
|
|
150
|
+
* @returns {string | undefined} Run id
|
|
151
|
+
*/
|
|
152
|
+
export function findTimingsRun(repo, deps) {
|
|
153
|
+
const found = [];
|
|
154
|
+
for (let page = 1; page <= MAX_PAGES; page += 1) {
|
|
155
|
+
const output = deps.run("gh", [
|
|
156
|
+
"api",
|
|
157
|
+
`repos/${repo}/actions/artifacts?per_page=${PAGE_SIZE}&page=${page}`,
|
|
158
|
+
"--jq",
|
|
159
|
+
LISTING_JQ,
|
|
160
|
+
]);
|
|
161
|
+
const lines = output.split("\n").filter(line => line.trim() !== "");
|
|
162
|
+
found.push(
|
|
163
|
+
...lines
|
|
164
|
+
.map(line => JSON.parse(line))
|
|
165
|
+
.filter(
|
|
166
|
+
entry =>
|
|
167
|
+
entry.expired !== true && ARTIFACT_NAME.test(entry.name ?? "")
|
|
168
|
+
)
|
|
169
|
+
);
|
|
170
|
+
if (found.length > 0 || lines.length < PAGE_SIZE) break;
|
|
171
|
+
}
|
|
172
|
+
const newest = found.toSorted((a, b) =>
|
|
173
|
+
String(b.createdAt).localeCompare(String(a.createdAt))
|
|
174
|
+
)[0];
|
|
175
|
+
return newest === undefined ? undefined : String(newest.runId);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Parse the arguments, or return a usage error.
|
|
180
|
+
* @param {ReadonlyArray<string>} argv - Arguments after the script name
|
|
181
|
+
* @returns {{ shards: number, repo: string, timings?: string, out?: string, githubOutput?: string } | { error: string }} Options
|
|
182
|
+
*/
|
|
183
|
+
export function parseArgs(argv) {
|
|
184
|
+
const value = flag => {
|
|
185
|
+
const at = argv.indexOf(flag);
|
|
186
|
+
return at === -1 ? undefined : argv[at + 1];
|
|
187
|
+
};
|
|
188
|
+
const shards = Number(value("--shards"));
|
|
189
|
+
if (!Number.isInteger(shards) || shards < 2 || shards > 20)
|
|
190
|
+
return { error: "--shards needs a whole number from 2 to 20" };
|
|
191
|
+
return {
|
|
192
|
+
shards,
|
|
193
|
+
repo: value("--repo") ?? REPOSITORY,
|
|
194
|
+
timings: value("--timings"),
|
|
195
|
+
out: value("--out"),
|
|
196
|
+
githubOutput: value("--github-output"),
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Read the integration timings: from `--timings`, or downloaded from the
|
|
202
|
+
* newest run that has them. Never throws: no timings is an answer.
|
|
203
|
+
* @param {{ repo: string, timings?: string }} options - Options
|
|
204
|
+
* @param {Deps} deps - Effects
|
|
205
|
+
* @returns {{ timings: ReadonlyArray<{ file: string, seconds: number }>, source: string }} Timings
|
|
206
|
+
*/
|
|
207
|
+
function readTimings(options, deps) {
|
|
208
|
+
if (options.timings !== undefined)
|
|
209
|
+
return {
|
|
210
|
+
timings: collectTimings(options.timings).integration,
|
|
211
|
+
source: options.timings,
|
|
212
|
+
};
|
|
213
|
+
const into = fs.mkdtempSync(path.join(os.tmpdir(), "lisa-shard-timings-"));
|
|
214
|
+
try {
|
|
215
|
+
const runId = findTimingsRun(options.repo, deps);
|
|
216
|
+
if (runId === undefined)
|
|
217
|
+
return { timings: [], source: "no run with integration timings" };
|
|
218
|
+
deps.run("gh", [
|
|
219
|
+
"run",
|
|
220
|
+
"download",
|
|
221
|
+
runId,
|
|
222
|
+
"-R",
|
|
223
|
+
options.repo,
|
|
224
|
+
"-p",
|
|
225
|
+
"test-timings-*-integration*",
|
|
226
|
+
"-D",
|
|
227
|
+
into,
|
|
228
|
+
]);
|
|
229
|
+
return {
|
|
230
|
+
timings: collectTimings(into).integration,
|
|
231
|
+
source: `run ${runId}`,
|
|
232
|
+
};
|
|
233
|
+
} catch (error) {
|
|
234
|
+
return {
|
|
235
|
+
timings: [],
|
|
236
|
+
source: `the Actions API refused: ${error instanceof Error ? error.message : String(error)}`,
|
|
237
|
+
};
|
|
238
|
+
} finally {
|
|
239
|
+
fs.rmSync(into, { recursive: true, force: true });
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* @typedef {object} Deps
|
|
245
|
+
* @property {(command: string, args: ReadonlyArray<string>) => string} run - Run a command, return stdout; throws on failure
|
|
246
|
+
* @property {(line: string) => void} out - Standard output
|
|
247
|
+
* @property {(line: string) => void} err - Standard error
|
|
248
|
+
* @property {(file: string) => boolean} exists - Whether a repository file still exists
|
|
249
|
+
*/
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* CLI entry.
|
|
253
|
+
* @param {ReadonlyArray<string>} argv - Arguments after the script name
|
|
254
|
+
* @param {Deps} deps - Effects
|
|
255
|
+
* @returns {number} Exit code
|
|
256
|
+
*/
|
|
257
|
+
export function main(argv, deps) {
|
|
258
|
+
const options = parseArgs(argv);
|
|
259
|
+
if ("error" in options) {
|
|
260
|
+
deps.err(`plan-integration-shards: ${options.error}.`);
|
|
261
|
+
return 2;
|
|
262
|
+
}
|
|
263
|
+
const read = readTimings(options, deps);
|
|
264
|
+
// A file deleted since the timings were recorded would only skew the loads.
|
|
265
|
+
const timings = read.timings.filter(entry => deps.exists(entry.file));
|
|
266
|
+
const plan = planShards({
|
|
267
|
+
total: options.shards,
|
|
268
|
+
timings,
|
|
269
|
+
groups: [[...HISTORY_SCANNER_SUITES]],
|
|
270
|
+
});
|
|
271
|
+
if (timings.length === 0) {
|
|
272
|
+
deps.out(
|
|
273
|
+
`::notice title=No integration timings::Found no integration timings (${read.source}), so every file weighs the same; the history-scanner suites still share one leg.`
|
|
274
|
+
);
|
|
275
|
+
} else {
|
|
276
|
+
deps.out(
|
|
277
|
+
`Assigned ${timings.length} timed files longest-processing-time-first from ${read.source}; untimed files weigh ${plan.defaultSeconds} s each.`
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
for (const line of formatPlan(plan)) deps.out(line);
|
|
281
|
+
const json = JSON.stringify(plan);
|
|
282
|
+
if (options.out !== undefined) fs.writeFileSync(options.out, `${json}\n`);
|
|
283
|
+
if (options.githubOutput !== undefined)
|
|
284
|
+
fs.appendFileSync(options.githubOutput, `mode=files\nplan=${json}\n`);
|
|
285
|
+
return 0;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
if (invokedAsScript(import.meta.url)) {
|
|
289
|
+
process.exitCode = main(process.argv.slice(2), {
|
|
290
|
+
run: (command, args) =>
|
|
291
|
+
execFileSync(command, [...args], {
|
|
292
|
+
encoding: "utf8",
|
|
293
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
294
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
295
|
+
}),
|
|
296
|
+
out: line => console.log(line),
|
|
297
|
+
err: line => console.error(line),
|
|
298
|
+
exists: file => fs.existsSync(file),
|
|
299
|
+
});
|
|
300
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export interface FileTiming {
|
|
2
|
+
readonly file: string;
|
|
3
|
+
readonly seconds: number;
|
|
4
|
+
readonly tests: number;
|
|
5
|
+
}
|
|
6
|
+
export interface ScopeSummary {
|
|
7
|
+
readonly files: number;
|
|
8
|
+
readonly tests: number;
|
|
9
|
+
readonly seconds: number;
|
|
10
|
+
readonly top: readonly {
|
|
11
|
+
readonly file: string;
|
|
12
|
+
readonly seconds: number;
|
|
13
|
+
readonly share: number;
|
|
14
|
+
}[];
|
|
15
|
+
readonly concentration: Readonly<Record<string, number>>;
|
|
16
|
+
readonly all: readonly FileTiming[];
|
|
17
|
+
}
|
|
18
|
+
export interface ReportIo {
|
|
19
|
+
readonly stdout: (line: string) => void;
|
|
20
|
+
readonly stderr: (line: string) => void;
|
|
21
|
+
readonly download?: (runId: string, into: string) => void;
|
|
22
|
+
}
|
|
23
|
+
export declare function collectTimings(directory: string): Readonly<
|
|
24
|
+
Record<string, readonly FileTiming[]>
|
|
25
|
+
> & {
|
|
26
|
+
readonly unit: readonly FileTiming[];
|
|
27
|
+
readonly integration: readonly FileTiming[];
|
|
28
|
+
};
|
|
29
|
+
export declare function summarize(
|
|
30
|
+
files: readonly FileTiming[],
|
|
31
|
+
top: number
|
|
32
|
+
): ScopeSummary;
|
|
33
|
+
export declare function formatReport(
|
|
34
|
+
summaries: Readonly<Record<string, ScopeSummary>>
|
|
35
|
+
): string;
|
|
36
|
+
export declare function parseArgs(
|
|
37
|
+
argv: readonly string[]
|
|
38
|
+
):
|
|
39
|
+
| { dir?: string; run?: string; top: number; json: boolean }
|
|
40
|
+
| { error: string };
|
|
41
|
+
export declare function main(argv: readonly string[], io: ReportIo): number;
|
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Per-file test timing report for Lisa's own CI (CodySwannGT/lisa#4592).
|
|
4
|
+
*
|
|
5
|
+
* Reads the `test-timings-<run>-<attempt>-<job>` artifacts that
|
|
6
|
+
* `.github/workflows/quality.yml` uploads from the unit job, every unit shard
|
|
7
|
+
* leg and the integration job, and prints per scope: file count, test count,
|
|
8
|
+
* summed file time, the slowest files with their share, and the cumulative
|
|
9
|
+
* share of the top 10, 100 and 200 files. `--json` emits the same data plus
|
|
10
|
+
* every file's timing, for shard balancing and slow-test audits.
|
|
11
|
+
*
|
|
12
|
+
* Usage:
|
|
13
|
+
* node scripts/test-timing-report.mjs --dir <downloaded artifacts> [--top N] [--json]
|
|
14
|
+
* node scripts/test-timing-report.mjs --run <run-id> [--top N] [--json]
|
|
15
|
+
*
|
|
16
|
+
* A scope with no timings exits 1 naming it: a missing file is not a zero.
|
|
17
|
+
*
|
|
18
|
+
* File time is the span Vitest's json reporter records for the file, from its
|
|
19
|
+
* first test's start to its last test's end. It excludes the file's import and
|
|
20
|
+
* collection time, so it can sit below the per-file duration the default
|
|
21
|
+
* reporter prints.
|
|
22
|
+
*
|
|
23
|
+
* The same file can arrive more than once: the unit job's merged report
|
|
24
|
+
* repeats every shard's files, and a failed-jobs rerun uploads under a new
|
|
25
|
+
* attempt beside the first. One record per file is kept — an executed record
|
|
26
|
+
* over a fully skipped one, then the latest attempt.
|
|
27
|
+
* @module test-timing-report
|
|
28
|
+
*/
|
|
29
|
+
import { execFileSync } from "node:child_process";
|
|
30
|
+
import * as fs from "node:fs";
|
|
31
|
+
import * as os from "node:os";
|
|
32
|
+
import * as path from "node:path";
|
|
33
|
+
|
|
34
|
+
import { invokedAsScript } from "./lib/invoked-as-script.mjs";
|
|
35
|
+
import { TEST_TIMINGS_SCOPES } from "./lib/test-timings-reporter.mjs";
|
|
36
|
+
|
|
37
|
+
const REPOSITORY = "CodySwannGT/lisa";
|
|
38
|
+
const DEFAULT_TOP = 20;
|
|
39
|
+
const CUTOFFS = Object.freeze([10, 100, 200]);
|
|
40
|
+
const SKIPPED = new Set(["skipped", "pending", "todo", "disabled"]);
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @typedef {object} FileTiming
|
|
44
|
+
* @property {string} file - Repository-relative test file
|
|
45
|
+
* @property {number} seconds - Time the file's tests spanned
|
|
46
|
+
* @property {number} tests - Test count
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Every file under a directory, recursively.
|
|
51
|
+
* @param {string} directory - Directory to walk
|
|
52
|
+
* @returns {ReadonlyArray<string>} File paths
|
|
53
|
+
*/
|
|
54
|
+
function walk(directory) {
|
|
55
|
+
return fs.readdirSync(directory, { withFileTypes: true }).flatMap(entry => {
|
|
56
|
+
const full = path.join(directory, entry.name);
|
|
57
|
+
return entry.isDirectory() ? walk(full) : [full];
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The run attempt an artifact directory names, or 0.
|
|
63
|
+
* @param {string} file - Timing file path
|
|
64
|
+
* @returns {number} Attempt number
|
|
65
|
+
*/
|
|
66
|
+
function attemptOf(file) {
|
|
67
|
+
const match = /^test-timings-\d+-(\d+)-/.exec(
|
|
68
|
+
path.basename(path.dirname(file))
|
|
69
|
+
);
|
|
70
|
+
return match ? Number(match[1]) : 0;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Drop the checkout prefix so files read as repository paths: the current
|
|
75
|
+
* directory for a local run, the GitHub runner's workspace for a CI one.
|
|
76
|
+
* @param {string} name - Absolute path Vitest recorded
|
|
77
|
+
* @returns {string} Repository-relative path when the prefix is recognised
|
|
78
|
+
*/
|
|
79
|
+
function repositoryPath(name) {
|
|
80
|
+
const local = `${process.cwd()}${path.sep}`;
|
|
81
|
+
if (name.startsWith(local)) return name.slice(local.length);
|
|
82
|
+
return name.replace(/^.*?\/work\/[^/]+\/[^/]+\//, "");
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Parse one Vitest json report, or `undefined` when it is not one.
|
|
87
|
+
* @param {string} file - Report path
|
|
88
|
+
* @returns {ReadonlyArray<{ file: string, seconds: number, tests: number, executed: boolean }> | undefined} Entries
|
|
89
|
+
*/
|
|
90
|
+
function readReport(file) {
|
|
91
|
+
const parsed = (() => {
|
|
92
|
+
try {
|
|
93
|
+
return JSON.parse(fs.readFileSync(file, "utf8"));
|
|
94
|
+
} catch {
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
97
|
+
})();
|
|
98
|
+
if (!parsed || !Array.isArray(parsed.testResults)) return undefined;
|
|
99
|
+
return parsed.testResults
|
|
100
|
+
.filter(result => typeof result?.name === "string")
|
|
101
|
+
.map(result => {
|
|
102
|
+
const assertions = Array.isArray(result.assertionResults)
|
|
103
|
+
? result.assertionResults
|
|
104
|
+
: [];
|
|
105
|
+
const span =
|
|
106
|
+
typeof result.startTime === "number" &&
|
|
107
|
+
typeof result.endTime === "number"
|
|
108
|
+
? result.endTime - result.startTime
|
|
109
|
+
: assertions.reduce((sum, a) => sum + (a?.duration ?? 0), 0);
|
|
110
|
+
return {
|
|
111
|
+
file: repositoryPath(result.name),
|
|
112
|
+
seconds: Math.max(0, span) / 1000,
|
|
113
|
+
tests: assertions.length,
|
|
114
|
+
executed: assertions.some(a => !SKIPPED.has(a?.status)),
|
|
115
|
+
};
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Whether a candidate record should replace the one already kept.
|
|
121
|
+
* @param {{ executed: boolean, attempt: number }} candidate - New record
|
|
122
|
+
* @param {{ executed: boolean, attempt: number } | undefined} kept - Current record
|
|
123
|
+
* @returns {boolean} True to replace
|
|
124
|
+
*/
|
|
125
|
+
function outranks(candidate, kept) {
|
|
126
|
+
if (kept === undefined) return true;
|
|
127
|
+
if (candidate.executed !== kept.executed) return candidate.executed;
|
|
128
|
+
return candidate.attempt > kept.attempt;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Gather one record per file, per scope, from a directory of artifacts.
|
|
133
|
+
* @param {string} directory - Downloaded artifacts (any depth)
|
|
134
|
+
* @returns {Readonly<Record<string, ReadonlyArray<FileTiming>>>} Timings by scope
|
|
135
|
+
*/
|
|
136
|
+
export function collectTimings(directory) {
|
|
137
|
+
const reports = walk(directory).flatMap(file => {
|
|
138
|
+
const scope = path.basename(file, ".json");
|
|
139
|
+
if (!file.endsWith(".json") || !TEST_TIMINGS_SCOPES.includes(scope))
|
|
140
|
+
return [];
|
|
141
|
+
const entries = readReport(file) ?? [];
|
|
142
|
+
const attempt = attemptOf(file);
|
|
143
|
+
return entries.map(entry => ({ ...entry, scope, attempt }));
|
|
144
|
+
});
|
|
145
|
+
const kept = reports.reduce((acc, record) => {
|
|
146
|
+
const key = `${record.scope}\u0000${record.file}`;
|
|
147
|
+
return outranks(record, acc[key]) ? { ...acc, [key]: record } : acc;
|
|
148
|
+
}, /** @type {Record<string, (typeof reports)[number]>} */ ({}));
|
|
149
|
+
return Object.fromEntries(
|
|
150
|
+
TEST_TIMINGS_SCOPES.map(scope => [
|
|
151
|
+
scope,
|
|
152
|
+
Object.values(kept)
|
|
153
|
+
.filter(record => record.scope === scope)
|
|
154
|
+
.map(({ file, seconds, tests }) => ({ file, seconds, tests }))
|
|
155
|
+
.toSorted(
|
|
156
|
+
(a, b) => b.seconds - a.seconds || a.file.localeCompare(b.file)
|
|
157
|
+
),
|
|
158
|
+
])
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Summarise one scope.
|
|
164
|
+
* @param {ReadonlyArray<FileTiming>} files - Files, any order
|
|
165
|
+
* @param {number} top - How many slowest files to list
|
|
166
|
+
* @returns {{ files: number, tests: number, seconds: number, top: ReadonlyArray<{ file: string, seconds: number, share: number }>, concentration: Readonly<Record<string, number>>, all: ReadonlyArray<FileTiming> }} Summary
|
|
167
|
+
*/
|
|
168
|
+
export function summarize(files, top) {
|
|
169
|
+
const all = files.toSorted(
|
|
170
|
+
(a, b) => b.seconds - a.seconds || a.file.localeCompare(b.file)
|
|
171
|
+
);
|
|
172
|
+
const seconds = all.reduce((sum, file) => sum + file.seconds, 0);
|
|
173
|
+
const share = value => (seconds === 0 ? 0 : value / seconds);
|
|
174
|
+
const sumOf = count =>
|
|
175
|
+
all.slice(0, count).reduce((sum, file) => sum + file.seconds, 0);
|
|
176
|
+
return {
|
|
177
|
+
files: all.length,
|
|
178
|
+
tests: all.reduce((sum, file) => sum + file.tests, 0),
|
|
179
|
+
seconds,
|
|
180
|
+
top: all.slice(0, top).map(file => ({
|
|
181
|
+
file: file.file,
|
|
182
|
+
seconds: file.seconds,
|
|
183
|
+
share: share(file.seconds),
|
|
184
|
+
})),
|
|
185
|
+
concentration: Object.fromEntries(
|
|
186
|
+
CUTOFFS.map(count => [`top${count}`, share(sumOf(count))])
|
|
187
|
+
),
|
|
188
|
+
all,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* A ratio as a percentage with one decimal.
|
|
194
|
+
* @param {number} ratio - 0..1
|
|
195
|
+
* @returns {string} Percentage text
|
|
196
|
+
*/
|
|
197
|
+
function percent(ratio) {
|
|
198
|
+
return (ratio * 100).toFixed(1);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Render summaries as text.
|
|
203
|
+
* @param {Readonly<Record<string, ReturnType<typeof summarize>>>} summaries - By scope
|
|
204
|
+
* @returns {string} Report text
|
|
205
|
+
*/
|
|
206
|
+
export function formatReport(summaries) {
|
|
207
|
+
return Object.entries(summaries)
|
|
208
|
+
.map(([scope, summary]) => {
|
|
209
|
+
const rows = summary.top.map(
|
|
210
|
+
(file, index) =>
|
|
211
|
+
` ${String(index + 1).padStart(3)}. ${file.seconds.toFixed(2).padStart(8)}s ${percent(file.share).padStart(6)}% ${file.file}`
|
|
212
|
+
);
|
|
213
|
+
const shares = CUTOFFS.map(count => {
|
|
214
|
+
const key = `top${count}`;
|
|
215
|
+
const ratio = summary.concentration[key];
|
|
216
|
+
return `top ${count}: ${percent(ratio)}%`;
|
|
217
|
+
}).join(" ");
|
|
218
|
+
const fewer =
|
|
219
|
+
summary.files < Math.max(...CUTOFFS)
|
|
220
|
+
? [
|
|
221
|
+
` (only ${summary.files} file${summary.files === 1 ? "" : "s"}; a larger cutoff covers them all)`,
|
|
222
|
+
]
|
|
223
|
+
: [];
|
|
224
|
+
return [
|
|
225
|
+
`${scope}: ${summary.files} files, ${summary.tests} tests, ${summary.seconds.toFixed(1)}s summed file time`,
|
|
226
|
+
` top ${summary.top.length} files by time:`,
|
|
227
|
+
...rows,
|
|
228
|
+
` ${shares}`,
|
|
229
|
+
...fewer,
|
|
230
|
+
].join("\n");
|
|
231
|
+
})
|
|
232
|
+
.join("\n\n");
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Download a run's timing artifacts with `gh`.
|
|
237
|
+
* @param {string} runId - Workflow run id
|
|
238
|
+
* @param {string} into - Destination directory
|
|
239
|
+
*/
|
|
240
|
+
function downloadRun(runId, into) {
|
|
241
|
+
execFileSync(
|
|
242
|
+
"gh",
|
|
243
|
+
[
|
|
244
|
+
"run",
|
|
245
|
+
"download",
|
|
246
|
+
runId,
|
|
247
|
+
"-R",
|
|
248
|
+
REPOSITORY,
|
|
249
|
+
"-p",
|
|
250
|
+
"test-timings-*",
|
|
251
|
+
"-D",
|
|
252
|
+
into,
|
|
253
|
+
],
|
|
254
|
+
{ stdio: ["ignore", "ignore", "inherit"] }
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Parse the arguments, or return a usage error.
|
|
260
|
+
* @param {ReadonlyArray<string>} argv - Arguments after the script name
|
|
261
|
+
* @returns {{ dir?: string, run?: string, top: number, json: boolean } | { error: string }} Options
|
|
262
|
+
*/
|
|
263
|
+
export function parseArgs(argv) {
|
|
264
|
+
const value = flag => {
|
|
265
|
+
const at = argv.indexOf(flag);
|
|
266
|
+
return at === -1 ? undefined : (argv[at + 1] ?? "");
|
|
267
|
+
};
|
|
268
|
+
const dir = value("--dir");
|
|
269
|
+
const run = value("--run");
|
|
270
|
+
const topText = value("--top");
|
|
271
|
+
const top = topText === undefined ? DEFAULT_TOP : Number(topText);
|
|
272
|
+
if ((dir === undefined) === (run === undefined))
|
|
273
|
+
return { error: "pass exactly one of --dir <directory> or --run <run-id>" };
|
|
274
|
+
if (dir === "" || run === "" || (run !== undefined && !/^\d+$/.test(run)))
|
|
275
|
+
return { error: "--dir needs a directory and --run a numeric run id" };
|
|
276
|
+
if (!Number.isInteger(top) || top < 1)
|
|
277
|
+
return { error: "--top needs a positive whole number" };
|
|
278
|
+
return { dir, run, top, json: argv.includes("--json") };
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Report on a directory of artifacts.
|
|
283
|
+
* @param {string} directory - Artifacts directory
|
|
284
|
+
* @param {{ top: number, json: boolean, source: string }} options - Output options
|
|
285
|
+
* @param {{ stdout: (line: string) => void, stderr: (line: string) => void }} io - Output sinks
|
|
286
|
+
* @returns {number} Exit code
|
|
287
|
+
*/
|
|
288
|
+
function report(directory, options, io) {
|
|
289
|
+
if (!fs.existsSync(directory) || !fs.statSync(directory).isDirectory()) {
|
|
290
|
+
io.stderr(`test-timing-report: ${directory} is not a directory.`);
|
|
291
|
+
return 1;
|
|
292
|
+
}
|
|
293
|
+
const timings = collectTimings(directory);
|
|
294
|
+
const missing = TEST_TIMINGS_SCOPES.filter(
|
|
295
|
+
scope => timings[scope].length === 0
|
|
296
|
+
);
|
|
297
|
+
if (missing.length > 0) {
|
|
298
|
+
io.stderr(
|
|
299
|
+
`test-timing-report: missing timings for scope${missing.length === 1 ? "" : "s"} ${missing.join(", ")} in ${options.source}. ` +
|
|
300
|
+
"Each scope needs a test-timings artifact holding <scope>.json; a missing file is not reported as zero."
|
|
301
|
+
);
|
|
302
|
+
return 1;
|
|
303
|
+
}
|
|
304
|
+
const summaries = Object.fromEntries(
|
|
305
|
+
TEST_TIMINGS_SCOPES.map(scope => [
|
|
306
|
+
scope,
|
|
307
|
+
summarize(timings[scope], options.top),
|
|
308
|
+
])
|
|
309
|
+
);
|
|
310
|
+
io.stdout(
|
|
311
|
+
options.json
|
|
312
|
+
? JSON.stringify(
|
|
313
|
+
{ schema: 1, source: options.source, scopes: summaries },
|
|
314
|
+
null,
|
|
315
|
+
2
|
|
316
|
+
)
|
|
317
|
+
: formatReport(summaries)
|
|
318
|
+
);
|
|
319
|
+
return 0;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* CLI entry.
|
|
324
|
+
* @param {ReadonlyArray<string>} argv - Arguments after the script name
|
|
325
|
+
* @param {{ stdout: (line: string) => void, stderr: (line: string) => void, download?: (runId: string, into: string) => void }} io - Output sinks and downloader
|
|
326
|
+
* @returns {number} Exit code
|
|
327
|
+
*/
|
|
328
|
+
export function main(argv, io) {
|
|
329
|
+
const options = parseArgs(argv);
|
|
330
|
+
if ("error" in options) {
|
|
331
|
+
io.stderr(`test-timing-report: ${options.error}.`);
|
|
332
|
+
return 2;
|
|
333
|
+
}
|
|
334
|
+
if (options.dir !== undefined)
|
|
335
|
+
return report(
|
|
336
|
+
path.resolve(options.dir),
|
|
337
|
+
{ ...options, source: options.dir },
|
|
338
|
+
io
|
|
339
|
+
);
|
|
340
|
+
const into = fs.mkdtempSync(path.join(os.tmpdir(), "lisa-test-timings-"));
|
|
341
|
+
try {
|
|
342
|
+
try {
|
|
343
|
+
(io.download ?? downloadRun)(options.run, into);
|
|
344
|
+
} catch (error) {
|
|
345
|
+
io.stderr(
|
|
346
|
+
`test-timing-report: could not download test-timings-* artifacts of run ${options.run} from ${REPOSITORY}: ${error instanceof Error ? error.message : String(error)}`
|
|
347
|
+
);
|
|
348
|
+
return 1;
|
|
349
|
+
}
|
|
350
|
+
return report(into, { ...options, source: `run ${options.run}` }, io);
|
|
351
|
+
} finally {
|
|
352
|
+
fs.rmSync(into, { recursive: true, force: true });
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
if (invokedAsScript(import.meta.url)) {
|
|
357
|
+
process.exitCode = main(process.argv.slice(2), {
|
|
358
|
+
stdout: line => console.log(line),
|
|
359
|
+
stderr: line => console.error(line),
|
|
360
|
+
});
|
|
361
|
+
}
|