Skip to content

Conversation

@pyramation
Copy link
Contributor

@pyramation pyramation commented Dec 24, 2025

feat(pgpm): add test-packages command for integration testing

Summary

Adds a new pgpm test-packages CLI command that abstracts the integration deploy testing scripts from pgpm-modules and constructive-db into a reusable command in the constructive repo. This addresses constructive-io/projects-issues#375.

The command discovers all PGPM modules in a workspace and runs integration tests on each by creating a temporary database, deploying, and optionally running verify/revert/deploy cycles.

Key features:

  • --exclude - Module names to exclude from testing
  • --stop-on-fail - Stop on first failure vs collect all failures
  • --full-cycle - Run full deploy/verify/revert/deploy cycle (default: deploy only)
  • --cwd - Working directory (default: current directory)

Implementation approach:

  • Uses PgpmPackage.getModules() for module discovery (reads from workspace pgpm.json config)
  • Uses PgpmPackage.deploy(), verify(), revert() methods directly instead of spawning CLI subprocesses
  • Uses SQL via pg-cache for database creation/dropping (no shell commands)
  • Properly terminates connections before dropping test databases

Updates since last revision

  • Added README documentation for test-packages command to both CLI packages:
    • pgpm/pgpm/README.md (pgpm CLI)
    • packages/cli/README.md (@constructive-io/cli which inherits pgpm commands via cnc/constructive)

Review & Testing Checklist for Human

  • Test end-to-end in a real workspace: Run pgpm test-packages in constructive-db to verify it discovers and tests modules correctly
  • Verify module discovery: Confirm that PgpmPackage.getModules() returns the same modules that the old scripts/test-all-packages.js would find (check if pgpm.json packages globs cover all expected directories)
  • Test database permissions: The SQL-based CREATE DATABASE/DROP DATABASE may require different privileges than the old createdb/dropdb approach
  • Verify --full-cycle behavior: Test that verify/revert/deploy cycle works correctly with the internal APIs

Recommended test plan:

cd /path/to/constructive-db
pgpm test-packages --help
pgpm test-packages  # deploy only
pgpm test-packages --full-cycle  # full cycle
pgpm test-packages --exclude some-module --stop-on-fail

Notes

@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@devin-ai-integration devin-ai-integration bot force-pushed the devin/1766534917-test-packages-command branch from 64f278e to 5324127 Compare December 24, 2025 02:06
Abstracts the integration deploy scripts from pgpm-modules and constructive-db
into a reusable pgpm CLI command.

Features:
- Configurable directories to search (--dirs)
- Package exclusion support (--exclude)
- Stop on first failure option (--stop-on-fail)
- Full cycle testing with verify/revert (--full-cycle)
- Auto-detection of Docker vs direct PostgreSQL connection
- Detailed test summary with pass/fail status

Closes constructive-io/constructive-planning#375
- Use PgpmPackage.getModules() for module discovery instead of manual directory walking
- Use PgpmPackage.deploy(), verify(), revert() methods directly instead of spawning pgpm subprocesses
- Use SQL via pg-cache for database creation/dropping instead of createdb/dropdb shell commands
- Remove Docker-specific detection logic - now uses standard pg-env connection settings
- Properly terminate connections before dropping test databases
- Simplified options: removed --dirs (uses workspace config), kept --exclude, --stop-on-fail, --full-cycle
@devin-ai-integration devin-ai-integration bot force-pushed the devin/1766534917-test-packages-command branch from 5324127 to 7e3dae0 Compare December 24, 2025 02:10
@pyramation pyramation closed this Dec 24, 2025
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 participants