test(integration): add integration tests against a real forgejo instance #266

Open
ci-bot wants to merge 1 commit from test/integration-tests into main
Member

Summary

Implements the integration layer (Layer 2) of the testing strategy, following the decision that examples/event_payloads/ are reference-only: tests run against a real Forgejo instance so the schemas are always validated against live payloads.

16 integration tests (all green against Forgejo 15.0.3), covering:

  • test/integration/forgejo.test.ts — the Forgejo client: repositories, issues, comments, pull requests, reviews and inline review comments. Every call goes through forgejoFetch, which validates responses against the TypeBox schemas, so a passing suite is the "content always synced" guarantee.
  • test/integration/context.test.tsgetEventContext for issue and pull request events against live data.
  • test/integration/tools.test.ts — all five tools execute against the real REST API, including create-pr-review (run from a checkout of the PR head branch so getLatestCommitId() resolves a real commit).

Infrastructure

  • docker-compose.test.yaml — pinned Forgejo 15.0.3 service (same version the payloads were captured on) with healthcheck.
  • scripts/integration-setup.sh — POSIX sh; creates users + access tokens via the Forgejo CLI in the container, deletes/recreates the test repository (deterministic data on every run), pushes a change branch with a known diff, seeds an issue with a comment, and writes test/integration/credentials.json (gitignored).
  • vitest.integration.config.ts + pnpm test:integration — separate config so the default pnpm test (unit) stays fast and doesn't need the instance; files run sequentially to keep tests order-independent.
  • The same forgejo service was added to .devcontainer/docker-compose.yaml, so tests can run from the workspace container.
  • test/README.md — run instructions (up, provision, test).

Notes

  • Only defineTool from @earendil-works/pi-coding-agent is mocked (metadata factory); the tools' execute functions run for real. See the unit tests for why the package itself can't be imported outside the bundle (@earendil-works/pi-server is not installed).
  • CI wiring (test.yaml workflow) is intentionally left as the next step — it needs a docker-capable runner; happy to add it in a follow-up once the runner setup is decided.

Checks

pnpm check / lint:check / format:check / pnpm test (23 unit) · pnpm test:integration 16/16 (validated against a live Forgejo 15.0.3 instance) · yamllint + prettier

Note: I accidentally pushed this commit straight to main first; main has been reverted (commit 420a634) to keep the PR-based flow, and the changes are re-applied here on top.

## Summary Implements the integration layer (Layer 2) of the testing strategy, following the decision that `examples/event_payloads/` are reference-only: tests run against a **real Forgejo instance** so the schemas are always validated against live payloads. **16 integration tests** (all green against Forgejo 15.0.3), covering: - `test/integration/forgejo.test.ts` — the Forgejo client: repositories, issues, comments, pull requests, reviews and inline review comments. Every call goes through `forgejoFetch`, which validates responses against the TypeBox schemas, so a passing suite is the "content always synced" guarantee. - `test/integration/context.test.ts` — `getEventContext` for issue and pull request events against live data. - `test/integration/tools.test.ts` — all five tools execute against the real REST API, including `create-pr-review` (run from a checkout of the PR head branch so `getLatestCommitId()` resolves a real commit). ## Infrastructure - `docker-compose.test.yaml` — pinned Forgejo 15.0.3 service (same version the payloads were captured on) with healthcheck. - `scripts/integration-setup.sh` — POSIX sh; creates users + access tokens via the Forgejo CLI in the container, deletes/recreates the test repository (deterministic data on every run), pushes a change branch with a known diff, seeds an issue with a comment, and writes `test/integration/credentials.json` (gitignored). - `vitest.integration.config.ts` + `pnpm test:integration` — separate config so the default `pnpm test` (unit) stays fast and doesn't need the instance; files run sequentially to keep tests order-independent. - The same forgejo service was added to `.devcontainer/docker-compose.yaml`, so tests can run from the workspace container. - `test/README.md` — run instructions (up, provision, test). ## Notes - Only `defineTool` from `@earendil-works/pi-coding-agent` is mocked (metadata factory); the tools' `execute` functions run for real. See the unit tests for why the package itself can't be imported outside the bundle (`@earendil-works/pi-server` is not installed). - CI wiring (`test.yaml` workflow) is intentionally left as the next step — it needs a docker-capable runner; happy to add it in a follow-up once the runner setup is decided. ## Checks `pnpm check` / `lint:check` / `format:check` / `pnpm test` (23 unit) ✅ · `pnpm test:integration` 16/16 ✅ (validated against a live Forgejo 15.0.3 instance) · yamllint + prettier ✅ > Note: I accidentally pushed this commit straight to `main` first; `main` has been reverted (commit `420a634`) to keep the PR-based flow, and the changes are re-applied here on top.
test(integration): add integration tests against a real forgejo instance
All checks were successful
check-commitizen.yaml / Check the PR title (pull_request) Successful in 1s
check-formatter.yaml / Checks with formatters (pull_request) Successful in 6s
check-linter.yaml / Checks with linters (pull_request) Successful in 11s
check-prettier.yaml / Check files formatting (pull_request) Successful in 1s
check-syntax.yaml / Checks with static tools (pull_request) Successful in 8s
check-yamllint.yaml / Lint yaml files (pull_request) Successful in 1s
forgejo-agent / LLM Bot response generation (pull_request) Successful in 2s
9d257223f9
Run the Forgejo client, the tools and getEventContext against a real
Forgejo 15.0.3 instance (docker compose) instead of a mock, so the
payloads are always synced with the instance:
- docker-compose.test.yaml with a pinned forgejo service + healthcheck
- scripts/integration-setup.sh to provision users, tokens, repository,
  change branch with a known diff and a seed issue
- test/integration with 16 tests covering client, context and tools
- vitest.integration.config.ts + test:integration script
- same forgejo service added to the devcontainer compose
- docs in test/README.md
All checks were successful
check-commitizen.yaml / Check the PR title (pull_request) Successful in 1s
check-formatter.yaml / Checks with formatters (pull_request) Successful in 6s
Required
Details
check-linter.yaml / Checks with linters (pull_request) Successful in 11s
Required
Details
check-prettier.yaml / Check files formatting (pull_request) Successful in 1s
Required
Details
check-syntax.yaml / Checks with static tools (pull_request) Successful in 8s
Required
Details
check-yamllint.yaml / Lint yaml files (pull_request) Successful in 1s
Required
Details
forgejo-agent / LLM Bot response generation (pull_request) Successful in 2s
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin test/integration-tests:test/integration-tests
git switch test/integration-tests
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
projects/forgejo-agent!266
No description provided.