Skip to content

ci: run the python-gated cargo tests with bean-check installed - #1744

Closed
robcohen wants to merge 2 commits into
mainfrom
ci/python-compat-tests
Closed

robcohen wants to merge 2 commits into
mainfrom
ci/python-compat-tests

Conversation

@robcohen

@robcohen robcohen commented Jul 9, 2026

Copy link
Copy Markdown
Member

What

Adds a python-gated-cargo-tests job to the Compatibility workflow so the cargo test suites that compare rledger against Python beancount actually run in CI — instead of silently skipping everywhere, forever.

Why

Several cargo suites call Command::new("bean-check") and skip with an eprintln! when it's missing — which is every CI environment today. The use-before-open silent-pass bug (#1742) sat on main behind exactly that skip: test_account_lifecycle_consistency existed, would have caught the bug, and never ran with bean-check on PATH. This was the open question flagged in #1741/#1742.

How

New job in compat.yml (which already runs on push/PR/nightly and owns the Python setup convention):

  1. pip install beancount, then a dedicated step asserts bean-check --version succeeds — if the binary ever breaks, the job goes red at the assert rather than the tests green-skipping (a silent skip here would recreate the hole this job closes).
  2. Runs the two python-gated suites: rustledger integration_test and rustledger-core synthetic_generation. A comment carries the grep (Command::new("bean-) that enumerates them, so the list is maintainable.
  3. Belt-and-braces final step greps a rerun for the Skipping: Python beancount not available marker — so a future availability-probe drift (renamed binary, container-based probe) can't quietly reintroduce the skip.

Follows the existing job's conventions: same pinned action SHAs, same Python version, rust-cache omitted for the same license-check reason (comment cross-references it).

⚠️ Merge order

Land #1742 first. Verified locally with bean-check available: this job catches exactly the #1742 failure on current main (integration_test: 18 passed / 1 failed — test_account_lifecycle_consistency; synthetic_generation: green). If this merges first, the job is red on arrival — which is the proof the gate works, but red main is red main.

Also worth deciding: whether to add this job to branch protection as a required check (that's a repo-settings change only you can make).

🤖 Generated with Claude Code

Several cargo test suites compare rledger against Python beancount
directly (Command::new("bean-check")) and skip silently when the
binary is absent — which is every CI environment today. The
use-before-open silent-pass bug (#1742) sat on main behind exactly
that skip: test_account_lifecycle_consistency would have caught it,
but nothing ever ran it with bean-check on PATH.

Add a python-gated-cargo-tests job to the Compatibility workflow
(which already runs on push/PR/nightly and owns the python setup):

- pip install beancount, then ASSERT bean-check is runnable before
  testing — if the binary breaks, the job goes red at the assert
  instead of the tests green-skipping;
- run the two python-gated suites (rustledger integration_test,
  rustledger-core synthetic_generation), with a comment pointing at
  the grep that enumerates them;
- a final belt-and-braces step greps a rerun for the skip marker, so
  a future availability-probe drift (different binary, container)
  cannot reintroduce the silent skip.

Verified locally with bean-check available: the job catches exactly
the #1742 failure on current main (18 passed / 1 failed), so MERGE
ORDER MATTERS — land #1742 first or this job is red on arrival.
That red is the proof the gate works.

Co-Authored-By: Claude Fable 5 <[email protected]>
Copilot AI review requested due to automatic review settings July 9, 2026 22:55
@robcohen
robcohen requested a review from a team as a code owner July 9, 2026 22:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a dedicated CI job to the Compatibility workflow to ensure Rust integration tests that depend on Python Beancount tooling (notably bean-check) actually execute in CI instead of silently skipping when the binary isn’t present on PATH.

Changes:

  • Introduces a new python-gated-cargo-tests job that installs beancount via pip and asserts bean-check --version works.
  • Runs the two Beancount-gated cargo test suites (rustledger integration_test and rustledger-core synthetic_generation).
  • Adds a “silent skip” guard intended to prevent future availability-probe drift from reintroducing false-green skipping.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/compat.yml Outdated
Comment on lines +1142 to +1143
# 2. run the python-gated suites. Keep this list in sync with
# `grep -rl 'Command::new("bean-' crates/*/tests`.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good catch, and it surfaced a real gap: bean_price_compat.rs is a third python-gated suite this job wasn't running at all. Rather than narrowing the hint, d496e02 includes the suite (pip install beanprice, bean-price --version asserted) — the broad grep hint is now accurate.

Comment on lines +1168 to +1183
- name: Run python-gated test suites
env:
CARGO_TERM_COLOR: always
run: |
cargo test -p rustledger --test integration_test -- --nocapture
cargo test -p rustledger-core --test synthetic_generation -- --nocapture
- name: Fail on silent skips
run: |
# Belt and braces: re-run and grep for the skip marker. The
# assert step above should make this unreachable, but if a test
# gains a new availability probe (a different binary, a
# container) this catches it green-skipping.
if cargo test -p rustledger --test integration_test -- --nocapture 2>&1 | grep -q "Skipping: Python beancount not available"; then
echo "::error::python-gated tests skipped despite bean-check being installed — availability probe drifted"
exit 1
fi

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Both points fixed in d496e02 — the primary run tees to a log (set -o pipefail so tee can't mask a red cargo), and the skip check greps that log for every suite's actual skip marker (integration_test, synthetic_generation, bean_price_compat). No rerun, no masked failure, all suites covered.

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

✅ Compatibility Test Results

Metric Result
Check Compatibility 100%
BQL Compatibility 100%
Full AST Match 100%
Total Files 810
What's tested
  • Check: Exit codes and error counts match bean-check
  • BQL: Query results match bean-query
  • Files: ~800 test files downloaded from 10+ beancount repositories

Full results available in workflow artifacts

…(review)

Two review catches, both real:

- The grep hint the job carried ('Command::new("bean-') matches the
  bean_price_compat suite too — which turned out to be a third
  python-gated suite the job wasn't running at all. Include it
  (pip install beanprice, assert bean-price --version) rather than
  narrowing the hint.
- The "Fail on silent skips" step re-ran only integration_test inside
  an `if`, masking a failing rerun and covering one suite. The
  primary run now tees to a log (set -o pipefail so tee can't mask a
  red cargo), and the skip check greps that log for every suite's
  actual skip marker.

Co-Authored-By: Claude Fable 5 <[email protected]>
@robcohen

Copy link
Copy Markdown
Member Author

Superseded by #1746 — same commits on a policy-compliant branch name (ci/ is rejected by the branch-name check, which is why 'Validate branch name' was red here). The merge-order note carries over: #1742 first, then #1746.

@robcohen robcohen closed this Jul 10, 2026
@robcohen
robcohen deleted the ci/python-compat-tests branch July 30, 2026 20:47
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