Skip to content

chore: remove FFI header generation from pre-commit FFI step#565

Merged
xdustinface merged 1 commit intov0.42-devfrom
chore/remove-ffi-header-generation
Mar 21, 2026
Merged

chore: remove FFI header generation from pre-commit FFI step#565
xdustinface merged 1 commit intov0.42-devfrom
chore/remove-ffi-header-generation

Conversation

@xdustinface
Copy link
Collaborator

@xdustinface xdustinface commented Mar 19, 2026

Headers are generated by build.rs via cbindgen during cargo build and dont need to be tracked in git or verified by pre-commit.

  • Remove build_ffi_crates() and header diff checks from verify_ffi.py
  • Gitignore generated headers (include/ dirs)
  • Remove header target from both FFI Makefiles
  • Make key-wallet-ffi/build.rs panic on cbindgen failure to make sure CI fails if there are failures
  • Move verify-ffi from pre-push to pre-commit stage

Summary by CodeRabbit

  • Chores

    • Optimized build process by automating interface file generation during compilation instead of manual steps
    • Updated repository configuration to automatically exclude generated build artifacts from version control
    • Simplified continuous integration verification hooks and their trigger stages
    • Strengthened build system error handling to provide explicit failure detection and reporting
  • Documentation

    • Updated development guides to document the new automated build workflow

Headers are generated by `build.rs` via `cbindgen` during `cargo build`
and dont need to be tracked in git or verified by `pre-commit`.

- Remove `build_ffi_crates()` and header diff checks from `verify_ffi.py`
- Gitignore generated headers (`include/` dirs)
- Remove `header` target from both FFI Makefiles
- Make `key-wallet-ffi/build.rs` panic on `cbindgen` failure to make sure CI fails if there are failures
- Move `verify-ffi` from `pre-push` to `pre-commit` stage
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 19, 2026

📝 Walkthrough

Walkthrough

This PR transitions FFI header generation from manual workflow to automatic generation during cargo build, deletes pre-generated header files, gitignores generated header directories, simplifies Makefile targets, and refocuses verification tooling on documentation only.

Changes

Cohort / File(s) Summary
FFI Build & Verification Infrastructure
.gitignore, .pre-commit-config.yaml, contrib/verify_ffi.py
Adds ignore patterns for auto-generated FFI header directories, updates pre-commit hook to verify only documentation (removes header freshness checks), removes build_ffi_crates() function from verification script, and eliminates git diff checks for */include/ directories.
Dash SPV FFI Build Configuration
dash-spv-ffi/CLAUDE.md, dash-spv-ffi/Makefile
Updates documentation to reflect auto-generation by build.rs, removes header Makefile target, decouples documentation generation from header generation in docs and full targets.
Dash SPV FFI Headers (Deleted)
dash-spv-ffi/dash_spv_ffi.h, dash-spv-ffi/include/dash_spv_ffi.h
Removes entire pre-generated C FFI interface files (~2000 lines total), including all exported functions, type declarations, enums, callbacks, and opaque handles for client operations, configuration, and wallet management.
Key Wallet FFI Build Configuration
key-wallet-ffi/Makefile, key-wallet-ffi/build.rs
Removes header Makefile target and its dependencies from docs/full targets; changes build-script error handling from warning to panic on cbindgen failure.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

Poem

🐰 No more manual headers to keep,
Build scripts now run auto-deep,
Generated files sleep in .gitignore's care,
Verification checks docs everywhere,
The workflow hops lighter through the air! 🌿

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title directly describes the main change: removing FFI header generation from the pre-commit FFI verification step, which is the core objective of the changeset.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/remove-ffi-header-generation
📝 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.

@codecov
Copy link

codecov bot commented Mar 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.35%. Comparing base (2e3da5c) to head (1959010).
⚠️ Report is 5 commits behind head on v0.42-dev.

Additional details and impacted files
@@            Coverage Diff             @@
##           v0.42-dev     #565   +/-   ##
==========================================
  Coverage      66.35%   66.35%           
==========================================
  Files            311      311           
  Lines          64976    64976           
==========================================
+ Hits           43116    43117    +1     
+ Misses         21860    21859    -1     
Flag Coverage Δ
core 75.13% <ø> (ø)
ffi 37.53% <ø> (ø)
rpc 28.28% <ø> (ø)
spv 81.11% <ø> (+<0.01%) ⬆️
wallet 65.93% <ø> (ø)
see 4 files with indirect coverage changes

Copy link
Contributor

@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 @.pre-commit-config.yaml:
- Around line 65-71: The verify-ffi hook (id: verify-ffi, entry:
contrib/verify_ffi.py) was left without a stages key so it runs on every
pre-commit and slows down commits; add a stages entry (for example stages:
[push] or stages: [manual]) under the verify-ffi hook to remove it from the
pre-commit fast path so it only runs on push or when invoked manually, leaving
the existing files pattern and other fields unchanged.

In `@contrib/verify_ffi.py`:
- Around line 56-64: The subprocess.run calls that invoke git (used after
checking docs_result.returncode in contrib/verify_ffi.py) should not rely on
PATH; resolve git once with shutil.which (e.g., git_path = shutil.which("git"))
and reuse that absolute path for both subprocess.run invocations instead of the
literal "git" string, and add a guard to raise/print a clear error if
shutil.which returns None; update the two subprocess.run calls that currently
pass ["git", ...] to use [git_path, ...] (and ensure shutil is imported).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 167b199a-cbc5-4341-bdd7-9d67b38aaa55

📥 Commits

Reviewing files that changed from the base of the PR and between 2e3da5c and 1959010.

📒 Files selected for processing (10)
  • .gitignore
  • .pre-commit-config.yaml
  • contrib/verify_ffi.py
  • dash-spv-ffi/CLAUDE.md
  • dash-spv-ffi/Makefile
  • dash-spv-ffi/dash_spv_ffi.h
  • dash-spv-ffi/include/dash_spv_ffi.h
  • key-wallet-ffi/Makefile
  • key-wallet-ffi/build.rs
  • key-wallet-ffi/include/key_wallet_ffi.h
💤 Files with no reviewable changes (2)
  • dash-spv-ffi/dash_spv_ffi.h
  • dash-spv-ffi/include/dash_spv_ffi.h

@github-actions github-actions bot added the ready-for-review CodeRabbit has approved this PR label Mar 19, 2026
@xdustinface xdustinface requested a review from ZocoLini March 19, 2026 05:02
@xdustinface xdustinface merged commit 2ac3c9c into v0.42-dev Mar 21, 2026
42 checks passed
@xdustinface xdustinface deleted the chore/remove-ffi-header-generation branch March 21, 2026 04:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review CodeRabbit has approved this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants