Skip to content

feat: add CRE runner to environment object#877

Merged
ecPablo merged 18 commits intomainfrom
ecpablo/add-cre-cli-runner
Mar 23, 2026
Merged

feat: add CRE runner to environment object#877
ecPablo merged 18 commits intomainfrom
ecpablo/add-cre-cli-runner

Conversation

@ecPablo
Copy link
Contributor

@ecPablo ecPablo commented Mar 19, 2026

Adds CRE CLI runner to the environment object as well as config variables.

AI Summary

This pull request introduces a new abstraction for invoking the CRE CLI tool within the deployment framework. The main changes are the addition of the Runner interface (with a default implementation CLIRunner), integration of this runner into the environment loading process, and support for configuration and testing of CRE CLI invocations. These changes enable flexible and testable interaction with the CRE CLI, including error handling and output inspection.

CRE CLI Integration

  • Added the cre.Runner interface and cre.CLIRunner implementation for running the CRE CLI, along with supporting types (CallResult, ExitError) and comprehensive unit tests. [1] [2] [3] [4] [5]
  • Integrated CRERunner into the Environment struct and environment loading logic, allowing CRE CLI invocation from changesets and supporting cloning of environments with the runner. [1] [2] [3] [4] [5] [6] [7] [8]

Configuration and Options

  • Added environment options for configuring the CRE CLI runner and binary path (WithCRERunner, WithCREBinaryPath), and implemented logic to resolve the runner based on overrides or binary path. [1] [2]
  • Extended environment variable mapping to include CRE-related settings such as authentication and storage address.

Testing and Mocking

  • Generated a mock for the Runner interface using mockery and added tests for runner configuration and resolution logic. [1] [2]

Dependency and Import Updates

  • Updated imports across multiple files to reference the new cre package and runner abstraction. [1] [2] [3] [4]

Test Environment Support

  • Updated test environment components and loader to support injecting a mock CRE runner for testing scenarios. [1] [2] [3]

These changes collectively provide a robust, configurable, and testable mechanism for interacting with the CRE CLI in deployment environments.

@changeset-bot
Copy link

changeset-bot bot commented Mar 19, 2026

🦋 Changeset detected

Latest commit: 55275dc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
chainlink-deployments-framework Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

Copilot AI left a comment

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 CRE CLI runner abstraction and threads it through environment construction so changesets/tests can invoke CRE via a pluggable runner.

Changes:

  • Introduce cre.Runner interface, CLIRunner implementation, ExitError, plus unit tests and a mock.
  • Add CRERunner to deployment.Environment, propagate it through cloning/runtime env regeneration, and expose options for CLD/test environments.
  • Minor mermaid renderer change to avoid fmt.Sprintf + WriteString pattern.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pkg/cre/runner.go Defines the core Runner interface and CallResult.
pkg/cre/cli_runner.go Implements Runner using os/exec and captures stdout/stderr/exit code.
pkg/cre/exit.go Adds ExitError for non-zero process exits.
pkg/cre/cli_runner_test.go Tests CLIRunner behavior (success, non-zero exit, missing binary, canceled ctx).
pkg/cre/exit_test.go Tests ExitError formatting and errors.As behavior.
pkg/cre/mocks/mock_runner.go Adds mockery-generated mock for cre.Runner.
deployment/environment.go Adds CRERunner field + WithCRERunner option + clones the field.
engine/test/environment/components.go Adds CRERunner to test environment components.
engine/test/environment/options.go Adds WithCRERunner LoadOpt for test environments.
engine/test/environment/environment.go Wires cmps.CRERunner into the returned test Environment.
engine/test/runtime/environment.go Preserves CRERunner when regenerating env from state.
engine/cld/environment/options.go Adds CLD options for CRE runner override and binary path + resolver helper.
engine/cld/environment/environment.go Sets Environment.CRERunner during CLD env load.
engine/cld/environment/fork.go Injects resolved runner into fork env creation.
engine/cld/config/env/config.go Adds viper env bindings for cre.* config keys.
engine/cld/mcms/proposalanalysis/examples/ccip/renderers/mermaid/renderer.go Switches to fmt.Fprintf(&builder, ...) for a few writes.
.mockery.yml Configures mockery generation for cre.Runner.

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

@ecPablo ecPablo marked this pull request as ready for review March 20, 2026 14:26
@ecPablo ecPablo requested a review from a team as a code owner March 20, 2026 14:27
Copilot AI review requested due to automatic review settings March 20, 2026 14:27
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.


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

@ecPablo ecPablo marked this pull request as draft March 20, 2026 16:38
ecPablo and others added 4 commits March 20, 2026 10:50
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@ecPablo ecPablo marked this pull request as ready for review March 20, 2026 19:35
Copilot AI review requested due to automatic review settings March 20, 2026 19:35
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.


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

Copy link
Contributor

Choose a reason for hiding this comment

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

it'd be good to hear from cldf original maintainers if a root cre package is the way to go

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I agree, maybe @graham-chainlink and @jkongie you guys can give us your thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

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

hmm, so far everything i see in cre package is quite generic except for the string cre . In the future will there be cre golang api code that will be implemented in this package? So far it looks to me like a generic cli command runner. I dont mind the cre root level package if it eventually becomes a very cre specific package.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah eventually we'll probably have to import a Go SDK and this interface will have a bit more CRE specific terminology. Right now the goal is just to provide a single interface to CRE while we get more clarity on the go sdk and then we can refactor.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if it should be in internal thoujgh. Do we want people to use this outside of CLDF directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would be accessed mainly through the Environment object. So it could make sense to make it internal. But seeing the implementation of the OffChain client seems the interface is still outside internal/ so not sure if we keep it that way to be consistent with both.

Copilot AI review requested due to automatic review settings March 23, 2026 14:02
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.


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

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 23, 2026 14:06
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.


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

// CRERunner invokes the CRE CLI from changesets. Optional in environment loading, so it won't
// fail to load environment if cre binary not available; failures (e.g. binary not found) only occur
// when CRERunner.Run() is used inside changesets. May be nil in test environments that did not set it.
CRERunner cre.Runner
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this means this will become a guarantee breaking change? If we update CRE runner eventually to use golang api instead of cli runner then this whole thing will either break or will it be replaced with a new field?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes for now this is the only option, we don't have any clarity on the Go API or even the CLI command flags that are needed for the offchain registry yet, so we opted to give the user flexibility and have them call the commands as they required. Once we have some changesets with usages we can decide on the best API to abstract this away, but it will always be a breaking change. Although for now I'm thinking about offering a couple default operations and changesets, these could be used initially so we have more control on where the CRERunner is being called

Copilot AI review requested due to automatic review settings March 23, 2026 14:57
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated no new comments.


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

@gustavogama-cll
Copy link
Contributor

looks good but there's now a minor linting issue and you probably want to add a changeset file

@cl-sonarqube-production
Copy link

@ecPablo ecPablo added this pull request to the merge queue Mar 23, 2026
Merged via the queue into main with commit 540ea5e Mar 23, 2026
22 checks passed
@ecPablo ecPablo deleted the ecpablo/add-cre-cli-runner branch March 23, 2026 16:46
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.

5 participants