Skip to content

Conversation

@pyramation
Copy link
Contributor

@pyramation pyramation commented Jan 22, 2026

Summary

Adds a seed.pgpm() adapter that allows Python tests to use pgpm (PostgreSQL Package Manager) for database migrations without rewriting pgpm in Python. This implements "Option 1" from the integration discussion - treating pgpm as a CLI tool called via subprocess.

Key changes:

  • New PgpmSeedAdapter class that calls pgpm deploy via subprocess, passing database connection info through environment variables
  • Pre-scaffolded pgpm workspace fixture (tests/fixtures/pgpm-workspace/) with a test module
  • Integration tests demonstrating the full flow with @pgpm/faker
  • Separate GitHub Actions workflow (test-pgpm.yml) for pgpm integration tests
  • Regular test workflow excludes pgpm tests (they require Node.js/pgpm)

Updates since last revision

  • Added package parameter to seed.pgpm() to specify which package to deploy, avoiding interactive prompts in CI/non-interactive environments
  • Enabled verbose logging in pgpm workflow (-s --log-cli-level=INFO) for better debugging
  • Both CI workflows now pass

Review & Testing Checklist for Human

  • Verify package parameter usage - The package parameter is required to avoid pgpm's interactive "Choose a package to deploy" prompt. Without it, pgpm may hang in non-interactive environments.
  • Check subprocess security - The adapter passes PGPASSWORD via environment variables to subprocess. Verify this is acceptable for your security requirements.
  • Verify pgpm fixture structure - The fixture was created by examining existing pgpm workspaces, but should be validated against actual pgpm requirements.
  • Note: cache parameter is not implemented - The adapter accepts a cache parameter but it's not yet functional (documented in docstring).

Test plan:

  1. Verify both CI workflows pass (regular tests + pgpm integration tests)
  2. Check that all 3 tests in test_pgpm_integration.py actually execute (not skipped)
  3. Optionally test locally: cd tests/fixtures/pgpm-workspace/packages/test-module && pgpm install @pgpm/faker, then run poetry run pytest tests/test_pgpm_integration.py -v

Notes

  • Requires Node.js and pgpm CLI installed (npm install -g pgpm)
  • The workflow uses ghcr.io/constructive-io/docker/postgres-plus:17 image consistent with other workflows
  • pgpm version pinned to 2.7.9 in the workflow

Link to Devin run: https://app.devin.ai/sessions/1203eea9373240d797329ae288ab6dd7
Requested by: Dan Lynch (@pyramation)

- Add PgpmSeedAdapter that calls pgpm CLI via subprocess
- Pass database connection info via PGHOST/PGPORT/PGDATABASE/PGUSER/PGPASSWORD env vars
- Add pre-scaffolded pgpm workspace fixture with test-module
- Add test_pgpm_integration.py with tests for pgpm deploy and @pgpm/faker
- Add test-pgpm.yml workflow that:
  - Installs pgpm CLI globally
  - Installs @pgpm/faker in the test fixture
  - Runs pgpm admin-users bootstrap
  - Runs pgpm integration tests

This demonstrates Option 1: using pgpm as a CLI tool from Python
to run database migrations without rewriting pgpm in Python.
@devin-ai-integration
Copy link

🤖 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

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

- Exclude tests/test_pgpm_integration.py from regular test workflow
  (pgpm CLI not installed in that workflow)
- Add --verbose flag to pgpm deploy for better debugging
- Log stdout and stderr from pgpm deploy for troubleshooting
Add -s and --log-cli-level=INFO to pytest to capture pgpm deploy output
The pgpm deploy command was showing an interactive prompt to choose a package
instead of actually deploying. This fix adds a 'package' parameter to the
seed.pgpm() adapter that passes --package to pgpm deploy, avoiding the
interactive prompt in CI/non-interactive environments.
@pyramation pyramation merged commit 8fd907f into main Jan 22, 2026
2 checks passed
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