feat(test): add scenario integration tests and self-dogfood e2e workflow#120
Merged
Conversation
Adds two complementary test-harness layers on top of the existing unit tests: - `src/main.integration.test.ts` — a `vitest` integration suite that drives `main.ts` through the full `eventName x allowed_contexts x parse outcome` matrix (13 table-driven scenarios), including the `discussion_comment` regression guard that asserts `issue_number` is never emitted. - `.github/workflows/e2e.yaml` — a self-dogfooding workflow that runs the built action against real `issue_comment` / `discussion_comment` events in this repo, gated by a protected `environment: e2e` (required-reviewer approval per run). The Verify step extracts an expectation directive embedded in the triggering comment under the reserved `_expect_` params key (see `docs/e2e.md` for the comment convention) and fails the job on mismatch. The verifier is split into pure functions in `src/e2e-verify.ts` (unit-tested via `src/e2e-verify.test.ts`) and a CLI shim in `scripts/e2e-verify.ts` invoked from the workflow. `docs/e2e.md` covers the comment convention, security model, required repo settings, operational tradeoffs, and smoke-run procedure. `README.md` gains a one-line link to the new doc. The e2e workflow is intentionally NOT wired into `publish.needs` of `ci.yaml`; `semantic-release` continues to ship from `main` independently. Closes #118 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
🎉 This PR is included in version 2.3.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds two complementary test-harness layers on top of the existing unit tests, as scoped by #118.
src/main.integration.test.ts— avitestintegration suite that drivesmain.tsthrough the fulleventName x allowed_contexts x parse outcomematrix (13 table-driven scenarios), including thediscussion_commentregression guard that assertsissue_numberis never emitted..github/workflows/e2e.yaml— a self-dogfooding workflow that runs the built action against realissue_comment/discussion_commentevents in this repo, gated by a protectedenvironment: e2e(required-reviewer approval per run). The Verify step extracts an expectation directive embedded in the triggering comment under the reserved_expect_params key and fails the job on mismatch.src/e2e-verify.ts(unit-tested viasrc/e2e-verify.test.ts); a CLI shim inscripts/e2e-verify.tsis invoked from the workflow.docs/e2e.md— comment convention, security model, required repo settings, operational tradeoffs, and smoke-run procedure.README.mdgains a one-line link.Notable design choices
# expect: <json>on a separate line of the comment body. The action's parser rejects any trailing non-params text, so the directive is instead carried as a single-quoted JSON string under a reserved_expect_params key (e.g..test foo=bar, _expect_='{"continue":"true","command":"test","params":{"foo":"bar"},"context":"issue"}'). The verifier strips_expect_from the actual params before deep-equal so directive-bearing comments do not pollute theexpected.paramsshape. Production code (src/main.ts,src/parse.ts,action.yaml) is untouched.continue=true(the action emitsparamsonly on that path). Filtered / unknown-command / malformed-params cases fall back to the smoke check — documented indocs/e2e.md.registeredruns onpull_request/push:mainfor visibility (echo only, no environment gate);dogfoodruns only on comment events, behindenvironment: e2e.dist/drift is gated by the existingci.yamlcheck rather than duplicated here.failedvalues as mismatches.Not part of this PR
docs/e2e.md(enable Discussions, create thee2eenvironment with required reviewers).docs/e2e.md"Smoke run" section).e2e.yamlis intentionally NOT wired intopublish.needsofci.yaml;semantic-releasecontinues to ship frommainindependently.Test plan
pnpm typecheck— exit 0pnpm test— 95 tests across 5 files passing (existing 58 + 13 integration + 20 e2e-verify unit + 4 utils)pnpm lint— 0 warnings, 0 errors on 15 filespnpm format:check— cleanpnpm build && git diff --exit-code dist/— no drift (production code unchanged)actionlint .github/workflows/e2e.yaml— exit 0e2eenvironment + enable Discussions perdocs/e2e.mddocs/e2e.mdReferences