Skip to content

feat(ci): verifies that the committed Go FFI binding - #7478

Open
EclesioMeloJunior wants to merge 3 commits into
mainfrom
verify-go-ffi-freshness
Open

feat(ci): verifies that the committed Go FFI binding#7478
EclesioMeloJunior wants to merge 3 commits into
mainfrom
verify-go-ffi-freshness

Conversation

@EclesioMeloJunior

@EclesioMeloJunior EclesioMeloJunior commented Aug 11, 2026

Copy link
Copy Markdown
Member

Summary of changes

Changes introduced in this pull request:

  • Make the interop-tests generating the go-ffi only if FOREST_REGENERATE_GO_FFI is present
  • Include mise run lint:go-ffi that sets FOREST_REGENERATE_GO_FFI and generate the Go FFI binding then perform a diff check
  • Include the mise run lint:go-ffi in the go-lint.yml workflow

Reference issue to close (if applicable)

Closes #7467

Other information and links

Change checklist

  • I have performed a self-review of my own code,
  • [] I have made corresponding changes to the documentation. All new code adheres to the team's documentation standards,
  • I have added tests that prove my fix is effective or that my feature works (if possible),
  • I have made sure the CHANGELOG is up-to-date. All user-facing changes should be reflected in this document.

Outside contributions

  • This pull request is based on an issue that a maintainer has accepted (see Before Opening a Pull Request).
  • I have read and agree to the CONTRIBUTING document.
  • I have read and agree to the AI Policy document. I understand that failure to comply with the guidelines will lead to rejection of the pull request.

Summary by CodeRabbit

  • Bug Fixes

    • Improved detection of changes affecting Go interoperability tests and linting.
    • Ensured generated Go bindings remain synchronized with their Rust definitions.
  • Chores

    • Updated CI linting to run on the latest Ubuntu environment with required tooling.
    • Added automated verification that regenerated bindings match committed files.
    • Documented the new Go FFI consistency check in the changelog.

@EclesioMeloJunior
EclesioMeloJunior requested a review from a team as a code owner August 11, 2026 20:33
@EclesioMeloJunior
EclesioMeloJunior requested review from LesnyRumcajs and akaladarshi and removed request for a team August 11, 2026 20:33
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: da243b83-6a06-4986-af91-1321f448e2bb

📥 Commits

Reviewing files that changed from the base of the PR and between 702ce1c and df711c2.

📒 Files selected for processing (1)
  • interop-tests/build.rs
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • filecoin-project/lotus (manual)
🚧 Files skipped from review as they are similar to previous changes (1)
  • interop-tests/build.rs

Walkthrough

The PR adds conditional Go FFI regeneration, a mise lint:go-ffi freshness check, and CI coverage for all interop-tests changes. It also documents the validation command in the changelog.

Changes

Go FFI freshness validation

Layer / File(s) Summary
Conditional regeneration and freshness check
interop-tests/build.rs, mise.toml
The build script tracks source and environment changes. It regenerates bindings only when FOREST_REGENERATE_GO_FFI is set. The new task fails when ffi_gen.go changes.
CI coverage and release documentation
.github/workflows/go-lint.yml, CHANGELOG.md
CI monitors all interop-tests/** changes, installs libclang-dev, runs mise lint:go-ffi, and documents the check.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CI as Go lint workflow
  participant Mise as mise lint:go-ffi
  participant Cargo as cargo check
  participant BuildScript as interop-tests/build.rs
  participant Binding as ffi_gen.go
  CI->>Mise: run freshness check
  Mise->>Cargo: regenerate bindings
  Cargo->>BuildScript: set FOREST_REGENERATE_GO_FFI
  BuildScript->>Binding: write generated binding
  Mise->>Binding: detect file differences
Loading

Possibly related PRs

Suggested reviewers: lesnyrumcajs, akaladarshi

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: CI verification of the committed Go FFI binding.
Linked Issues check ✅ Passed The PR adds conditional regeneration, a freshness comparison, and CI execution while preserving non-regenerating normal builds, satisfying issue #7467.
Out of Scope Changes check ✅ Passed The workflow, build script, lint task, and changelog changes support the requested Go FFI freshness check without unrelated code changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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 verify-go-ffi-freshness
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch verify-go-ffi-freshness

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/go-lint.yml:
- Line 62: Update the actions/checkout@v7 step in the workflow to set
persist-credentials to false before the mise lint:go-ffi step, while preserving
the job’s ability to inspect local git diff output.

In `@CHANGELOG.md`:
- Line 42: Update the CHANGELOG entry for issue `#7467` so the mention of “mise
run lint:go-ffi” forms a grammatically complete clause, splitting the sentence
or replacing “included” with appropriate wording while preserving the described
CI behavior.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 8ee1180e-ff1e-4091-bcad-c981915108ac

📥 Commits

Reviewing files that changed from the base of the PR and between f6ebc6a and 702ce1c.

📒 Files selected for processing (4)
  • .github/workflows/go-lint.yml
  • CHANGELOG.md
  • interop-tests/build.rs
  • mise.toml
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • filecoin-project/lotus (manual)

- uses: jdx/mise-action@v4
- name: Apt Dependencies
run: sudo apt-get install -y libclang-dev # required by rust2go's bindgen
- run: mise lint:go-ffi

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.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -eu

printf '%s\n' '--- workflow ---'
sed -n '1,110p' .github/workflows/go-lint.yml

printf '%s\n' '--- relevant mise tasks and scripts ---'
rg -n -C 5 'lint:go-ffi|go-ffi|cargo|go generate|git diff' mise.toml .mise.toml mise.yml .mise.yml .github scripts Makefile 2>/dev/null || true

printf '%s\n' '--- checkout configuration across workflows ---'
rg -n -C 4 'actions/checkout|persist-credentials' .github/workflows 2>/dev/null || true

Repository: ChainSafe/forest

Length of output: 50372


🏁 Script executed:

#!/bin/bash
set -eu

printf '%s\n' '--- FFI package manifest and build scripts ---'
rg -n -C 8 'forest-interop-tests|build\s*=|FOREST_REGENERATE_GO_FFI|go_ffi|ffi_gen' Cargo.toml Cargo.lock interop-tests f3-sidecar 2>/dev/null | head -n 240

printf '%s\n' '--- exact checkout settings in the reviewed workflow ---'
nl -ba .github/workflows/go-lint.yml | sed -n '45,70p'

printf '%s\n' '--- workflow token and repository context usage ---'
rg -n -C 3 'GITHUB_TOKEN|github.token|secrets\.[A-Za-z0-9_]+|permissions:' .github/workflows/go-lint.yml .github/actions .github 2>/dev/null | head -n 160

Repository: ChainSafe/forest

Length of output: 14883


🌐 Web query:

actions/checkout persist-credentials false local git config http extraheader GITHUB_TOKEN documentation

💡 Result:

The persist-credentials input in actions/checkout controls whether the action automatically configures the local Git repository with credentials (typically the GITHUB_TOKEN) to enable subsequent authenticated Git operations [1][2][3]. When persist-credentials is set to true (the default), the action configures Git to use an authorization header for requests to GitHub [1][3]. The specific mechanism has evolved: In versions v5 and earlier, the action directly injected an http.extraheader containing the authorization token into the local.git/config file [4][5]. In version v6 and later, the action enhances security by writing the credentials to a separate file within the runner's temporary directory ($RUNNER_TEMP) and adding an includeIf.gitdir configuration to.git/config that points to that file [4][6]. Setting persist-credentials: false opts out of this behavior [1][2]. This is often recommended when: You do not need to perform subsequent Git operations that require the default token [4]. You want to prevent the GITHUB_TOKEN from being persisted in any configuration file, which can be a security best practice to reduce the attack surface for credential leakage [7][4][8]. You are using custom authentication (e.g., a personal access token or SSH key) and want to ensure the default GITHUB_TOKEN does not override or interfere with your configuration [9][5][6]. To use this option in your workflow, add it to the with block of your checkout step: - name: Checkout repository uses: actions/checkout@v4 with: persist-credentials: false

Citations:


🏁 Script executed:

#!/bin/bash
set -eu

python3 - <<'PY'
from pathlib import Path
import re

workflow = Path(".github/workflows/go-lint.yml").read_text()
mise = Path("mise.toml").read_text()
build = Path("interop-tests/build.rs").read_text()
manifest = Path("interop-tests/Cargo.toml").read_text()

checks = {
    "lint workflow has checkout before FFI task": bool(re.search(
        r"actions/checkout@v7[\s\S]*?mise lint:go-ffi", workflow)),
    "FFI task runs cargo check": "FOREST_REGENERATE_GO_FFI=1 cargo check -p forest-interop-tests" in mise,
    "FFI task checks generated file with git diff": "git diff --exit-code -- interop-tests/src/tests/go_app/ffi_gen.go" in mise,
    "interop-tests has a Cargo build script": 'build = "build.rs"' in manifest,
    "build script enables regeneration from environment": 'FOREST_REGENERATE_GO_FFI' in build,
    "build script writes generated Go file": 'src/tests/go_app/ffi_gen.go' in build,
}
for name, result in checks.items():
    print(f"{name}: {result}")
if not all(checks.values()):
    raise SystemExit("invariant failed")
PY

Repository: ChainSafe/forest

Length of output: 450


Disable persisted checkout credentials before mise lint:go-ffi.

cargo check executes the forest-interop-tests build script and regenerates Go bindings. A build script or dependency could read the persisted GITHUB_TOKEN. Set persist-credentials: false on the actions/checkout@v7 step; the job only needs local git diff.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/go-lint.yml at line 62, Update the actions/checkout@v7
step in the workflow to set persist-credentials to false before the mise
lint:go-ffi step, while preserving the job’s ability to inspect local git diff
output.

Source: Linters/SAST tools

Comment thread CHANGELOG.md

### Changed

- [#7467](https://github.com/ChainSafe/forest/issues/7467): CI now verifies that the committed Go FFI binding `interop-tests/src/tests/go_app/ffi_gen.go` stays in sync with `go_ffi.rs` through the `FOREST_REGENERATE_GO_FFI` environment variable, included `mise run lint:go-ffi`.

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.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Fix the changelog wording.

The phrase included mise run lint:go-ffi is not grammatical. Split the sentence or replace included with a complete clause.

Proposed wording
-- [`#7467`](https://github.com/ChainSafe/forest/issues/7467): CI now verifies that the committed Go FFI binding `interop-tests/src/tests/go_app/ffi_gen.go` stays in sync with `go_ffi.rs` through the `FOREST_REGENERATE_GO_FFI` environment variable, included `mise run lint:go-ffi`.
+- [`#7467`](https://github.com/ChainSafe/forest/issues/7467): CI now verifies that the committed Go FFI binding `interop-tests/src/tests/go_app/ffi_gen.go` stays in sync with `go_ffi.rs` through the `FOREST_REGENERATE_GO_FFI` environment variable. Run `mise run lint:go-ffi` to check freshness.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- [#7467](https://github.com/ChainSafe/forest/issues/7467): CI now verifies that the committed Go FFI binding `interop-tests/src/tests/go_app/ffi_gen.go` stays in sync with `go_ffi.rs` through the `FOREST_REGENERATE_GO_FFI` environment variable, included `mise run lint:go-ffi`.
- [`#7467`](https://github.com/ChainSafe/forest/issues/7467): CI now verifies that the committed Go FFI binding `interop-tests/src/tests/go_app/ffi_gen.go` stays in sync with `go_ffi.rs` through the `FOREST_REGENERATE_GO_FFI` environment variable. Run `mise run lint:go-ffi` to check freshness.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@CHANGELOG.md` at line 42, Update the CHANGELOG entry for issue `#7467` so the
mention of “mise run lint:go-ffi” forms a grammatically complete clause,
splitting the sentence or replacing “included” with appropriate wording while
preserving the described CI behavior.

@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.21%. Comparing base (0b42ef6) to head (df711c2).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files

see 11 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f6ebc6a...df711c2. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread .github/workflows/go-lint.yml
Comment thread .github/workflows/go-lint.yml
Comment thread interop-tests/build.rs

// the generated Go file has been committed to the git repository
// set the var to regenerate the file, CI sets this var to verify freshness.
if std::env::var_os("FOREST_REGENERATE_GO_FFI").is_some() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

new flags should be added to env variable reference in docs.

Comment thread interop-tests/build.rs

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There's also the root repo's build.rs that has similar logic - what about it?

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.

ci(interop-tests): verify generated Go FFI binding freshness

2 participants