Conversation
|
There was a problem hiding this comment.
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.Runnerinterface,CLIRunnerimplementation,ExitError, plus unit tests and a mock. - Add
CRERunnertodeployment.Environment, propagate it through cloning/runtime env regeneration, and expose options for CLD/test environments. - Minor mermaid renderer change to avoid
fmt.Sprintf+WriteStringpattern.
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.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
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.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
There was a problem hiding this comment.
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.
| return &MockRunner_Call_Call{Call: _e.mock.On("Call", | ||
| append([]interface{}{ctx}, args...)...)} |
There was a problem hiding this comment.
The generated mock’s variadic handling is inconsistent: Call(ctx, args...) forwards the variadic as a single []string argument (_mock.Called(ctx, args)), but the EXPECT().Call(...) helper builds expectations as if each variadic element were a separate argument (append([]interface{}{ctx}, args...)). As a result, EXPECT().Call(ctx, "build") will never match a real call; expectations must use a single []string, which is surprising and easy to misuse. Consider changing the Runner API to Call(ctx, args []string) (non-variadic), or adjust the mock generation/template so the expecter helper also expects a single []string argument.
| return &MockRunner_Call_Call{Call: _e.mock.On("Call", | |
| append([]interface{}{ctx}, args...)...)} | |
| // Normalize the variadic arguments so that the underlying mock always | |
| // sees the same shape as (*MockRunner).Call, i.e. (ctx, []string). | |
| var argSlice []string | |
| if len(args) == 1 { | |
| // If the caller passed a single []string, use it directly. | |
| if s, ok := args[0].([]string); ok { | |
| argSlice = s | |
| } | |
| } | |
| if argSlice == nil { | |
| // Otherwise, treat each variadic element as a string and build []string. | |
| argSlice = make([]string, len(args)) | |
| for i, a := range args { | |
| argSlice[i] = a.(string) | |
| } | |
| } | |
| return &MockRunner_Call_Call{Call: _e.mock.On("Call", ctx, argSlice)} |
| // CREAuthConfig holds authentication settings for CRE (Chainlink Runtime Environment) deploy operations. | ||
| type CREAuthConfig struct { | ||
| HMACKeyID string `mapstructure:"hmac_key_id" yaml:"hmac_key_id"` // Secret: HMAC key ID | ||
| HMACKeySecret string `mapstructure:"hmac_key_secret" yaml:"hmac_key_secret"` // Secret: HMAC key secret | ||
| TenantID string `mapstructure:"tenant_id" yaml:"tenant_id"` | ||
| OrgID string `mapstructure:"org_id" yaml:"org_id"` | ||
| } |
There was a problem hiding this comment.
CREAuthConfig introduces secret fields (HMAC key ID/secret) but lacks the same WARNING header used by other secret-bearing config structs in this file (e.g., KMSConfig, EVMConfig, JobDistributorAuth). Adding a similar warning helps prevent accidental logging or committing these credentials to config files.
There was a problem hiding this comment.
it'd be good to hear from cldf original maintainers if a root cre package is the way to go
|
|
||
| // Runner is used to invoke the CRE CLI. | ||
| type Runner interface { | ||
| Call(ctx context.Context, args ...string) (*CallResult, error) |
There was a problem hiding this comment.
if it's a Runner maybe the method should be called Run?
| cmd.Stdout = &stdout | ||
| cmd.Stderr = &stderr | ||
|
|
||
| err := cmd.Run() |
There was a problem hiding this comment.
minor observation: this means we can only run the cli commands synchronously, and will get no feedback until it's finished, correct?
I just wanted to check if this is desired, as it might be a good idea to review the design in case some of the commands take several seconds (for instance, by providing options to stream the commands stdout and/or stderr to custom io writers).
| { | ||
| name: "success", | ||
| skip: "windows", | ||
| runner: &CLIRunner{BinaryPath: "true"}, |
There was a problem hiding this comment.
problaby better to use a command that outputs something to stderr and stdout, and then add the associated assertions.
| // 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.Call() is used inside changesets. May be nil in test environments that did not set it. | ||
| CRERunner cre.Runner |
There was a problem hiding this comment.
forgive the ignorance, but does the cre client communicate with the blockchain directly? If not, should if be part of offchain.Client?
| Onchain OnchainConfig `mapstructure:"onchain" yaml:"onchain"` | ||
| Offchain OffchainConfig `mapstructure:"offchain" yaml:"offchain"` | ||
| Catalog CatalogConfig `mapstructure:"catalog" yaml:"catalog"` | ||
| // CRE is optional. If the cre block is absent from YAML and CRE_* env vars are unset, |
There was a problem hiding this comment.
this is true for several other parts of the config. Maybe the comment is not needed. Or just use a shorter one.
| } | ||
|
|
||
| // resolveCRERunner returns override if set, otherwise a CLIRunner for the given path. | ||
| func resolveCRERunner(override cre.Runner, binaryPath string) cre.Runner { |
There was a problem hiding this comment.
hmm.. this looks a bit confusing. Why can't we get away with WithCRERunner alone? At first glance it seems the resolveCRERunner and WithCREBinaryPath functions are redundant.




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
Runnerinterface (with a default implementationCLIRunner), 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
cre.Runnerinterface andcre.CLIRunnerimplementation for running the CRE CLI, along with supporting types (CallResult,ExitError) and comprehensive unit tests. [1] [2] [3] [4] [5]CRERunnerinto theEnvironmentstruct 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
WithCRERunner,WithCREBinaryPath), and implemented logic to resolve the runner based on overrides or binary path. [1] [2]Testing and Mocking
Runnerinterface using mockery and added tests for runner configuration and resolution logic. [1] [2]Dependency and Import Updates
crepackage and runner abstraction. [1] [2] [3] [4]Test Environment Support
These changes collectively provide a robust, configurable, and testable mechanism for interacting with the CRE CLI in deployment environments.