Skip to content

ci(fork): add pytest-run job with Postgres service container#2

Closed
HaraldeRoessler wants to merge 3 commits into
mainfrom
fix/fork-ci-run-tests
Closed

ci(fork): add pytest-run job with Postgres service container#2
HaraldeRoessler wants to merge 3 commits into
mainfrom
fix/fork-ci-run-tests

Conversation

@HaraldeRoessler
Copy link
Copy Markdown
Owner

Summary

The fork CI previously only ran pytest --collect-only — tests were never executed. This meant regressions like the PR#17 credit-middleware 402-block loss were invisible to CI.

The concurrency test test_concurrent_deducts_respect_balance would have caught it immediately (expects 3×200 + 7×402, got 10×200) — but it never ran.

What's added

pytest-run job — spins up a Postgres 16 service container, runs init_db.sql for the schema, then executes tests/test_credit_middleware.py with proper env vars:

- name: run credit middleware tests
  env:
    CREDITS_ENABLED: 'true'
    MOLTSTACK_DB_PW: 'ci-pw'
    MOLTRUST_API_KEYS: 'mt_ci_placeholder_key'
    NONCE_SECRET: 'ci-placeholder-nonce-secret'
  run: |
    python -m pytest tests/test_credit_middleware.py -v --tb=short

Scoped to credit middleware tests for now. Other test files (test_caep.py, test_protocol_compliance.py) need additional infrastructure and can follow separately.

Also adds httpx to pip install in the collect job (needed for imports to succeed).

Why this matters

The entire PR#17 regression was discovered by Kersten running tests manually on the production server. With this CI job, the red test blocks the merge automatically.

Previously the fork CI only ran pytest --collect-only, never executing
any tests. This meant regressions like the PR#17 credit-middleware
402-block loss were invisible to CI — the concurrency test
(test_concurrent_deducts_respect_balance) would have caught it
immediately, but it never ran.

New job:
- pytest-run: spins up a Postgres 16 service container, runs
  init_db.sql for the schema, executes tests/test_credit_middleware.py
  with proper env vars (CREDITS_ENABLED=true, MOLTSTACK_DB_PW, etc.)

This is intentionally scoped to credit middleware tests only — the
test_caep.py and protocol compliance tests need additional
infrastructure (sandbox, admin keys) and can be added separately.

Also adds httpx to the collect job's pip install (needed for import
to succeed).
@HaraldeRoessler
Copy link
Copy Markdown
Owner Author

Superseded — CI changes moved to PR#58 (MoltyCel#58)

@HaraldeRoessler HaraldeRoessler deleted the fix/fork-ci-run-tests branch May 22, 2026 03:22
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.

1 participant