@urateam/core 0.1.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/dist/__tests__/assembler.test.d.ts +2 -0
- package/dist/__tests__/assembler.test.d.ts.map +1 -0
- package/dist/__tests__/assembler.test.js +63 -0
- package/dist/__tests__/assembler.test.js.map +1 -0
- package/dist/__tests__/auth-check.test.d.ts +2 -0
- package/dist/__tests__/auth-check.test.d.ts.map +1 -0
- package/dist/__tests__/auth-check.test.js +88 -0
- package/dist/__tests__/auth-check.test.js.map +1 -0
- package/dist/__tests__/auto-merge.test.d.ts +15 -0
- package/dist/__tests__/auto-merge.test.d.ts.map +1 -0
- package/dist/__tests__/auto-merge.test.js +428 -0
- package/dist/__tests__/auto-merge.test.js.map +1 -0
- package/dist/__tests__/bec89-unified-schema.test.d.ts +2 -0
- package/dist/__tests__/bec89-unified-schema.test.d.ts.map +1 -0
- package/dist/__tests__/bec89-unified-schema.test.js +235 -0
- package/dist/__tests__/bec89-unified-schema.test.js.map +1 -0
- package/dist/__tests__/conflict-detector.test.d.ts +2 -0
- package/dist/__tests__/conflict-detector.test.d.ts.map +1 -0
- package/dist/__tests__/conflict-detector.test.js +206 -0
- package/dist/__tests__/conflict-detector.test.js.map +1 -0
- package/dist/__tests__/coordination.test.d.ts +2 -0
- package/dist/__tests__/coordination.test.d.ts.map +1 -0
- package/dist/__tests__/coordination.test.js +257 -0
- package/dist/__tests__/coordination.test.js.map +1 -0
- package/dist/__tests__/db-postgres.test.d.ts +14 -0
- package/dist/__tests__/db-postgres.test.d.ts.map +1 -0
- package/dist/__tests__/db-postgres.test.js +289 -0
- package/dist/__tests__/db-postgres.test.js.map +1 -0
- package/dist/__tests__/db.test.d.ts +2 -0
- package/dist/__tests__/db.test.d.ts.map +1 -0
- package/dist/__tests__/db.test.js +182 -0
- package/dist/__tests__/db.test.js.map +1 -0
- package/dist/__tests__/deep-review.test.d.ts +2 -0
- package/dist/__tests__/deep-review.test.d.ts.map +1 -0
- package/dist/__tests__/deep-review.test.js +322 -0
- package/dist/__tests__/deep-review.test.js.map +1 -0
- package/dist/__tests__/devcontainer.test.d.ts +2 -0
- package/dist/__tests__/devcontainer.test.d.ts.map +1 -0
- package/dist/__tests__/devcontainer.test.js +89 -0
- package/dist/__tests__/devcontainer.test.js.map +1 -0
- package/dist/__tests__/distributed-lock.test.d.ts +18 -0
- package/dist/__tests__/distributed-lock.test.d.ts.map +1 -0
- package/dist/__tests__/distributed-lock.test.js +237 -0
- package/dist/__tests__/distributed-lock.test.js.map +1 -0
- package/dist/__tests__/e2e-pipeline.test.d.ts +25 -0
- package/dist/__tests__/e2e-pipeline.test.d.ts.map +1 -0
- package/dist/__tests__/e2e-pipeline.test.js +517 -0
- package/dist/__tests__/e2e-pipeline.test.js.map +1 -0
- package/dist/__tests__/error-classifier.test.d.ts +2 -0
- package/dist/__tests__/error-classifier.test.d.ts.map +1 -0
- package/dist/__tests__/error-classifier.test.js +33 -0
- package/dist/__tests__/error-classifier.test.js.map +1 -0
- package/dist/__tests__/executor-integration.test.d.ts +11 -0
- package/dist/__tests__/executor-integration.test.d.ts.map +1 -0
- package/dist/__tests__/executor-integration.test.js +246 -0
- package/dist/__tests__/executor-integration.test.js.map +1 -0
- package/dist/__tests__/executor-issue-id.test.d.ts +13 -0
- package/dist/__tests__/executor-issue-id.test.d.ts.map +1 -0
- package/dist/__tests__/executor-issue-id.test.js +211 -0
- package/dist/__tests__/executor-issue-id.test.js.map +1 -0
- package/dist/__tests__/executor.test.d.ts +2 -0
- package/dist/__tests__/executor.test.d.ts.map +1 -0
- package/dist/__tests__/executor.test.js +164 -0
- package/dist/__tests__/executor.test.js.map +1 -0
- package/dist/__tests__/extract-handoff.test.d.ts +2 -0
- package/dist/__tests__/extract-handoff.test.d.ts.map +1 -0
- package/dist/__tests__/extract-handoff.test.js +131 -0
- package/dist/__tests__/extract-handoff.test.js.map +1 -0
- package/dist/__tests__/fail-on-auto-commit.test.d.ts +2 -0
- package/dist/__tests__/fail-on-auto-commit.test.d.ts.map +1 -0
- package/dist/__tests__/fail-on-auto-commit.test.js +156 -0
- package/dist/__tests__/fail-on-auto-commit.test.js.map +1 -0
- package/dist/__tests__/fixtures/webhook-comment.json +5 -0
- package/dist/__tests__/fixtures/webhook-state-change.json +15 -0
- package/dist/__tests__/force-push-agent-branches.test.d.ts +12 -0
- package/dist/__tests__/force-push-agent-branches.test.d.ts.map +1 -0
- package/dist/__tests__/force-push-agent-branches.test.js +348 -0
- package/dist/__tests__/force-push-agent-branches.test.js.map +1 -0
- package/dist/__tests__/github-webhook.test.d.ts +2 -0
- package/dist/__tests__/github-webhook.test.d.ts.map +1 -0
- package/dist/__tests__/github-webhook.test.js +370 -0
- package/dist/__tests__/github-webhook.test.js.map +1 -0
- package/dist/__tests__/gitlab.test.d.ts +28 -0
- package/dist/__tests__/gitlab.test.d.ts.map +1 -0
- package/dist/__tests__/gitlab.test.js +241 -0
- package/dist/__tests__/gitlab.test.js.map +1 -0
- package/dist/__tests__/integration/auto-commit.test.d.ts +2 -0
- package/dist/__tests__/integration/auto-commit.test.d.ts.map +1 -0
- package/dist/__tests__/integration/auto-commit.test.js +207 -0
- package/dist/__tests__/integration/auto-commit.test.js.map +1 -0
- package/dist/__tests__/integration/bec99-cross-worktree-guard.test.d.ts +10 -0
- package/dist/__tests__/integration/bec99-cross-worktree-guard.test.d.ts.map +1 -0
- package/dist/__tests__/integration/bec99-cross-worktree-guard.test.js +183 -0
- package/dist/__tests__/integration/bec99-cross-worktree-guard.test.js.map +1 -0
- package/dist/__tests__/integration/reproduce-bec99.test.d.ts +32 -0
- package/dist/__tests__/integration/reproduce-bec99.test.d.ts.map +1 -0
- package/dist/__tests__/integration/reproduce-bec99.test.js +243 -0
- package/dist/__tests__/integration/reproduce-bec99.test.js.map +1 -0
- package/dist/__tests__/integration/vitest-changed.test.d.ts +10 -0
- package/dist/__tests__/integration/vitest-changed.test.d.ts.map +1 -0
- package/dist/__tests__/integration/vitest-changed.test.js +128 -0
- package/dist/__tests__/integration/vitest-changed.test.js.map +1 -0
- package/dist/__tests__/license.test.d.ts +2 -0
- package/dist/__tests__/license.test.d.ts.map +1 -0
- package/dist/__tests__/license.test.js +53 -0
- package/dist/__tests__/license.test.js.map +1 -0
- package/dist/__tests__/mcp-resolver.test.d.ts +2 -0
- package/dist/__tests__/mcp-resolver.test.d.ts.map +1 -0
- package/dist/__tests__/mcp-resolver.test.js +65 -0
- package/dist/__tests__/mcp-resolver.test.js.map +1 -0
- package/dist/__tests__/migrator.test.d.ts +2 -0
- package/dist/__tests__/migrator.test.d.ts.map +1 -0
- package/dist/__tests__/migrator.test.js +300 -0
- package/dist/__tests__/migrator.test.js.map +1 -0
- package/dist/__tests__/notifier-discord.test.d.ts +2 -0
- package/dist/__tests__/notifier-discord.test.d.ts.map +1 -0
- package/dist/__tests__/notifier-discord.test.js +166 -0
- package/dist/__tests__/notifier-discord.test.js.map +1 -0
- package/dist/__tests__/notifier-slack.test.d.ts +2 -0
- package/dist/__tests__/notifier-slack.test.d.ts.map +1 -0
- package/dist/__tests__/notifier-slack.test.js +157 -0
- package/dist/__tests__/notifier-slack.test.js.map +1 -0
- package/dist/__tests__/notifier.test.d.ts +2 -0
- package/dist/__tests__/notifier.test.d.ts.map +1 -0
- package/dist/__tests__/notifier.test.js +207 -0
- package/dist/__tests__/notifier.test.js.map +1 -0
- package/dist/__tests__/pipeline-config.test.d.ts +2 -0
- package/dist/__tests__/pipeline-config.test.d.ts.map +1 -0
- package/dist/__tests__/pipeline-config.test.js +143 -0
- package/dist/__tests__/pipeline-config.test.js.map +1 -0
- package/dist/__tests__/pipeline-runner.test.d.ts +2 -0
- package/dist/__tests__/pipeline-runner.test.d.ts.map +1 -0
- package/dist/__tests__/pipeline-runner.test.js +359 -0
- package/dist/__tests__/pipeline-runner.test.js.map +1 -0
- package/dist/__tests__/pm-approvals-n1.repro.test.d.ts +9 -0
- package/dist/__tests__/pm-approvals-n1.repro.test.d.ts.map +1 -0
- package/dist/__tests__/pm-approvals-n1.repro.test.js +175 -0
- package/dist/__tests__/pm-approvals-n1.repro.test.js.map +1 -0
- package/dist/__tests__/pm-approvals.test.d.ts +2 -0
- package/dist/__tests__/pm-approvals.test.d.ts.map +1 -0
- package/dist/__tests__/pm-approvals.test.js +162 -0
- package/dist/__tests__/pm-approvals.test.js.map +1 -0
- package/dist/__tests__/pm-budget.test.d.ts +2 -0
- package/dist/__tests__/pm-budget.test.d.ts.map +1 -0
- package/dist/__tests__/pm-budget.test.js +65 -0
- package/dist/__tests__/pm-budget.test.js.map +1 -0
- package/dist/__tests__/pm-conflict.test.d.ts +2 -0
- package/dist/__tests__/pm-conflict.test.d.ts.map +1 -0
- package/dist/__tests__/pm-conflict.test.js +87 -0
- package/dist/__tests__/pm-conflict.test.js.map +1 -0
- package/dist/__tests__/pm-promote.test.d.ts +2 -0
- package/dist/__tests__/pm-promote.test.d.ts.map +1 -0
- package/dist/__tests__/pm-promote.test.js +82 -0
- package/dist/__tests__/pm-promote.test.js.map +1 -0
- package/dist/__tests__/pm-recover.test.d.ts +2 -0
- package/dist/__tests__/pm-recover.test.d.ts.map +1 -0
- package/dist/__tests__/pm-recover.test.js +100 -0
- package/dist/__tests__/pm-recover.test.js.map +1 -0
- package/dist/__tests__/pm-scheduler.test.d.ts +2 -0
- package/dist/__tests__/pm-scheduler.test.d.ts.map +1 -0
- package/dist/__tests__/pm-scheduler.test.js +112 -0
- package/dist/__tests__/pm-scheduler.test.js.map +1 -0
- package/dist/__tests__/pm-slack-interface.test.d.ts +2 -0
- package/dist/__tests__/pm-slack-interface.test.d.ts.map +1 -0
- package/dist/__tests__/pm-slack-interface.test.js +372 -0
- package/dist/__tests__/pm-slack-interface.test.js.map +1 -0
- package/dist/__tests__/pm-slack.test.d.ts +2 -0
- package/dist/__tests__/pm-slack.test.d.ts.map +1 -0
- package/dist/__tests__/pm-slack.test.js +83 -0
- package/dist/__tests__/pm-slack.test.js.map +1 -0
- package/dist/__tests__/pm-triage.test.d.ts +2 -0
- package/dist/__tests__/pm-triage.test.d.ts.map +1 -0
- package/dist/__tests__/pm-triage.test.js +198 -0
- package/dist/__tests__/pm-triage.test.js.map +1 -0
- package/dist/__tests__/pm-types.test.d.ts +2 -0
- package/dist/__tests__/pm-types.test.d.ts.map +1 -0
- package/dist/__tests__/pm-types.test.js +76 -0
- package/dist/__tests__/pm-types.test.js.map +1 -0
- package/dist/__tests__/pr-automerge.test.d.ts +18 -0
- package/dist/__tests__/pr-automerge.test.d.ts.map +1 -0
- package/dist/__tests__/pr-automerge.test.js +645 -0
- package/dist/__tests__/pr-automerge.test.js.map +1 -0
- package/dist/__tests__/pr-description.test.d.ts +2 -0
- package/dist/__tests__/pr-description.test.d.ts.map +1 -0
- package/dist/__tests__/pr-description.test.js +728 -0
- package/dist/__tests__/pr-description.test.js.map +1 -0
- package/dist/__tests__/prompt-injection.test.d.ts +2 -0
- package/dist/__tests__/prompt-injection.test.d.ts.map +1 -0
- package/dist/__tests__/prompt-injection.test.js +446 -0
- package/dist/__tests__/prompt-injection.test.js.map +1 -0
- package/dist/__tests__/ralph-gate.test.d.ts +19 -0
- package/dist/__tests__/ralph-gate.test.d.ts.map +1 -0
- package/dist/__tests__/ralph-gate.test.js +593 -0
- package/dist/__tests__/ralph-gate.test.js.map +1 -0
- package/dist/__tests__/ralph-review-fix-regression.test.d.ts +18 -0
- package/dist/__tests__/ralph-review-fix-regression.test.d.ts.map +1 -0
- package/dist/__tests__/ralph-review-fix-regression.test.js +306 -0
- package/dist/__tests__/ralph-review-fix-regression.test.js.map +1 -0
- package/dist/__tests__/ralph.test.d.ts +2 -0
- package/dist/__tests__/ralph.test.d.ts.map +1 -0
- package/dist/__tests__/ralph.test.js +96 -0
- package/dist/__tests__/ralph.test.js.map +1 -0
- package/dist/__tests__/recover-stuck.test.d.ts +8 -0
- package/dist/__tests__/recover-stuck.test.d.ts.map +1 -0
- package/dist/__tests__/recover-stuck.test.js +399 -0
- package/dist/__tests__/recover-stuck.test.js.map +1 -0
- package/dist/__tests__/repo.test.d.ts +2 -0
- package/dist/__tests__/repo.test.d.ts.map +1 -0
- package/dist/__tests__/repo.test.js +295 -0
- package/dist/__tests__/repo.test.js.map +1 -0
- package/dist/__tests__/repro-bec58-n-plus-one.test.d.ts +2 -0
- package/dist/__tests__/repro-bec58-n-plus-one.test.d.ts.map +1 -0
- package/dist/__tests__/repro-bec58-n-plus-one.test.js +187 -0
- package/dist/__tests__/repro-bec58-n-plus-one.test.js.map +1 -0
- package/dist/__tests__/reproduce-bec113-pagination-warning.test.d.ts +16 -0
- package/dist/__tests__/reproduce-bec113-pagination-warning.test.d.ts.map +1 -0
- package/dist/__tests__/reproduce-bec113-pagination-warning.test.js +226 -0
- package/dist/__tests__/reproduce-bec113-pagination-warning.test.js.map +1 -0
- package/dist/__tests__/reproduce-bec43-updatedat.test.d.ts +2 -0
- package/dist/__tests__/reproduce-bec43-updatedat.test.d.ts.map +1 -0
- package/dist/__tests__/reproduce-bec43-updatedat.test.js +76 -0
- package/dist/__tests__/reproduce-bec43-updatedat.test.js.map +1 -0
- package/dist/__tests__/reproduce-bec48-distributed-race.test.d.ts +18 -0
- package/dist/__tests__/reproduce-bec48-distributed-race.test.d.ts.map +1 -0
- package/dist/__tests__/reproduce-bec48-distributed-race.test.js +178 -0
- package/dist/__tests__/reproduce-bec48-distributed-race.test.js.map +1 -0
- package/dist/__tests__/reproduce-bec62.test.d.ts +2 -0
- package/dist/__tests__/reproduce-bec62.test.d.ts.map +1 -0
- package/dist/__tests__/reproduce-bec62.test.js +86 -0
- package/dist/__tests__/reproduce-bec62.test.js.map +1 -0
- package/dist/__tests__/reproduce-bec91-stuck-in-progress.test.d.ts +13 -0
- package/dist/__tests__/reproduce-bec91-stuck-in-progress.test.d.ts.map +1 -0
- package/dist/__tests__/reproduce-bec91-stuck-in-progress.test.js +220 -0
- package/dist/__tests__/reproduce-bec91-stuck-in-progress.test.js.map +1 -0
- package/dist/__tests__/review-feedback.test.d.ts +2 -0
- package/dist/__tests__/review-feedback.test.d.ts.map +1 -0
- package/dist/__tests__/review-feedback.test.js +383 -0
- package/dist/__tests__/review-feedback.test.js.map +1 -0
- package/dist/__tests__/sanitizer.test.d.ts +2 -0
- package/dist/__tests__/sanitizer.test.d.ts.map +1 -0
- package/dist/__tests__/sanitizer.test.js +162 -0
- package/dist/__tests__/sanitizer.test.js.map +1 -0
- package/dist/__tests__/security.test.d.ts +2 -0
- package/dist/__tests__/security.test.d.ts.map +1 -0
- package/dist/__tests__/security.test.js +52 -0
- package/dist/__tests__/security.test.js.map +1 -0
- package/dist/__tests__/server.test.d.ts +2 -0
- package/dist/__tests__/server.test.d.ts.map +1 -0
- package/dist/__tests__/server.test.js +61 -0
- package/dist/__tests__/server.test.js.map +1 -0
- package/dist/__tests__/slack-alerts.test.d.ts +2 -0
- package/dist/__tests__/slack-alerts.test.d.ts.map +1 -0
- package/dist/__tests__/slack-alerts.test.js +214 -0
- package/dist/__tests__/slack-alerts.test.js.map +1 -0
- package/dist/__tests__/stage-models.test.d.ts +14 -0
- package/dist/__tests__/stage-models.test.d.ts.map +1 -0
- package/dist/__tests__/stage-models.test.js +244 -0
- package/dist/__tests__/stage-models.test.js.map +1 -0
- package/dist/__tests__/start-todo.test.d.ts +2 -0
- package/dist/__tests__/start-todo.test.d.ts.map +1 -0
- package/dist/__tests__/start-todo.test.js +175 -0
- package/dist/__tests__/start-todo.test.js.map +1 -0
- package/dist/__tests__/tech-stack.test.d.ts +2 -0
- package/dist/__tests__/tech-stack.test.d.ts.map +1 -0
- package/dist/__tests__/tech-stack.test.js +75 -0
- package/dist/__tests__/tech-stack.test.js.map +1 -0
- package/dist/__tests__/templates.test.d.ts +2 -0
- package/dist/__tests__/templates.test.d.ts.map +1 -0
- package/dist/__tests__/templates.test.js +161 -0
- package/dist/__tests__/templates.test.js.map +1 -0
- package/dist/__tests__/test-quality.test.d.ts +2 -0
- package/dist/__tests__/test-quality.test.d.ts.map +1 -0
- package/dist/__tests__/test-quality.test.js +329 -0
- package/dist/__tests__/test-quality.test.js.map +1 -0
- package/dist/__tests__/token-budget.test.d.ts +2 -0
- package/dist/__tests__/token-budget.test.d.ts.map +1 -0
- package/dist/__tests__/token-budget.test.js +198 -0
- package/dist/__tests__/token-budget.test.js.map +1 -0
- package/dist/__tests__/types.test.d.ts +2 -0
- package/dist/__tests__/types.test.d.ts.map +1 -0
- package/dist/__tests__/types.test.js +156 -0
- package/dist/__tests__/types.test.js.map +1 -0
- package/dist/__tests__/validate.test.d.ts +2 -0
- package/dist/__tests__/validate.test.d.ts.map +1 -0
- package/dist/__tests__/validate.test.js +128 -0
- package/dist/__tests__/validate.test.js.map +1 -0
- package/dist/__tests__/webhook-handler.test.d.ts +2 -0
- package/dist/__tests__/webhook-handler.test.d.ts.map +1 -0
- package/dist/__tests__/webhook-handler.test.js +286 -0
- package/dist/__tests__/webhook-handler.test.js.map +1 -0
- package/dist/__tests__/webhook.test.d.ts +2 -0
- package/dist/__tests__/webhook.test.d.ts.map +1 -0
- package/dist/__tests__/webhook.test.js +58 -0
- package/dist/__tests__/webhook.test.js.map +1 -0
- package/dist/db/client.d.ts +56 -0
- package/dist/db/client.d.ts.map +1 -0
- package/dist/db/client.js +201 -0
- package/dist/db/client.js.map +1 -0
- package/dist/db/index.d.ts +4 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +4 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/migrations/postgres/001_initial_schema.sql +78 -0
- package/dist/db/migrations/postgres/002_pg_timestamps.sql +78 -0
- package/dist/db/migrations/postgres/003_retry_count.sql +10 -0
- package/dist/db/migrations/postgres/004_review_feedback.sql +20 -0
- package/dist/db/migrations/postgres/005_auto_merge.sql +15 -0
- package/dist/db/migrations/sqlite/001_initial_schema.sql +78 -0
- package/dist/db/migrations/sqlite/002_retry_count.sql +5 -0
- package/dist/db/migrations/sqlite/003_review_feedback.sql +7 -0
- package/dist/db/migrations/sqlite/004_auto_merge.sql +6 -0
- package/dist/db/migrator.d.ts +51 -0
- package/dist/db/migrator.d.ts.map +1 -0
- package/dist/db/migrator.js +188 -0
- package/dist/db/migrator.js.map +1 -0
- package/dist/db/schema.d.ts +1114 -0
- package/dist/db/schema.d.ts.map +1 -0
- package/dist/db/schema.js +129 -0
- package/dist/db/schema.js.map +1 -0
- package/dist/entrypoint.d.ts +2 -0
- package/dist/entrypoint.d.ts.map +1 -0
- package/dist/entrypoint.js +113 -0
- package/dist/entrypoint.js.map +1 -0
- package/dist/executor/agent-config.d.ts +10 -0
- package/dist/executor/agent-config.d.ts.map +1 -0
- package/dist/executor/agent-config.js +81 -0
- package/dist/executor/agent-config.js.map +1 -0
- package/dist/executor/agent-stream.d.ts +65 -0
- package/dist/executor/agent-stream.d.ts.map +1 -0
- package/dist/executor/agent-stream.js +101 -0
- package/dist/executor/agent-stream.js.map +1 -0
- package/dist/executor/auth-check.d.ts +10 -0
- package/dist/executor/auth-check.d.ts.map +1 -0
- package/dist/executor/auth-check.js +52 -0
- package/dist/executor/auth-check.js.map +1 -0
- package/dist/executor/deep-review.d.ts +61 -0
- package/dist/executor/deep-review.d.ts.map +1 -0
- package/dist/executor/deep-review.js +308 -0
- package/dist/executor/deep-review.js.map +1 -0
- package/dist/executor/executor.d.ts +27 -0
- package/dist/executor/executor.d.ts.map +1 -0
- package/dist/executor/executor.js +168 -0
- package/dist/executor/executor.js.map +1 -0
- package/dist/executor/extract-handoff.d.ts +14 -0
- package/dist/executor/extract-handoff.d.ts.map +1 -0
- package/dist/executor/extract-handoff.js +80 -0
- package/dist/executor/extract-handoff.js.map +1 -0
- package/dist/executor/handoff.d.ts +24 -0
- package/dist/executor/handoff.d.ts.map +1 -0
- package/dist/executor/handoff.js +63 -0
- package/dist/executor/handoff.js.map +1 -0
- package/dist/executor/index.d.ts +8 -0
- package/dist/executor/index.d.ts.map +1 -0
- package/dist/executor/index.js +8 -0
- package/dist/executor/index.js.map +1 -0
- package/dist/executor/mcp-resolver.d.ts +29 -0
- package/dist/executor/mcp-resolver.d.ts.map +1 -0
- package/dist/executor/mcp-resolver.js +80 -0
- package/dist/executor/mcp-resolver.js.map +1 -0
- package/dist/executor/permissions.d.ts +11 -0
- package/dist/executor/permissions.d.ts.map +1 -0
- package/dist/executor/permissions.js +32 -0
- package/dist/executor/permissions.js.map +1 -0
- package/dist/executor/profiles.d.ts +5 -0
- package/dist/executor/profiles.d.ts.map +1 -0
- package/dist/executor/profiles.js +35 -0
- package/dist/executor/profiles.js.map +1 -0
- package/dist/executor/prompt/assembler.d.ts +10 -0
- package/dist/executor/prompt/assembler.d.ts.map +1 -0
- package/dist/executor/prompt/assembler.js +28 -0
- package/dist/executor/prompt/assembler.js.map +1 -0
- package/dist/executor/prompt/index.d.ts +5 -0
- package/dist/executor/prompt/index.d.ts.map +1 -0
- package/dist/executor/prompt/index.js +5 -0
- package/dist/executor/prompt/index.js.map +1 -0
- package/dist/executor/prompt/sanitizer.d.ts +25 -0
- package/dist/executor/prompt/sanitizer.d.ts.map +1 -0
- package/dist/executor/prompt/sanitizer.js +81 -0
- package/dist/executor/prompt/sanitizer.js.map +1 -0
- package/dist/executor/prompt/schema-mapper.d.ts +7 -0
- package/dist/executor/prompt/schema-mapper.d.ts.map +1 -0
- package/dist/executor/prompt/schema-mapper.js +59 -0
- package/dist/executor/prompt/schema-mapper.js.map +1 -0
- package/dist/executor/prompt/templates.d.ts +31 -0
- package/dist/executor/prompt/templates.d.ts.map +1 -0
- package/dist/executor/prompt/templates.js +283 -0
- package/dist/executor/prompt/templates.js.map +1 -0
- package/dist/executor/ralph.d.ts +19 -0
- package/dist/executor/ralph.d.ts.map +1 -0
- package/dist/executor/ralph.js +112 -0
- package/dist/executor/ralph.js.map +1 -0
- package/dist/executor/test-quality.d.ts +117 -0
- package/dist/executor/test-quality.d.ts.map +1 -0
- package/dist/executor/test-quality.js +261 -0
- package/dist/executor/test-quality.js.map +1 -0
- package/dist/executor/validate.d.ts +15 -0
- package/dist/executor/validate.d.ts.map +1 -0
- package/dist/executor/validate.js +124 -0
- package/dist/executor/validate.js.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/license.d.ts +18 -0
- package/dist/license.d.ts.map +1 -0
- package/dist/license.js +44 -0
- package/dist/license.js.map +1 -0
- package/dist/logger.d.ts +43 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +91 -0
- package/dist/logger.js.map +1 -0
- package/dist/notifier/composite.d.ts +13 -0
- package/dist/notifier/composite.d.ts.map +1 -0
- package/dist/notifier/composite.js +28 -0
- package/dist/notifier/composite.js.map +1 -0
- package/dist/notifier/discord.d.ts +14 -0
- package/dist/notifier/discord.d.ts.map +1 -0
- package/dist/notifier/discord.js +105 -0
- package/dist/notifier/discord.js.map +1 -0
- package/dist/notifier/index.d.ts +6 -0
- package/dist/notifier/index.d.ts.map +1 -0
- package/dist/notifier/index.js +6 -0
- package/dist/notifier/index.js.map +1 -0
- package/dist/notifier/linear.d.ts +28 -0
- package/dist/notifier/linear.d.ts.map +1 -0
- package/dist/notifier/linear.js +138 -0
- package/dist/notifier/linear.js.map +1 -0
- package/dist/notifier/slack-alerts.d.ts +62 -0
- package/dist/notifier/slack-alerts.d.ts.map +1 -0
- package/dist/notifier/slack-alerts.js +184 -0
- package/dist/notifier/slack-alerts.js.map +1 -0
- package/dist/notifier/slack.d.ts +14 -0
- package/dist/notifier/slack.d.ts.map +1 -0
- package/dist/notifier/slack.js +146 -0
- package/dist/notifier/slack.js.map +1 -0
- package/dist/pipeline/automerge.d.ts +44 -0
- package/dist/pipeline/automerge.d.ts.map +1 -0
- package/dist/pipeline/automerge.js +135 -0
- package/dist/pipeline/automerge.js.map +1 -0
- package/dist/pipeline/config.d.ts +5 -0
- package/dist/pipeline/config.d.ts.map +1 -0
- package/dist/pipeline/config.js +68 -0
- package/dist/pipeline/config.js.map +1 -0
- package/dist/pipeline/distributed-lock.d.ts +50 -0
- package/dist/pipeline/distributed-lock.d.ts.map +1 -0
- package/dist/pipeline/distributed-lock.js +114 -0
- package/dist/pipeline/distributed-lock.js.map +1 -0
- package/dist/pipeline/error-classifier.d.ts +9 -0
- package/dist/pipeline/error-classifier.d.ts.map +1 -0
- package/dist/pipeline/error-classifier.js +25 -0
- package/dist/pipeline/error-classifier.js.map +1 -0
- package/dist/pipeline/index.d.ts +9 -0
- package/dist/pipeline/index.d.ts.map +1 -0
- package/dist/pipeline/index.js +9 -0
- package/dist/pipeline/index.js.map +1 -0
- package/dist/pipeline/pr-description.d.ts +35 -0
- package/dist/pipeline/pr-description.d.ts.map +1 -0
- package/dist/pipeline/pr-description.js +52 -0
- package/dist/pipeline/pr-description.js.map +1 -0
- package/dist/pipeline/queue.d.ts +7 -0
- package/dist/pipeline/queue.d.ts.map +1 -0
- package/dist/pipeline/queue.js +39 -0
- package/dist/pipeline/queue.js.map +1 -0
- package/dist/pipeline/router.d.ts +6 -0
- package/dist/pipeline/router.d.ts.map +1 -0
- package/dist/pipeline/router.js +19 -0
- package/dist/pipeline/router.js.map +1 -0
- package/dist/pipeline/runner.d.ts +142 -0
- package/dist/pipeline/runner.d.ts.map +1 -0
- package/dist/pipeline/runner.js +1848 -0
- package/dist/pipeline/runner.js.map +1 -0
- package/dist/pm/actions/approval-helpers.d.ts +11 -0
- package/dist/pm/actions/approval-helpers.d.ts.map +1 -0
- package/dist/pm/actions/approval-helpers.js +34 -0
- package/dist/pm/actions/approval-helpers.js.map +1 -0
- package/dist/pm/actions/cancel.d.ts +11 -0
- package/dist/pm/actions/cancel.d.ts.map +1 -0
- package/dist/pm/actions/cancel.js +68 -0
- package/dist/pm/actions/cancel.js.map +1 -0
- package/dist/pm/actions/deprioritize.d.ts +12 -0
- package/dist/pm/actions/deprioritize.d.ts.map +1 -0
- package/dist/pm/actions/deprioritize.js +55 -0
- package/dist/pm/actions/deprioritize.js.map +1 -0
- package/dist/pm/actions/promote.d.ts +11 -0
- package/dist/pm/actions/promote.d.ts.map +1 -0
- package/dist/pm/actions/promote.js +78 -0
- package/dist/pm/actions/promote.js.map +1 -0
- package/dist/pm/actions/recover-stuck.d.ts +42 -0
- package/dist/pm/actions/recover-stuck.d.ts.map +1 -0
- package/dist/pm/actions/recover-stuck.js +143 -0
- package/dist/pm/actions/recover-stuck.js.map +1 -0
- package/dist/pm/actions/recover.d.ts +18 -0
- package/dist/pm/actions/recover.d.ts.map +1 -0
- package/dist/pm/actions/recover.js +56 -0
- package/dist/pm/actions/recover.js.map +1 -0
- package/dist/pm/actions/resolve-approvals.d.ts +17 -0
- package/dist/pm/actions/resolve-approvals.d.ts.map +1 -0
- package/dist/pm/actions/resolve-approvals.js +92 -0
- package/dist/pm/actions/resolve-approvals.js.map +1 -0
- package/dist/pm/actions/start-todo.d.ts +28 -0
- package/dist/pm/actions/start-todo.d.ts.map +1 -0
- package/dist/pm/actions/start-todo.js +117 -0
- package/dist/pm/actions/start-todo.js.map +1 -0
- package/dist/pm/actions/triage.d.ts +13 -0
- package/dist/pm/actions/triage.d.ts.map +1 -0
- package/dist/pm/actions/triage.js +109 -0
- package/dist/pm/actions/triage.js.map +1 -0
- package/dist/pm/budget.d.ts +9 -0
- package/dist/pm/budget.d.ts.map +1 -0
- package/dist/pm/budget.js +62 -0
- package/dist/pm/budget.js.map +1 -0
- package/dist/pm/call-claude.d.ts +3 -0
- package/dist/pm/call-claude.d.ts.map +1 -0
- package/dist/pm/call-claude.js +37 -0
- package/dist/pm/call-claude.js.map +1 -0
- package/dist/pm/conflict-detector.d.ts +42 -0
- package/dist/pm/conflict-detector.d.ts.map +1 -0
- package/dist/pm/conflict-detector.js +116 -0
- package/dist/pm/conflict-detector.js.map +1 -0
- package/dist/pm/conflict.d.ts +20 -0
- package/dist/pm/conflict.d.ts.map +1 -0
- package/dist/pm/conflict.js +63 -0
- package/dist/pm/conflict.js.map +1 -0
- package/dist/pm/coordination.d.ts +50 -0
- package/dist/pm/coordination.d.ts.map +1 -0
- package/dist/pm/coordination.js +163 -0
- package/dist/pm/coordination.js.map +1 -0
- package/dist/pm/linear-helpers.d.ts +2 -0
- package/dist/pm/linear-helpers.d.ts.map +1 -0
- package/dist/pm/linear-helpers.js +16 -0
- package/dist/pm/linear-helpers.js.map +1 -0
- package/dist/pm/scheduler.d.ts +47 -0
- package/dist/pm/scheduler.d.ts.map +1 -0
- package/dist/pm/scheduler.js +346 -0
- package/dist/pm/scheduler.js.map +1 -0
- package/dist/pm/slack-helpers.d.ts +2 -0
- package/dist/pm/slack-helpers.d.ts.map +1 -0
- package/dist/pm/slack-helpers.js +24 -0
- package/dist/pm/slack-helpers.js.map +1 -0
- package/dist/pm/slack-interface.d.ts +133 -0
- package/dist/pm/slack-interface.d.ts.map +1 -0
- package/dist/pm/slack-interface.js +641 -0
- package/dist/pm/slack-interface.js.map +1 -0
- package/dist/pm/slack.d.ts +18 -0
- package/dist/pm/slack.d.ts.map +1 -0
- package/dist/pm/slack.js +144 -0
- package/dist/pm/slack.js.map +1 -0
- package/dist/pm/types.d.ts +99 -0
- package/dist/pm/types.d.ts.map +1 -0
- package/dist/pm/types.js +17 -0
- package/dist/pm/types.js.map +1 -0
- package/dist/repo/config.d.ts +35 -0
- package/dist/repo/config.d.ts.map +1 -0
- package/dist/repo/config.js +72 -0
- package/dist/repo/config.js.map +1 -0
- package/dist/repo/devcontainer.d.ts +33 -0
- package/dist/repo/devcontainer.d.ts.map +1 -0
- package/dist/repo/devcontainer.js +90 -0
- package/dist/repo/devcontainer.js.map +1 -0
- package/dist/repo/git.d.ts +185 -0
- package/dist/repo/git.d.ts.map +1 -0
- package/dist/repo/git.js +586 -0
- package/dist/repo/git.js.map +1 -0
- package/dist/repo/github.d.ts +56 -0
- package/dist/repo/github.d.ts.map +1 -0
- package/dist/repo/github.js +164 -0
- package/dist/repo/github.js.map +1 -0
- package/dist/repo/gitlab.d.ts +47 -0
- package/dist/repo/gitlab.d.ts.map +1 -0
- package/dist/repo/gitlab.js +91 -0
- package/dist/repo/gitlab.js.map +1 -0
- package/dist/repo/index.d.ts +7 -0
- package/dist/repo/index.d.ts.map +1 -0
- package/dist/repo/index.js +5 -0
- package/dist/repo/index.js.map +1 -0
- package/dist/repo/tech-stack.d.ts +13 -0
- package/dist/repo/tech-stack.d.ts.map +1 -0
- package/dist/repo/tech-stack.js +112 -0
- package/dist/repo/tech-stack.js.map +1 -0
- package/dist/security/index.d.ts +3 -0
- package/dist/security/index.d.ts.map +1 -0
- package/dist/security/index.js +3 -0
- package/dist/security/index.js.map +1 -0
- package/dist/security/review-checklist.d.ts +9 -0
- package/dist/security/review-checklist.d.ts.map +1 -0
- package/dist/security/review-checklist.js +46 -0
- package/dist/security/review-checklist.js.map +1 -0
- package/dist/security/sandbox.d.ts +7 -0
- package/dist/security/sandbox.d.ts.map +1 -0
- package/dist/security/sandbox.js +31 -0
- package/dist/security/sandbox.js.map +1 -0
- package/dist/server.d.ts +48 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +90 -0
- package/dist/server.js.map +1 -0
- package/dist/types.d.ts +1230 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +225 -0
- package/dist/types.js.map +1 -0
- package/dist/webhook/github-handler.d.ts +39 -0
- package/dist/webhook/github-handler.d.ts.map +1 -0
- package/dist/webhook/github-handler.js +439 -0
- package/dist/webhook/github-handler.js.map +1 -0
- package/dist/webhook/handler.d.ts +16 -0
- package/dist/webhook/handler.d.ts.map +1 -0
- package/dist/webhook/handler.js +171 -0
- package/dist/webhook/handler.js.map +1 -0
- package/dist/webhook/index.d.ts +5 -0
- package/dist/webhook/index.d.ts.map +1 -0
- package/dist/webhook/index.js +5 -0
- package/dist/webhook/index.js.map +1 -0
- package/dist/webhook/parser.d.ts +18 -0
- package/dist/webhook/parser.d.ts.map +1 -0
- package/dist/webhook/parser.js +30 -0
- package/dist/webhook/parser.js.map +1 -0
- package/dist/webhook/signature.d.ts +2 -0
- package/dist/webhook/signature.d.ts.map +1 -0
- package/dist/webhook/signature.js +14 -0
- package/dist/webhook/signature.js.map +1 -0
- package/package.json +40 -0
|
@@ -0,0 +1,645 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PR Automerge integration tests — BEC-117
|
|
3
|
+
*
|
|
4
|
+
* Tests that the GitHub webhook handler correctly triggers automerge when
|
|
5
|
+
* a PR event is received and the pipeline config has autoMergeConfig set.
|
|
6
|
+
*
|
|
7
|
+
* Covers:
|
|
8
|
+
* 1. check_suite.completed event triggers automerge when all criteria pass
|
|
9
|
+
* 2. check_suite.completed does NOT trigger automerge when criteria fail
|
|
10
|
+
* 3. pull_request.labeled event triggers automerge check
|
|
11
|
+
* 4. status event triggers automerge check via branch lookup
|
|
12
|
+
* 5. No-op when GitHub App credentials are missing
|
|
13
|
+
* 6. No-op when pipeline has no autoMergeConfig
|
|
14
|
+
*
|
|
15
|
+
* Also unit-tests checkAutoMergeEligibility in isolation.
|
|
16
|
+
*/
|
|
17
|
+
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
18
|
+
import { createHmac } from "node:crypto";
|
|
19
|
+
import { Hono } from "hono";
|
|
20
|
+
import { createDb } from "../db/client.js";
|
|
21
|
+
import { createGitHubWebhookHandler } from "../webhook/github-handler.js";
|
|
22
|
+
import { pipelineRuns } from "../db/schema.js";
|
|
23
|
+
import { checkAutoMergeEligibility } from "../pipeline/automerge.js";
|
|
24
|
+
// ---------------------------------------------------------------------------
|
|
25
|
+
// Module mocks
|
|
26
|
+
// ---------------------------------------------------------------------------
|
|
27
|
+
const mockMergePR = vi.fn().mockResolvedValue({ data: { merged: true, message: "Merged" } });
|
|
28
|
+
const mockListReviews = vi.fn().mockResolvedValue({ data: [] });
|
|
29
|
+
const mockGetCombinedStatus = vi.fn().mockResolvedValue({ data: { statuses: [] } });
|
|
30
|
+
const mockChecksListForRef = vi.fn().mockResolvedValue({ data: { check_runs: [] } });
|
|
31
|
+
const mockPullsList = vi.fn().mockResolvedValue({ data: [] });
|
|
32
|
+
const mockPullsGet = vi.fn().mockResolvedValue({
|
|
33
|
+
data: {
|
|
34
|
+
draft: false,
|
|
35
|
+
merged: false,
|
|
36
|
+
state: "open",
|
|
37
|
+
base: { ref: "main" },
|
|
38
|
+
head: { sha: "abc123" },
|
|
39
|
+
labels: [],
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
vi.mock("@octokit/rest", () => ({
|
|
43
|
+
Octokit: vi.fn().mockImplementation(() => ({
|
|
44
|
+
pulls: {
|
|
45
|
+
get: mockPullsGet,
|
|
46
|
+
merge: mockMergePR,
|
|
47
|
+
listReviews: mockListReviews,
|
|
48
|
+
list: mockPullsList,
|
|
49
|
+
},
|
|
50
|
+
repos: {
|
|
51
|
+
getCombinedStatusForRef: mockGetCombinedStatus,
|
|
52
|
+
},
|
|
53
|
+
checks: {
|
|
54
|
+
listForRef: mockChecksListForRef,
|
|
55
|
+
},
|
|
56
|
+
})),
|
|
57
|
+
}));
|
|
58
|
+
vi.mock("@octokit/auth-app", () => ({
|
|
59
|
+
createAppAuth: vi.fn().mockReturnValue({}),
|
|
60
|
+
}));
|
|
61
|
+
// ---------------------------------------------------------------------------
|
|
62
|
+
// Helpers
|
|
63
|
+
// ---------------------------------------------------------------------------
|
|
64
|
+
const WEBHOOK_SECRET = "test-automerge-secret";
|
|
65
|
+
function signPayload(body) {
|
|
66
|
+
return `sha256=${createHmac("sha256", WEBHOOK_SECRET).update(body).digest("hex")}`;
|
|
67
|
+
}
|
|
68
|
+
async function postGitHubWebhook(app, event, payload) {
|
|
69
|
+
const body = JSON.stringify(payload);
|
|
70
|
+
const res = await app.fetch(new Request("http://localhost/webhooks/github", {
|
|
71
|
+
method: "POST",
|
|
72
|
+
headers: {
|
|
73
|
+
"Content-Type": "application/json",
|
|
74
|
+
"X-GitHub-Event": event,
|
|
75
|
+
"X-Hub-Signature-256": signPayload(body),
|
|
76
|
+
},
|
|
77
|
+
body,
|
|
78
|
+
}));
|
|
79
|
+
return { status: res.status, json: (await res.json()) };
|
|
80
|
+
}
|
|
81
|
+
const GITHUB_CONFIG = { appId: "12345", privateKey: "fake-key", installationId: 1 };
|
|
82
|
+
const REPO_CONFIG = {
|
|
83
|
+
url: "https://github.com/test/repo.git",
|
|
84
|
+
defaultBranch: "main",
|
|
85
|
+
testCommand: "pnpm test",
|
|
86
|
+
buildCommand: "pnpm build",
|
|
87
|
+
};
|
|
88
|
+
function makeAutoMergePipelineConfig(overrides = {}) {
|
|
89
|
+
return {
|
|
90
|
+
name: "Auto Implement",
|
|
91
|
+
stages: ["implement"],
|
|
92
|
+
retry: { maxAttempts: 0, strategy: "fail-fast" },
|
|
93
|
+
review: { requiredApprovals: 0 },
|
|
94
|
+
prStrategy: "ready",
|
|
95
|
+
autoMergeConfig: {
|
|
96
|
+
mergeMethod: "squash",
|
|
97
|
+
...overrides,
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function checkSuitePayload(prNumber, prBranch, prUrl) {
|
|
102
|
+
return {
|
|
103
|
+
action: "completed",
|
|
104
|
+
check_suite: {
|
|
105
|
+
id: 999,
|
|
106
|
+
conclusion: "success",
|
|
107
|
+
pull_requests: [
|
|
108
|
+
{
|
|
109
|
+
number: prNumber,
|
|
110
|
+
html_url: prUrl,
|
|
111
|
+
head: { ref: prBranch, sha: "abc123" },
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
},
|
|
115
|
+
repository: { name: "repo", owner: { login: "test" } },
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
// ---------------------------------------------------------------------------
|
|
119
|
+
// Tests
|
|
120
|
+
// ---------------------------------------------------------------------------
|
|
121
|
+
describe("PR Automerge — GitHub webhook event handling", () => {
|
|
122
|
+
let db;
|
|
123
|
+
beforeEach(async () => {
|
|
124
|
+
vi.clearAllMocks();
|
|
125
|
+
mockPullsGet.mockResolvedValue({
|
|
126
|
+
data: {
|
|
127
|
+
draft: false,
|
|
128
|
+
merged: false,
|
|
129
|
+
state: "open",
|
|
130
|
+
base: { ref: "main" },
|
|
131
|
+
head: { sha: "abc123" },
|
|
132
|
+
labels: [],
|
|
133
|
+
},
|
|
134
|
+
});
|
|
135
|
+
mockMergePR.mockResolvedValue({ data: { merged: true, message: "Merged" } });
|
|
136
|
+
mockListReviews.mockResolvedValue({ data: [] });
|
|
137
|
+
mockGetCombinedStatus.mockResolvedValue({ data: { statuses: [] } });
|
|
138
|
+
mockChecksListForRef.mockResolvedValue({ data: { check_runs: [] } });
|
|
139
|
+
db = await createDb({ driver: "sqlite", connectionString: ":memory:" });
|
|
140
|
+
});
|
|
141
|
+
// ---------------------------------------------------------------------------
|
|
142
|
+
// 1. check_suite.completed → merge triggered when all criteria pass
|
|
143
|
+
// ---------------------------------------------------------------------------
|
|
144
|
+
it("triggers automerge on check_suite.completed when all criteria pass", async () => {
|
|
145
|
+
const prUrl = "https://github.com/test/repo/pull/1";
|
|
146
|
+
const prBranch = "agent/BEC-117-feature";
|
|
147
|
+
// Seed a completed pipeline run with a PR URL
|
|
148
|
+
await db.insert(pipelineRuns).values({
|
|
149
|
+
id: "run-001",
|
|
150
|
+
issueId: "BEC-117",
|
|
151
|
+
issueTitle: "Feature",
|
|
152
|
+
pipelineKey: "auto-implement",
|
|
153
|
+
repoUrl: "https://github.com/test/repo.git",
|
|
154
|
+
branch: prBranch,
|
|
155
|
+
status: "completed",
|
|
156
|
+
prUrl,
|
|
157
|
+
startedAt: new Date(),
|
|
158
|
+
});
|
|
159
|
+
const pipelineConfig = makeAutoMergePipelineConfig();
|
|
160
|
+
const app = new Hono();
|
|
161
|
+
app.route("/", createGitHubWebhookHandler({
|
|
162
|
+
webhookSecret: WEBHOOK_SECRET,
|
|
163
|
+
runner: {},
|
|
164
|
+
pipelineConfigs: { "auto-implement": pipelineConfig },
|
|
165
|
+
repoConfigs: { "test-repo": REPO_CONFIG },
|
|
166
|
+
db: db,
|
|
167
|
+
github: GITHUB_CONFIG,
|
|
168
|
+
}));
|
|
169
|
+
const { status, json } = await postGitHubWebhook(app, "check_suite", checkSuitePayload(1, prBranch, prUrl));
|
|
170
|
+
expect(status).toBe(200);
|
|
171
|
+
expect(json.ok).toBe(true);
|
|
172
|
+
// Verify merge API was called
|
|
173
|
+
expect(mockMergePR).toHaveBeenCalledWith(expect.objectContaining({
|
|
174
|
+
owner: "test",
|
|
175
|
+
repo: "repo",
|
|
176
|
+
pull_number: 1,
|
|
177
|
+
merge_method: "squash",
|
|
178
|
+
}));
|
|
179
|
+
// Verify DB was updated
|
|
180
|
+
const rows = await db.select().from(pipelineRuns).where();
|
|
181
|
+
expect(rows[0].autoMerged).toBeTruthy();
|
|
182
|
+
expect(rows[0].autoMergeReason).toMatch(/auto-merged successfully/);
|
|
183
|
+
});
|
|
184
|
+
// ---------------------------------------------------------------------------
|
|
185
|
+
// 2. check_suite.completed → NO merge when PR is a draft
|
|
186
|
+
// ---------------------------------------------------------------------------
|
|
187
|
+
it("does not merge when PR is a draft", async () => {
|
|
188
|
+
mockPullsGet.mockResolvedValue({
|
|
189
|
+
data: {
|
|
190
|
+
draft: true,
|
|
191
|
+
merged: false,
|
|
192
|
+
state: "open",
|
|
193
|
+
base: { ref: "main" },
|
|
194
|
+
head: { sha: "abc123" },
|
|
195
|
+
labels: [],
|
|
196
|
+
},
|
|
197
|
+
});
|
|
198
|
+
const prUrl = "https://github.com/test/repo/pull/2";
|
|
199
|
+
const prBranch = "agent/BEC-117-draft";
|
|
200
|
+
await db.insert(pipelineRuns).values({
|
|
201
|
+
id: "run-002",
|
|
202
|
+
issueId: "BEC-117-D",
|
|
203
|
+
issueTitle: "Draft Feature",
|
|
204
|
+
pipelineKey: "auto-implement",
|
|
205
|
+
repoUrl: "https://github.com/test/repo.git",
|
|
206
|
+
branch: prBranch,
|
|
207
|
+
status: "completed",
|
|
208
|
+
prUrl,
|
|
209
|
+
startedAt: new Date(),
|
|
210
|
+
});
|
|
211
|
+
const pipelineConfig = makeAutoMergePipelineConfig();
|
|
212
|
+
const app = new Hono();
|
|
213
|
+
app.route("/", createGitHubWebhookHandler({
|
|
214
|
+
webhookSecret: WEBHOOK_SECRET,
|
|
215
|
+
runner: {},
|
|
216
|
+
pipelineConfigs: { "auto-implement": pipelineConfig },
|
|
217
|
+
repoConfigs: {},
|
|
218
|
+
db: db,
|
|
219
|
+
github: GITHUB_CONFIG,
|
|
220
|
+
}));
|
|
221
|
+
await postGitHubWebhook(app, "check_suite", checkSuitePayload(2, prBranch, prUrl));
|
|
222
|
+
expect(mockMergePR).not.toHaveBeenCalled();
|
|
223
|
+
const rows = await db.select().from(pipelineRuns).where();
|
|
224
|
+
expect(rows[0].autoMerged).toBeFalsy();
|
|
225
|
+
expect(rows[0].autoMergeReason).toMatch(/draft/i);
|
|
226
|
+
});
|
|
227
|
+
// ---------------------------------------------------------------------------
|
|
228
|
+
// 3. Missing required status check → no merge
|
|
229
|
+
// ---------------------------------------------------------------------------
|
|
230
|
+
it("does not merge when required status check has not passed", async () => {
|
|
231
|
+
mockGetCombinedStatus.mockResolvedValue({ data: { statuses: [] } });
|
|
232
|
+
mockChecksListForRef.mockResolvedValue({ data: { check_runs: [] } });
|
|
233
|
+
const prUrl = "https://github.com/test/repo/pull/3";
|
|
234
|
+
const prBranch = "agent/BEC-117-checks";
|
|
235
|
+
await db.insert(pipelineRuns).values({
|
|
236
|
+
id: "run-003",
|
|
237
|
+
issueId: "BEC-117-C",
|
|
238
|
+
issueTitle: "Checks Feature",
|
|
239
|
+
pipelineKey: "auto-implement",
|
|
240
|
+
repoUrl: "https://github.com/test/repo.git",
|
|
241
|
+
branch: prBranch,
|
|
242
|
+
status: "completed",
|
|
243
|
+
prUrl,
|
|
244
|
+
startedAt: new Date(),
|
|
245
|
+
});
|
|
246
|
+
const pipelineConfig = makeAutoMergePipelineConfig({ requiredStatusChecks: ["ci/tests"] });
|
|
247
|
+
const app = new Hono();
|
|
248
|
+
app.route("/", createGitHubWebhookHandler({
|
|
249
|
+
webhookSecret: WEBHOOK_SECRET,
|
|
250
|
+
runner: {},
|
|
251
|
+
pipelineConfigs: { "auto-implement": pipelineConfig },
|
|
252
|
+
repoConfigs: {},
|
|
253
|
+
db: db,
|
|
254
|
+
github: GITHUB_CONFIG,
|
|
255
|
+
}));
|
|
256
|
+
await postGitHubWebhook(app, "check_suite", checkSuitePayload(3, prBranch, prUrl));
|
|
257
|
+
expect(mockMergePR).not.toHaveBeenCalled();
|
|
258
|
+
const rows = await db.select().from(pipelineRuns).where();
|
|
259
|
+
expect(rows[0].autoMerged).toBeFalsy();
|
|
260
|
+
expect(rows[0].autoMergeReason).toMatch(/ci\/tests/);
|
|
261
|
+
});
|
|
262
|
+
// ---------------------------------------------------------------------------
|
|
263
|
+
// 4. Insufficient approvals → no merge
|
|
264
|
+
// ---------------------------------------------------------------------------
|
|
265
|
+
it("does not merge when minimumApprovingReviews is not met", async () => {
|
|
266
|
+
mockListReviews.mockResolvedValue({ data: [] }); // 0 approvals
|
|
267
|
+
const prUrl = "https://github.com/test/repo/pull/4";
|
|
268
|
+
const prBranch = "agent/BEC-117-approvals";
|
|
269
|
+
await db.insert(pipelineRuns).values({
|
|
270
|
+
id: "run-004",
|
|
271
|
+
issueId: "BEC-117-A",
|
|
272
|
+
issueTitle: "Approval Feature",
|
|
273
|
+
pipelineKey: "auto-implement",
|
|
274
|
+
repoUrl: "https://github.com/test/repo.git",
|
|
275
|
+
branch: prBranch,
|
|
276
|
+
status: "completed",
|
|
277
|
+
prUrl,
|
|
278
|
+
startedAt: new Date(),
|
|
279
|
+
});
|
|
280
|
+
const pipelineConfig = makeAutoMergePipelineConfig({ minimumApprovingReviews: 2 });
|
|
281
|
+
const app = new Hono();
|
|
282
|
+
app.route("/", createGitHubWebhookHandler({
|
|
283
|
+
webhookSecret: WEBHOOK_SECRET,
|
|
284
|
+
runner: {},
|
|
285
|
+
pipelineConfigs: { "auto-implement": pipelineConfig },
|
|
286
|
+
repoConfigs: {},
|
|
287
|
+
db: db,
|
|
288
|
+
github: GITHUB_CONFIG,
|
|
289
|
+
}));
|
|
290
|
+
await postGitHubWebhook(app, "check_suite", checkSuitePayload(4, prBranch, prUrl));
|
|
291
|
+
expect(mockMergePR).not.toHaveBeenCalled();
|
|
292
|
+
const rows = await db.select().from(pipelineRuns).where();
|
|
293
|
+
expect(rows[0].autoMergeReason).toMatch(/approving review/);
|
|
294
|
+
});
|
|
295
|
+
// ---------------------------------------------------------------------------
|
|
296
|
+
// 5. Required label missing → no merge
|
|
297
|
+
// ---------------------------------------------------------------------------
|
|
298
|
+
it("does not merge when required label is missing from PR", async () => {
|
|
299
|
+
mockPullsGet.mockResolvedValue({
|
|
300
|
+
data: {
|
|
301
|
+
draft: false,
|
|
302
|
+
merged: false,
|
|
303
|
+
state: "open",
|
|
304
|
+
base: { ref: "main" },
|
|
305
|
+
head: { sha: "abc123" },
|
|
306
|
+
labels: [{ name: "bug" }], // missing "ready-to-merge"
|
|
307
|
+
},
|
|
308
|
+
});
|
|
309
|
+
const prUrl = "https://github.com/test/repo/pull/5";
|
|
310
|
+
const prBranch = "agent/BEC-117-labels";
|
|
311
|
+
await db.insert(pipelineRuns).values({
|
|
312
|
+
id: "run-005",
|
|
313
|
+
issueId: "BEC-117-L",
|
|
314
|
+
issueTitle: "Labels Feature",
|
|
315
|
+
pipelineKey: "auto-implement",
|
|
316
|
+
repoUrl: "https://github.com/test/repo.git",
|
|
317
|
+
branch: prBranch,
|
|
318
|
+
status: "completed",
|
|
319
|
+
prUrl,
|
|
320
|
+
startedAt: new Date(),
|
|
321
|
+
});
|
|
322
|
+
const pipelineConfig = makeAutoMergePipelineConfig({ requiredLabels: ["ready-to-merge"] });
|
|
323
|
+
const app = new Hono();
|
|
324
|
+
app.route("/", createGitHubWebhookHandler({
|
|
325
|
+
webhookSecret: WEBHOOK_SECRET,
|
|
326
|
+
runner: {},
|
|
327
|
+
pipelineConfigs: { "auto-implement": pipelineConfig },
|
|
328
|
+
repoConfigs: {},
|
|
329
|
+
db: db,
|
|
330
|
+
github: GITHUB_CONFIG,
|
|
331
|
+
}));
|
|
332
|
+
await postGitHubWebhook(app, "check_suite", checkSuitePayload(5, prBranch, prUrl));
|
|
333
|
+
expect(mockMergePR).not.toHaveBeenCalled();
|
|
334
|
+
const rows = await db.select().from(pipelineRuns).where();
|
|
335
|
+
expect(rows[0].autoMergeReason).toMatch(/ready-to-merge/);
|
|
336
|
+
});
|
|
337
|
+
// ---------------------------------------------------------------------------
|
|
338
|
+
// 6. Branch not in allowedBranches → no merge
|
|
339
|
+
// ---------------------------------------------------------------------------
|
|
340
|
+
it("does not merge when base branch is not in allowedBranches", async () => {
|
|
341
|
+
mockPullsGet.mockResolvedValue({
|
|
342
|
+
data: {
|
|
343
|
+
draft: false,
|
|
344
|
+
merged: false,
|
|
345
|
+
state: "open",
|
|
346
|
+
base: { ref: "develop" }, // not in allowedBranches
|
|
347
|
+
head: { sha: "abc123" },
|
|
348
|
+
labels: [],
|
|
349
|
+
},
|
|
350
|
+
});
|
|
351
|
+
const prUrl = "https://github.com/test/repo/pull/6";
|
|
352
|
+
const prBranch = "agent/BEC-117-branches";
|
|
353
|
+
await db.insert(pipelineRuns).values({
|
|
354
|
+
id: "run-006",
|
|
355
|
+
issueId: "BEC-117-B",
|
|
356
|
+
issueTitle: "Branch Feature",
|
|
357
|
+
pipelineKey: "auto-implement",
|
|
358
|
+
repoUrl: "https://github.com/test/repo.git",
|
|
359
|
+
branch: prBranch,
|
|
360
|
+
status: "completed",
|
|
361
|
+
prUrl,
|
|
362
|
+
startedAt: new Date(),
|
|
363
|
+
});
|
|
364
|
+
const pipelineConfig = makeAutoMergePipelineConfig({ allowedBranches: ["main", "release"] });
|
|
365
|
+
const app = new Hono();
|
|
366
|
+
app.route("/", createGitHubWebhookHandler({
|
|
367
|
+
webhookSecret: WEBHOOK_SECRET,
|
|
368
|
+
runner: {},
|
|
369
|
+
pipelineConfigs: { "auto-implement": pipelineConfig },
|
|
370
|
+
repoConfigs: {},
|
|
371
|
+
db: db,
|
|
372
|
+
github: GITHUB_CONFIG,
|
|
373
|
+
}));
|
|
374
|
+
await postGitHubWebhook(app, "check_suite", checkSuitePayload(6, prBranch, prUrl));
|
|
375
|
+
expect(mockMergePR).not.toHaveBeenCalled();
|
|
376
|
+
const rows = await db.select().from(pipelineRuns).where();
|
|
377
|
+
expect(rows[0].autoMergeReason).toMatch(/develop/);
|
|
378
|
+
});
|
|
379
|
+
// ---------------------------------------------------------------------------
|
|
380
|
+
// 7. No GitHub credentials → skip without error
|
|
381
|
+
// ---------------------------------------------------------------------------
|
|
382
|
+
it("skips automerge when no GitHub App credentials are configured", async () => {
|
|
383
|
+
const prUrl = "https://github.com/test/repo/pull/7";
|
|
384
|
+
const prBranch = "agent/BEC-117-no-creds";
|
|
385
|
+
await db.insert(pipelineRuns).values({
|
|
386
|
+
id: "run-007",
|
|
387
|
+
issueId: "BEC-117-NC",
|
|
388
|
+
issueTitle: "NoCreds Feature",
|
|
389
|
+
pipelineKey: "auto-implement",
|
|
390
|
+
repoUrl: "https://github.com/test/repo.git",
|
|
391
|
+
branch: prBranch,
|
|
392
|
+
status: "completed",
|
|
393
|
+
prUrl,
|
|
394
|
+
startedAt: new Date(),
|
|
395
|
+
});
|
|
396
|
+
const pipelineConfig = makeAutoMergePipelineConfig();
|
|
397
|
+
const app = new Hono();
|
|
398
|
+
app.route("/", createGitHubWebhookHandler({
|
|
399
|
+
webhookSecret: WEBHOOK_SECRET,
|
|
400
|
+
runner: {},
|
|
401
|
+
pipelineConfigs: { "auto-implement": pipelineConfig },
|
|
402
|
+
repoConfigs: {},
|
|
403
|
+
db: db,
|
|
404
|
+
// no github credentials
|
|
405
|
+
}));
|
|
406
|
+
const { status } = await postGitHubWebhook(app, "check_suite", checkSuitePayload(7, prBranch, prUrl));
|
|
407
|
+
expect(status).toBe(200);
|
|
408
|
+
expect(mockMergePR).not.toHaveBeenCalled();
|
|
409
|
+
});
|
|
410
|
+
// ---------------------------------------------------------------------------
|
|
411
|
+
// 8. No autoMergeConfig in pipeline → skip
|
|
412
|
+
// ---------------------------------------------------------------------------
|
|
413
|
+
it("skips automerge when pipeline has no autoMergeConfig", async () => {
|
|
414
|
+
const prUrl = "https://github.com/test/repo/pull/8";
|
|
415
|
+
const prBranch = "agent/BEC-117-no-config";
|
|
416
|
+
await db.insert(pipelineRuns).values({
|
|
417
|
+
id: "run-008",
|
|
418
|
+
issueId: "BEC-117-NP",
|
|
419
|
+
issueTitle: "NoPipeline Feature",
|
|
420
|
+
pipelineKey: "auto-implement",
|
|
421
|
+
repoUrl: "https://github.com/test/repo.git",
|
|
422
|
+
branch: prBranch,
|
|
423
|
+
status: "completed",
|
|
424
|
+
prUrl,
|
|
425
|
+
startedAt: new Date(),
|
|
426
|
+
});
|
|
427
|
+
// Pipeline config without autoMergeConfig
|
|
428
|
+
const pipelineConfig = {
|
|
429
|
+
name: "Auto Implement",
|
|
430
|
+
stages: ["implement"],
|
|
431
|
+
retry: { maxAttempts: 0, strategy: "fail-fast" },
|
|
432
|
+
review: { requiredApprovals: 0 },
|
|
433
|
+
prStrategy: "ready",
|
|
434
|
+
};
|
|
435
|
+
const app = new Hono();
|
|
436
|
+
app.route("/", createGitHubWebhookHandler({
|
|
437
|
+
webhookSecret: WEBHOOK_SECRET,
|
|
438
|
+
runner: {},
|
|
439
|
+
pipelineConfigs: { "auto-implement": pipelineConfig },
|
|
440
|
+
repoConfigs: {},
|
|
441
|
+
db: db,
|
|
442
|
+
github: GITHUB_CONFIG,
|
|
443
|
+
}));
|
|
444
|
+
await postGitHubWebhook(app, "check_suite", checkSuitePayload(8, prBranch, prUrl));
|
|
445
|
+
expect(mockMergePR).not.toHaveBeenCalled();
|
|
446
|
+
});
|
|
447
|
+
// ---------------------------------------------------------------------------
|
|
448
|
+
// 9. pull_request.labeled event also triggers automerge check
|
|
449
|
+
// ---------------------------------------------------------------------------
|
|
450
|
+
it("triggers automerge on pull_request.labeled event", async () => {
|
|
451
|
+
const prUrl = "https://github.com/test/repo/pull/9";
|
|
452
|
+
const prBranch = "agent/BEC-117-labeled";
|
|
453
|
+
await db.insert(pipelineRuns).values({
|
|
454
|
+
id: "run-009",
|
|
455
|
+
issueId: "BEC-117-PL",
|
|
456
|
+
issueTitle: "Labeled Feature",
|
|
457
|
+
pipelineKey: "auto-implement",
|
|
458
|
+
repoUrl: "https://github.com/test/repo.git",
|
|
459
|
+
branch: prBranch,
|
|
460
|
+
status: "completed",
|
|
461
|
+
prUrl,
|
|
462
|
+
startedAt: new Date(),
|
|
463
|
+
});
|
|
464
|
+
const pipelineConfig = makeAutoMergePipelineConfig();
|
|
465
|
+
const app = new Hono();
|
|
466
|
+
app.route("/", createGitHubWebhookHandler({
|
|
467
|
+
webhookSecret: WEBHOOK_SECRET,
|
|
468
|
+
runner: {},
|
|
469
|
+
pipelineConfigs: { "auto-implement": pipelineConfig },
|
|
470
|
+
repoConfigs: {},
|
|
471
|
+
db: db,
|
|
472
|
+
github: GITHUB_CONFIG,
|
|
473
|
+
}));
|
|
474
|
+
const payload = {
|
|
475
|
+
action: "labeled",
|
|
476
|
+
label: { name: "automerge" },
|
|
477
|
+
pull_request: {
|
|
478
|
+
number: 9,
|
|
479
|
+
html_url: prUrl,
|
|
480
|
+
draft: false,
|
|
481
|
+
head: { ref: prBranch, sha: "abc123" },
|
|
482
|
+
base: { ref: "main" },
|
|
483
|
+
labels: [{ name: "automerge" }],
|
|
484
|
+
},
|
|
485
|
+
repository: { name: "repo", owner: { login: "test" } },
|
|
486
|
+
};
|
|
487
|
+
await postGitHubWebhook(app, "pull_request", payload);
|
|
488
|
+
expect(mockMergePR).toHaveBeenCalled();
|
|
489
|
+
});
|
|
490
|
+
// ---------------------------------------------------------------------------
|
|
491
|
+
// 10. Branch protection prevents merge (405)
|
|
492
|
+
// ---------------------------------------------------------------------------
|
|
493
|
+
it("handles branch protection preventing merge gracefully", async () => {
|
|
494
|
+
mockMergePR.mockRejectedValue(Object.assign(new Error("Required status check failed"), { status: 405 }));
|
|
495
|
+
const prUrl = "https://github.com/test/repo/pull/10";
|
|
496
|
+
const prBranch = "agent/BEC-117-protected";
|
|
497
|
+
await db.insert(pipelineRuns).values({
|
|
498
|
+
id: "run-010",
|
|
499
|
+
issueId: "BEC-117-P",
|
|
500
|
+
issueTitle: "Protected Branch Feature",
|
|
501
|
+
pipelineKey: "auto-implement",
|
|
502
|
+
repoUrl: "https://github.com/test/repo.git",
|
|
503
|
+
branch: prBranch,
|
|
504
|
+
status: "completed",
|
|
505
|
+
prUrl,
|
|
506
|
+
startedAt: new Date(),
|
|
507
|
+
});
|
|
508
|
+
const pipelineConfig = makeAutoMergePipelineConfig();
|
|
509
|
+
const app = new Hono();
|
|
510
|
+
app.route("/", createGitHubWebhookHandler({
|
|
511
|
+
webhookSecret: WEBHOOK_SECRET,
|
|
512
|
+
runner: {},
|
|
513
|
+
pipelineConfigs: { "auto-implement": pipelineConfig },
|
|
514
|
+
repoConfigs: {},
|
|
515
|
+
db: db,
|
|
516
|
+
github: GITHUB_CONFIG,
|
|
517
|
+
}));
|
|
518
|
+
const { status } = await postGitHubWebhook(app, "check_suite", checkSuitePayload(10, prBranch, prUrl));
|
|
519
|
+
expect(status).toBe(200); // Handler should not crash
|
|
520
|
+
const rows = await db.select().from(pipelineRuns).where();
|
|
521
|
+
expect(rows[0].autoMerged).toBeFalsy();
|
|
522
|
+
expect(rows[0].autoMergeReason).toMatch(/[Bb]ranch protection/);
|
|
523
|
+
});
|
|
524
|
+
});
|
|
525
|
+
// ---------------------------------------------------------------------------
|
|
526
|
+
// Unit tests for checkAutoMergeEligibility
|
|
527
|
+
// ---------------------------------------------------------------------------
|
|
528
|
+
describe("checkAutoMergeEligibility unit tests", () => {
|
|
529
|
+
beforeEach(() => {
|
|
530
|
+
vi.clearAllMocks();
|
|
531
|
+
mockPullsGet.mockResolvedValue({
|
|
532
|
+
data: {
|
|
533
|
+
draft: false,
|
|
534
|
+
merged: false,
|
|
535
|
+
state: "open",
|
|
536
|
+
base: { ref: "main" },
|
|
537
|
+
head: { sha: "abc123" },
|
|
538
|
+
labels: [],
|
|
539
|
+
},
|
|
540
|
+
});
|
|
541
|
+
});
|
|
542
|
+
/**
|
|
543
|
+
* Build a minimal Octokit-shaped mock that delegates to the module-level
|
|
544
|
+
* mock functions. This avoids calling `new Octokit()` (which bypasses
|
|
545
|
+
* vi.mock when used via require() inside a function) and keeps the test
|
|
546
|
+
* behaviour deterministic.
|
|
547
|
+
*/
|
|
548
|
+
function makeOctokit() {
|
|
549
|
+
return {
|
|
550
|
+
pulls: { get: mockPullsGet, listReviews: mockListReviews, merge: mockMergePR, list: mockPullsList },
|
|
551
|
+
repos: { getCombinedStatusForRef: mockGetCombinedStatus },
|
|
552
|
+
checks: { listForRef: mockChecksListForRef },
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
it("returns eligible when no criteria are configured", async () => {
|
|
556
|
+
const result = await checkAutoMergeEligibility(makeOctokit(), "owner", "repo", 1, {});
|
|
557
|
+
expect(result.eligible).toBe(true);
|
|
558
|
+
});
|
|
559
|
+
it("returns ineligible for draft PRs", async () => {
|
|
560
|
+
mockPullsGet.mockResolvedValue({
|
|
561
|
+
data: { draft: true, merged: false, state: "open", base: { ref: "main" }, head: { sha: "x" }, labels: [] },
|
|
562
|
+
});
|
|
563
|
+
const result = await checkAutoMergeEligibility(makeOctokit(), "owner", "repo", 1, {});
|
|
564
|
+
expect(result.eligible).toBe(false);
|
|
565
|
+
expect(result.reason).toMatch(/draft/i);
|
|
566
|
+
});
|
|
567
|
+
it("returns ineligible for already-merged PRs", async () => {
|
|
568
|
+
mockPullsGet.mockResolvedValue({
|
|
569
|
+
data: { draft: false, merged: true, state: "closed", base: { ref: "main" }, head: { sha: "x" }, labels: [] },
|
|
570
|
+
});
|
|
571
|
+
const result = await checkAutoMergeEligibility(makeOctokit(), "owner", "repo", 1, {});
|
|
572
|
+
expect(result.eligible).toBe(false);
|
|
573
|
+
expect(result.reason).toMatch(/merged/i);
|
|
574
|
+
});
|
|
575
|
+
it("returns ineligible when required label is absent", async () => {
|
|
576
|
+
mockPullsGet.mockResolvedValue({
|
|
577
|
+
data: { draft: false, merged: false, state: "open", base: { ref: "main" }, head: { sha: "x" }, labels: [] },
|
|
578
|
+
});
|
|
579
|
+
const result = await checkAutoMergeEligibility(makeOctokit(), "owner", "repo", 1, {
|
|
580
|
+
requiredLabels: ["ready-to-merge"],
|
|
581
|
+
});
|
|
582
|
+
expect(result.eligible).toBe(false);
|
|
583
|
+
expect(result.reason).toMatch(/ready-to-merge/);
|
|
584
|
+
});
|
|
585
|
+
it("returns ineligible when base branch is not allowed", async () => {
|
|
586
|
+
mockPullsGet.mockResolvedValue({
|
|
587
|
+
data: { draft: false, merged: false, state: "open", base: { ref: "dev" }, head: { sha: "x" }, labels: [] },
|
|
588
|
+
});
|
|
589
|
+
const result = await checkAutoMergeEligibility(makeOctokit(), "owner", "repo", 1, {
|
|
590
|
+
allowedBranches: ["main"],
|
|
591
|
+
});
|
|
592
|
+
expect(result.eligible).toBe(false);
|
|
593
|
+
expect(result.reason).toMatch(/dev/);
|
|
594
|
+
});
|
|
595
|
+
it("counts approvals correctly — only APPROVED state counts", async () => {
|
|
596
|
+
mockListReviews.mockResolvedValue({
|
|
597
|
+
data: [
|
|
598
|
+
{ user: { id: 1 }, state: "APPROVED" },
|
|
599
|
+
{ user: { id: 2 }, state: "CHANGES_REQUESTED" },
|
|
600
|
+
{ user: { id: 3 }, state: "COMMENTED" },
|
|
601
|
+
],
|
|
602
|
+
});
|
|
603
|
+
// Only 1 approver out of 3 reviews
|
|
604
|
+
const result = await checkAutoMergeEligibility(makeOctokit(), "owner", "repo", 1, {
|
|
605
|
+
minimumApprovingReviews: 2,
|
|
606
|
+
});
|
|
607
|
+
expect(result.eligible).toBe(false);
|
|
608
|
+
expect(result.reason).toMatch(/1 approving/);
|
|
609
|
+
});
|
|
610
|
+
it("uses latest review per reviewer when counting approvals", async () => {
|
|
611
|
+
// User 1 approved then requested changes → not counted as approved
|
|
612
|
+
mockListReviews.mockResolvedValue({
|
|
613
|
+
data: [
|
|
614
|
+
{ user: { id: 1 }, state: "APPROVED" },
|
|
615
|
+
{ user: { id: 1 }, state: "CHANGES_REQUESTED" },
|
|
616
|
+
{ user: { id: 2 }, state: "APPROVED" },
|
|
617
|
+
],
|
|
618
|
+
});
|
|
619
|
+
const result = await checkAutoMergeEligibility(makeOctokit(), "owner", "repo", 1, {
|
|
620
|
+
minimumApprovingReviews: 2,
|
|
621
|
+
});
|
|
622
|
+
expect(result.eligible).toBe(false);
|
|
623
|
+
expect(result.reason).toMatch(/1 approving/);
|
|
624
|
+
});
|
|
625
|
+
it("passes when required status check is present and successful", async () => {
|
|
626
|
+
mockGetCombinedStatus.mockResolvedValue({
|
|
627
|
+
data: { statuses: [{ context: "ci/tests", state: "success" }] },
|
|
628
|
+
});
|
|
629
|
+
const result = await checkAutoMergeEligibility(makeOctokit(), "owner", "repo", 1, {
|
|
630
|
+
requiredStatusChecks: ["ci/tests"],
|
|
631
|
+
});
|
|
632
|
+
expect(result.eligible).toBe(true);
|
|
633
|
+
});
|
|
634
|
+
it("returns ineligible when required check run has not passed", async () => {
|
|
635
|
+
mockChecksListForRef.mockResolvedValue({
|
|
636
|
+
data: { check_runs: [{ name: "ci/tests", conclusion: "failure" }] },
|
|
637
|
+
});
|
|
638
|
+
const result = await checkAutoMergeEligibility(makeOctokit(), "owner", "repo", 1, {
|
|
639
|
+
requiredStatusChecks: ["ci/tests"],
|
|
640
|
+
});
|
|
641
|
+
expect(result.eligible).toBe(false);
|
|
642
|
+
expect(result.reason).toMatch(/ci\/tests/);
|
|
643
|
+
});
|
|
644
|
+
});
|
|
645
|
+
//# sourceMappingURL=pr-automerge.test.js.map
|