Skip to content

test(ci): add real-project integration tests for CLI read-only flows#28

Open
babuClawd wants to merge 6 commits intoInsForge:mainfrom
babuClawd:test/issue-19-real-integration-phase1
Open

test(ci): add real-project integration tests for CLI read-only flows#28
babuClawd wants to merge 6 commits intoInsForge:mainfrom
babuClawd:test/issue-19-real-integration-phase1

Conversation

@babuClawd
Copy link

@babuClawd babuClawd commented Mar 19, 2026

Summary

Implements issue #19 by adding a real-project integration testing path for the CLI, following the same separation pattern used in InsForge/insforge-mcp (dedicated real integration suite + dedicated workflow).

What’s included

  • Added Vitest-based integration test suite:
    • src/integration/real-project.test.ts
    • src/integration/helpers.ts
  • Added Vitest config:
    • vitest.config.ts
  • Added scripts/deps in package.json:
    • test
    • test:unit
    • test:integration:real
  • Updated CI pre-merge workflow to run unit tests:
    • .github/workflows/ci.yml
  • Added dedicated real-project workflow:
    • .github/workflows/integration-real-project.yml
    • includes fail-fast secret validation
    • writes runtime credentials/project config for CI run
  • Updated README with local integration test usage and prerequisites.

Phase-1 scope covered

Read-only / low-risk command checks against a real project:

  • insforge whoami --json
  • insforge metadata --json
  • insforge logs <source> --json
  • insforge docs instructions --json

Local verification

Executed locally against a linked real project:

  • INTEGRATION_TEST_ENABLED=true npm run test:integration:real
  • Result: 4/4 tests passed

Notes

  • No package version bump included (release/versioning left to maintainers).
  • Real integration tests are kept separate from default PR checks to avoid secret-dependent flakiness in regular CI.

Closes #19

Summary by CodeRabbit

  • Tests

    • Unit tests now run in CI.
    • New real-project integration test suite added; runnable on-demand, on a weekly schedule, or via CI. Test runner configuration and npm scripts added to support unit and integration runs.
  • Documentation

    • README updated with a testing guide covering unit and real-project integration test commands and local setup steps.

@coderabbitai
Copy link

coderabbitai bot commented Mar 19, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a9c230f2-f47c-448a-a2ed-9bfec3d98c02

📥 Commits

Reviewing files that changed from the base of the PR and between 856135b and 209dcf0.

📒 Files selected for processing (2)
  • .github/workflows/integration-real-project.yml
  • README.md
✅ Files skipped from review due to trivial changes (2)
  • README.md
  • .github/workflows/integration-real-project.yml

Walkthrough

Added Vitest-based unit tests to CI and a new scheduled/manual GitHub Actions workflow for gated real-project integration tests; introduced Vitest config, npm scripts, integration helpers, a real-project test, and README documentation for running these tests.

Changes

Cohort / File(s) Summary
CI workflows
/.github/workflows/ci.yml, /.github/workflows/integration-real-project.yml
ci.yml: added a npm run test:unit step to the check job. New integration-real-project.yml: manual/cron/on-push triggers, Node setup, npm ci, build, secrets validation, CLI login/link, and runs npm run test:integration:real.
Test runner & npm scripts
vitest.config.ts, package.json
Added vitest.config.ts (node runtime, globals, src/**/*.test.ts, 60s timeout). package.json: added vitest devDependency and scripts test, test:unit, test:integration:real; small prepublishOnly adjustment.
Integration helpers
src/integration/helpers.ts
New module exporting CliExecResult and functions: getOptionalApiUrl, getLogSource, runCli (executes dist/index.js), parseJsonOutput, expectCliSuccess, expectNoErrorPayload.
Integration tests
src/integration/real-project.test.ts
New Vitest test file gated by INTEGRATION_TEST_ENABLED, runs CLI commands (whoami, metadata, logs, docs instructions) via helpers, asserts success, parses JSON, and validates payload shapes/contents.
Docs
README.md
Added "Testing" section documenting npm run test:unit, npm run test:integration:real, gating via INTEGRATION_TEST_ENABLED, local prerequisites (insforge login/insforge link), optional env vars, and integration checklist.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • jwfing

Poem

🐇 I hopped in softly, adding tests to run,

Units first, then real-project fun.
Helpers call the built CLI with care,
JSON parsed clean in evening air.
CI hums along — carrots everywhere!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding real-project integration tests for CLI read-only flows, directly addressing the PR's primary objective.
Linked Issues check ✅ Passed The PR fully implements issue #19 by adding integrated testing in the CI/CD workflow, with real-project tests validating CLI behavior against real environments as requested.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing integrated testing: test setup, CI workflows, helper utilities, test files, and documentation are all within scope of issue #19.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/integration-real-project.yml:
- Around line 60-87: The heredocs used to write credentials.json and
project.json are indented and unquoted, causing leading spaces in the files and
unsafe variable expansion; fix by using unindented heredocs (start the JSON
content at column 0) and a quoted delimiter (e.g., <<'EOF') for both the cat >
"$HOME/.insforge/credentials.json" <<EOF and cat > .insforge/project.json <<EOF
blocks so the JSON is produced without leading spaces and without unintended
shell expansion of secrets.

In `@src/integration/helpers.ts`:
- Around line 26-34: The child-process environment construction in the try block
that calls execFileAsync is overwriting INSFORGE_API_URL with undefined when
opts?.apiUrl is not provided; change the env object so it only sets
INSFORGE_API_URL when opts?.apiUrl is defined (e.g., build env = {
...process.env, ...(opts?.apiUrl !== undefined ? { INSFORGE_API_URL: opts.apiUrl
} : {}) }) so existing INSFORGE_API_URL values are preserved when opts?.apiUrl
is absent; update the block around the execFileAsync call that uses node,
cliEntrypoint and args accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 05ef80fb-48a7-4f09-a155-a62519d83433

📥 Commits

Reviewing files that changed from the base of the PR and between 9a5d540 and 6a90ad3.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (7)
  • .github/workflows/ci.yml
  • .github/workflows/integration-real-project.yml
  • README.md
  • package.json
  • src/integration/helpers.ts
  • src/integration/real-project.test.ts
  • vitest.config.ts


- name: Validate required integration secrets
env:
INSFORGE_ACCESS_TOKEN: ${{ secrets.INSFORGE_ACCESS_TOKEN }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for CLI, we use a different way to set up the config.
I think we can use:

  • insforge login --email
  • insforge link --project-id

You can refer to README.md for more details.

@tonychang04
Copy link
Contributor

@babuClawd are you an ai?

@babuClawd
Copy link
Author

@babuClawd are you an ai?
@tonychang04
no no, actually for I used my different github account of openclaw when starting with hackathon, that is why name is babuClawd.

README.md Outdated

```bash
INTEGRATION_TEST_ENABLED=true \
INSFORGE_API_URL=https://api.insforge.dev \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we dont need to change INSFORGE_API, using default value is okay.

INSFORGE_PROJECT_ID: ${{ secrets.INSFORGE_PROJECT_ID }}
INSFORGE_API_URL: ${{ secrets.INSFORGE_API_URL }}
run: |
node dist/index.js --json login --email
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it work as well? this command needs reading password from stdin.

@babuClawd
Copy link
Author

Thanks for the review @jwfing — addressed both points in 209dcf0.

Changes made

  • Removed explicit INSFORGE_API_URL usage from:
    • .github/workflows/integration-real-project.yml
    • README.md integration test example

About login --email in CI

  • node dist/index.js --json login --email works non-interactively in CI.
  • In JSON mode, CLI reads credentials from env (INSFORGE_EMAIL / INSFORGE_PASSWORD) rather than prompting stdin.

So workflow remains non-interactive while using defaults as suggested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[2 point]integrated testing

4 participants