Conversation
There was a problem hiding this comment.
Pull request overview
Adds CRE workflow pause and delete capabilities to the changesets/operations layers, enabling these actions to be executed via the CRE CLI with unit test coverage.
Changes:
- Introduces
CREWorkflowPauseOp/CREWorkflowDeleteOpoperations (argument building, artifact prep, CLI invocation, exit/error handling). - Adds
CREWorkflowPauseChangeset/CREWorkflowDeleteChangesetchangesets (precondition checks and env config loading). - Adds unit tests for both operations and changesets.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
cre/operations/workflow_pause.go |
Implements CLI-backed workflow pause operation + args builder. |
cre/operations/workflow_pause_test.go |
Unit tests for pause operation, args building, and input validation. |
cre/operations/workflow_delete.go |
Implements CLI-backed workflow delete operation + args builder. |
cre/operations/workflow_delete_test.go |
Unit tests for delete operation, args building, and input validation. |
cre/changesets/workflow_pause.go |
Adds pause changeset wiring (env load + operation execution). |
cre/changesets/workflow_pause_test.go |
Tests pause changeset preconditions and apply behavior. |
cre/changesets/workflow_delete.go |
Adds delete changeset wiring (env load + operation execution). |
cre/changesets/workflow_delete_test.go |
Tests delete changeset preconditions and apply behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| func TestCREWorkflowDeleteChangeset_Apply(t *testing.T) { | ||
| t.Parallel() | ||
| cs := CREWorkflowDeleteChangeset{} | ||
| input := validDeleteInput(t) | ||
|
|
||
| t.Run("success returns report", func(t *testing.T) { | ||
| t.Parallel() | ||
| mockCLI := cremocks.NewMockCLIRunner(t) | ||
| mockCLI.EXPECT().ContextRegistries().Return([]fcre.ContextRegistryEntry{{ID: "private", Type: "off-chain"}}).Once() | ||
| mockCLI.EXPECT(). | ||
| Run(mock.Anything, (map[string]string)(nil), matchCLIArgs("workflow", "delete")). | ||
| Return(&fcre.CallResult{ExitCode: 0, Stdout: []byte("ok")}, nil). | ||
| Once() | ||
| env := newDeleteTestEnv(t, testenv.WithCRERunner(fcre.NewRunner(fcre.WithCLI(mockCLI)))) | ||
|
|
||
| out, err := cs.Apply(*env, input) | ||
| require.NoError(t, err) | ||
| require.Len(t, out.Reports, 1) | ||
| output, ok := out.Reports[0].Output.(operations.CREWorkflowDeleteOutput) | ||
| require.True(t, ok) | ||
| require.Equal(t, 0, output.ExitCode) | ||
| require.Equal(t, "ok", output.Stdout) | ||
| }) | ||
|
|
||
| t.Run("operation error returns report and error", func(t *testing.T) { | ||
| t.Parallel() | ||
| mockCLI := cremocks.NewMockCLIRunner(t) | ||
| mockCLI.EXPECT().ContextRegistries().Return([]fcre.ContextRegistryEntry{{ID: "private", Type: "off-chain"}}).Once() | ||
| mockCLI.EXPECT().Run(mock.Anything, mock.Anything, mock.Anything). | ||
| Return((*fcre.CallResult)(nil), errors.New("op failed")). | ||
| Once() | ||
| env := newDeleteTestEnv(t, testenv.WithCRERunner(fcre.NewRunner(fcre.WithCLI(mockCLI)))) | ||
|
|
||
| out, err := cs.Apply(*env, input) | ||
| require.ErrorContains(t, err, "cre workflow delete: op failed") | ||
| require.Len(t, out.Reports, 1) | ||
| output, ok := out.Reports[0].Output.(operations.CREWorkflowDeleteOutput) | ||
| require.True(t, ok) | ||
| require.Empty(t, output.Stdout) | ||
| }) |
There was a problem hiding this comment.
The deploy changeset tests include coverage for on-chain registries injecting the deployer key env (CRE_ETH_PRIVATE_KEY) into the CLI invocation (cre/changesets/workflow_deploy_test.go:184-202). This delete changeset currently only exercises off-chain registries; adding an on-chain registry test would ensure delete also passes the deployer key env when required and stays consistent with deploy behavior.
| args := BuildWorkflowPauseArgs(target, workDir, envPath, input.ExtraCREArgs) | ||
| b.Logger.Infow("Running CRE workflow pause", "args", args) | ||
|
|
||
| res, runErr := deps.CLI.Run(ctx, nil, args...) | ||
| if runErr != nil { |
There was a problem hiding this comment.
CREWorkflowDeployOp conditionally injects CRE_ETH_PRIVATE_KEY into the CLI env for on-chain registries (see cre/operations/workflow_deploy.go:160-166), but CREWorkflowPauseOp always calls deps.CLI.Run(ctx, nil, ...). This means pausing workflows against on-chain registries will not receive the deployer key env even though CREDeployDeps provides it. Consider mirroring the deploy op behavior: detect on-chain registries from ctxCfg and pass a non-nil env map with CRE_ETH_PRIVATE_KEY when needed.
| args := BuildWorkflowDeleteArgs(target, workDir, envPath, input.ExtraCREArgs) | ||
| b.Logger.Infow("Running CRE workflow delete", "args", args) | ||
|
|
||
| res, runErr := deps.CLI.Run(ctx, nil, args...) |
There was a problem hiding this comment.
CREWorkflowDeployOp injects CRE_ETH_PRIVATE_KEY for on-chain registries (cre/operations/workflow_deploy.go:160-166), but CREWorkflowDeleteOp always runs the CLI with a nil env map. If DeploymentRegistry is an on-chain registry, the delete command likely requires the same signer env to authenticate. Consider adding the same on-chain-registry detection and env injection here so delete behaves consistently with deploy.
| res, runErr := deps.CLI.Run(ctx, nil, args...) | |
| var cliEnv map[string]string | |
| if ethPrivateKey, ok := os.LookupEnv("CRE_ETH_PRIVATE_KEY"); ok && strings.TrimSpace(ethPrivateKey) != "" { | |
| cliEnv = map[string]string{ | |
| "CRE_ETH_PRIVATE_KEY": ethPrivateKey, | |
| } | |
| } | |
| res, runErr := deps.CLI.Run(ctx, cliEnv, args...) |
| func TestCREWorkflowPauseChangeset_Apply(t *testing.T) { | ||
| t.Parallel() | ||
| cs := CREWorkflowPauseChangeset{} | ||
| input := validPauseInput(t) | ||
|
|
||
| t.Run("success returns report", func(t *testing.T) { | ||
| t.Parallel() | ||
| mockCLI := cremocks.NewMockCLIRunner(t) | ||
| mockCLI.EXPECT().ContextRegistries().Return([]fcre.ContextRegistryEntry{{ID: "private", Type: "off-chain"}}).Once() | ||
| mockCLI.EXPECT(). | ||
| Run(mock.Anything, (map[string]string)(nil), matchCLIArgs("workflow", "pause")). | ||
| Return(&fcre.CallResult{ExitCode: 0, Stdout: []byte("ok")}, nil). | ||
| Once() | ||
| env := newPauseTestEnv(t, testenv.WithCRERunner(fcre.NewRunner(fcre.WithCLI(mockCLI)))) | ||
|
|
||
| out, err := cs.Apply(*env, input) | ||
| require.NoError(t, err) | ||
| require.Len(t, out.Reports, 1) | ||
| output, ok := out.Reports[0].Output.(operations.CREWorkflowPauseOutput) | ||
| require.True(t, ok) | ||
| require.Equal(t, 0, output.ExitCode) | ||
| require.Equal(t, "ok", output.Stdout) | ||
| }) | ||
|
|
||
| t.Run("operation error returns report and error", func(t *testing.T) { | ||
| t.Parallel() | ||
| mockCLI := cremocks.NewMockCLIRunner(t) | ||
| mockCLI.EXPECT().ContextRegistries().Return([]fcre.ContextRegistryEntry{{ID: "private", Type: "off-chain"}}).Once() | ||
| mockCLI.EXPECT().Run(mock.Anything, mock.Anything, mock.Anything). | ||
| Return((*fcre.CallResult)(nil), errors.New("op failed")). | ||
| Once() | ||
| env := newPauseTestEnv(t, testenv.WithCRERunner(fcre.NewRunner(fcre.WithCLI(mockCLI)))) | ||
|
|
||
| out, err := cs.Apply(*env, input) | ||
| require.ErrorContains(t, err, "cre workflow pause: op failed") | ||
| require.Len(t, out.Reports, 1) | ||
| output, ok := out.Reports[0].Output.(operations.CREWorkflowPauseOutput) | ||
| require.True(t, ok) | ||
| require.Empty(t, output.Stdout) | ||
| }) |
There was a problem hiding this comment.
The deploy changeset has a dedicated test asserting that on-chain registries inject CRE_ETH_PRIVATE_KEY into the CLI env (cre/changesets/workflow_deploy_test.go:184-202). Since this changeset introduces a new workflow operation that also targets a DeploymentRegistry, it should add an equivalent on-chain test case to ensure pause passes the deployer key env when the registry type is on-chain (and to prevent regressions once the operation is updated).
This pull request introduces support for CRE workflow pause and delete operations, including their implementation and comprehensive unit tests. The changes add new changeset types for pausing and deleting workflows, define the corresponding operation logic, and ensure robust input validation and error handling.
New CRE Workflow Operations:
CREWorkflowPauseChangesetandCREWorkflowDeleteChangesettypes to manage workflow pause and delete actions, including precondition checks and integration with the CRE CLI and environment configuration. [1] [2]CREWorkflowDeleteOpoperation, which handles the CLI invocation, artifact preparation, argument construction, and result parsing for workflow deletion.Testing and Validation:
Validatemethod, checking for required fields and proper formatting.