Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions .github/workflows/go-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ on:
- "go.work"
- "mise.toml"
- "f3-sidecar/**"
- "interop-tests/src/tests/**"
- "interop-tests/**"
push:
branches:
- main
Expand All @@ -27,7 +27,7 @@ on:
- "go.work"
- "mise.toml"
- "f3-sidecar/**"
- "interop-tests/src/tests/**"
- "interop-tests/**"

jobs:
# Merge groups don't support path filters, so detect the relevant changes
Expand All @@ -48,13 +48,16 @@ jobs:
- 'go.work'
- 'mise.toml'
- 'f3-sidecar/**'
- 'interop-tests/src/tests/**'
- 'interop-tests/**'
lint-go:
name: Go lint checks
needs: changes
if: ${{ needs.changes.outputs.changesFound == 'true' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-slim
runs-on: ubuntu-24.04
Comment thread
EclesioMeloJunior marked this conversation as resolved.
Outdated
steps:
- uses: actions/checkout@v7
- uses: jdx/mise-action@v4
- name: Apt Dependencies
run: sudo apt-get install -y libclang-dev # required by rust2go's bindgen
Comment thread
EclesioMeloJunior marked this conversation as resolved.
Outdated
- run: mise lint:go-ffi
Comment thread
EclesioMeloJunior marked this conversation as resolved.
- run: mise lint:golang
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@

### 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`.
Comment thread
EclesioMeloJunior marked this conversation as resolved.
Outdated

### Removed

### Fixed
Expand Down
27 changes: 17 additions & 10 deletions interop-tests/build.rs
Comment thread
EclesioMeloJunior marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,25 @@

fn main() {
println!("cargo::rerun-if-changed=src/tests/go_app");
println!("cargo::rerun-if-changed=src/tests/go_ffi.rs");
println!("cargo::rerun-if-env-changed=FOREST_REGENERATE_GO_FFI");

unsafe {
std::env::set_var("GOWORK", "off");
std::env::set_var("GOFLAGS", "-tags=netgo");
}
rust2go::Builder::default()
.with_go_src("./src/tests/go_app")
// the generated Go file has been committed to the git repository,
// uncomment to regenerate the code locally
// .with_regen_arg(rust2go::RegenArgs {
// src: "./src/tests/go_ffi.rs".into(),
// dst: "./src/tests/go_app/ffi_gen.go".into(),
// ..Default::default()
// })
.build();

let mut builder = rust2go::Builder::default().with_go_src("./src/tests/go_app");

// 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() {
Comment thread
EclesioMeloJunior marked this conversation as resolved.
Outdated
builder = builder.with_regen_arg(rust2go::RegenArgs {
src: "./src/tests/go_ffi.rs".into(),
dst: "./src/tests/go_app/ffi_gen.go".into(),
..Default::default()
})
}

builder.build();
}
10 changes: 10 additions & 0 deletions mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ run = '''
golangci-lint run ./f3-sidecar ./interop-tests/src/tests/go_app
'''

[tasks."lint:go-ffi"]
description = "Verify the committed Go FFI binding is in sync with go_ffi.rs."
run = '''
# Checking the (empty) lib target is enough to run `build.rs`, which does the
# regeneration. Adding `--tests` would compile the whole Forest node instead.
FOREST_REGENERATE_GO_FFI=1 cargo check -p forest-interop-tests --profile quick
git diff --exit-code -- interop-tests/src/tests/go_app/ffi_gen.go \
|| (echo "ffi_gen.go is stale — run 'mise lint:go-ffi' and commit the result"; false)
'''

[tasks."lint:ruby"]
description = "Lint Ruby code using rubocop."
tools.ruby = "latest"
Expand Down
Loading