Skip to content

Commit

Permalink
ci: add workflow to check bindings are up to date (#243)
Browse files Browse the repository at this point in the history
Fixes #207 

### What Changed?
This PR introduces the following changes
* Adds a CI workflow to check if the bindings are up to date. This works
by re-generating the bindings and checking the diff against the existing
bindings.
* Changes the `make bindings` target to generate the bindings using a
specific Foundry version. This is important since different Foundry
versions may generate slightly different bindings, which will cause the
CI to fail. To ensure a specific Foundry version is used, we run the
command inside a Docker container that runs a pinned Foundry version
(v0.3.0).
* Updates the bindings by generating them with the modified `make
bindings` target.

**Note:** the existing `bindings` target was renamed to `bindings_host`,
as it runs without Docker. However the `bindings_host` target is only
for CI use only. To generate the bindings, please use the `bindings`
target.

### Reviewer Checklist

- [ ] New features are tested and documented
- [ ] PR has one of the `changelog-X` labels (if applies)
- [ ] Code deprecates any old functionality before removing it

---------

Co-authored-by: Pablo Deymonnaz <[email protected]>
  • Loading branch information
ricomateo and pablodeymo authored Jan 21, 2025
1 parent d479799 commit 1a66fc2
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 14 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/bindings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Bindings

on:
push:
branches: [main]
pull_request:
branches: [ '**' ]

env:
FOUNDRY_PROFILE: ci

jobs:
check:
strategy:
fail-fast: true

name: Check bindings are up to date
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: v0.3.0

- name: Show Forge version
run: forge --version

- name: Backup existing bindings
working-directory: crates/utils/src/
run: |
cp -r core/ existing_core/
cp -r middleware/ existing_middleware/
cp -r sdk/ existing_sdk/
- name: Generate new bindings
run: |
make bindings_host
cargo fmt
- name: Compare existing and new bindings
working-directory: crates/utils/src/
run: |
diff existing_core/ core/
diff existing_middleware/ middleware/
diff existing_sdk/ sdk/
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ Each version will have a separate `Breaking Changes` section as well. To describ
## [Unreleased]
### Added
### Changed
* Changes in the way bindings are generated in [#245](https://github.com/Layr-Labs/eigensdk-rs/pull/243).
* The `bindings` target now generates the bindings using Docker with Foundry v0.3.0.
* The previous `bindings` target was renamed to `bindings_host`, as it runs without Docker. However the `bindings_host` target is for CI use only. To generate the bindings, please use the `bindings` target.


### Breaking changes
### Removed

Expand Down
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ CORE_CONTRACTS_ARGS:=$(patsubst %, --select '^%$$', $(shell echo $(CORE_CONTRACT


.PHONY: bindings
bindings:

bindings_host:
@echo "Generating bindings..."
# Fetch submoduless
cd $(SDK_CONTRACTS_LOCATION) && forge install
Expand Down Expand Up @@ -89,3 +90,9 @@ bindings:
$(CORE_CONTRACTS_ARGS)

@echo "Bindings generated"

bindings:
@echo "Starting Docker container..."
@docker run --rm -v "$(PWD):$(PWD)" -w "$(PWD)" \
ghcr.io/foundry-rs/foundry:v0.3.0 \
-c 'apk add g++ && apk add make && make bindings_host'
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,20 @@ make bindings

This command will generate the bindings files in the folder: `crates/utils`.

⚠️ Remember to fix all compilation warnings.
**Important:** this command requires Docker installed and running since it uses a container to generate the bindings. On Mac, you may get an error similar to:

```text
v0.3.0: Pulling from foundry-rs/foundry
docker: no matching manifest for linux/arm64/v8 in the manifest list entries.
```

In that case, you'll need to pull the foundry image for the `amd64` platform with:

```bash
docker pull --platform linux/amd64/v8 ghcr.io/foundry-rs/foundry:v0.3.0
```

And then run `make bindings` again.

## Contributor Guidelines

Expand Down
8 changes: 4 additions & 4 deletions crates/utils/src/sdk/contractsregistry.rs

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions crates/utils/src/sdk/mockavsservicemanager.rs

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions crates/utils/src/sdk/mockerc20.rs

Large diffs are not rendered by default.

0 comments on commit 1a66fc2

Please sign in to comment.