Skip to content

feat: private workflow registry deployment behind a feature flag#367

Merged
j-nowak merged 28 commits intomainfrom
DEVSVCS-4615/private-registry-deploy
Apr 15, 2026
Merged

feat: private workflow registry deployment behind a feature flag#367
j-nowak merged 28 commits intomainfrom
DEVSVCS-4615/private-registry-deploy

Conversation

@j-nowak
Copy link
Copy Markdown
Contributor

@j-nowak j-nowak commented Apr 11, 2026

  • Added a preview private-registry deploy path for cre workflow deploy behind --preview-private-registry (STAGING-only).
  • Refactored deploy orchestration into target-specific strategies (onchain vs private) and routed pre-checks/upsert through a shared interface.
  • Implemented private-registry upsert flow via GraphQL client, including request payload mapping and deploy result output.
  • Updated artifact handling so uploads happen after pre-deploy checks and are skipped when artifact URLs are already provided.
  • Added broad test coverage (unit + integration/multi-command flow) for private-registry target resolution, owner derivation, input mapping, and happy-path deploy behavior.

@j-nowak j-nowak changed the base branch from main to DEVSVCS-4530/registry-client April 11, 2026 04:44
@j-nowak j-nowak force-pushed the DEVSVCS-4615/private-registry-deploy branch from 39b44d6 to a4048aa Compare April 11, 2026 04:45
// resolveWorkflowOwner returns the effective owner address for workflow ID computation.
// For private registry deploys, the owner is derived from tenantID and organizationID.
// For onchain deploys, the configured WorkflowOwner address is used directly.
func (h *handler) resolveWorkflowOwner(targetWorkflowRegistry registryTarget) (string, error) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Temporary implementation, that will be resolved with derived workflow owner from GQL in the future.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah, I was going to note this. Would we add a new resolveOwner endpoint? From what I can see this flow does not support API_KEY yet, which is fine for now but will need to be supported eventually

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We discussed offline, we will use derieved owner from API call, part of a follow up work.

Copy link
Copy Markdown
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

This PR introduces a preview “private workflow registry” deploy path (STAGING-only) and refactors workflow deployment to route through registry-specific strategies (onchain vs private), with accompanying unit and e2e coverage.

Changes:

  • Add --preview-private-registry flag and resolve registry target (private vs onchain) with STAGING gating.
  • Refactor deploy flow into registryDeployStrategy implementations for onchain and private registry upsert behavior.
  • Add unit tests + multi-command e2e happy path for private registry deployment.

Reviewed changes

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

Show a summary per file
File Description
test/multi_command_test.go Adds multi-command happy path case for private registry deploy preview flag.
test/multi_command_flows/workflow_private_registry.go New e2e flow mocking GraphQL + upload endpoints to validate private registry deploy output.
cmd/workflow/deploy/registry_deploy_strategy_test.go Unit tests for registry target resolution and STAGING-only gating.
cmd/workflow/deploy/registry_deploy_strategy_private.go Implements private registry deploy strategy using GraphQL upsert + details output.
cmd/workflow/deploy/registry_deploy_strategy_onchain.go Extracts onchain deploy logic into a strategy with async WRC initialization and prechecks.
cmd/workflow/deploy/registry_deploy_strategy.go Adds target resolution + strategy factory and STAGING-only validation for preview.
cmd/workflow/deploy/private_registry_test.go Adds tests for private-registry inputs mapping and owner derivation behavior.
cmd/workflow/deploy/prepare.go Updates workflow artifact preparation to accept an explicit workflow owner for WorkflowID generation.
cmd/workflow/deploy/deploy_test.go Adds tests for resolving private registry target/owner and executing private deploy path via mocked GraphQL.
cmd/workflow/deploy/deploy.go Adds preview flag + target selection, derives owner for private registry, and orchestrates deploy via strategies.
cmd/workflow/deploy/compile_test.go Updates tests for the new PrepareWorkflowArtifact(workflowOwner) signature.
cmd/workflow/deploy/autoLink.go Uses resolved h.inputs.WorkflowOwner for autolink inputs.

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

Comment thread cmd/workflow/deploy/deploy.go
Comment thread test/multi_command_flows/workflow_private_registry.go Outdated
Copy link
Copy Markdown
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 14 out of 14 changed files in this pull request and generated 3 comments.


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

Comment thread cmd/workflow/deploy/private_registry_test.go
Comment thread cmd/workflow/deploy/artifacts_test.go
Comment thread test/multi_command_flows/workflow_private_registry.go Outdated
@j-nowak j-nowak requested a review from timothyF95 April 14, 2026 04:32
j-nowak and others added 2 commits April 14, 2026 07:52
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
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 14 out of 14 changed files in this pull request and generated 3 comments.


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

Comment thread cmd/workflow/deploy/registry_deploy_strategy.go Outdated
Comment thread cmd/workflow/deploy/deploy.go Outdated
Comment thread test/multi_command_flows/workflow_private_registry.go Outdated
Base automatically changed from DEVSVCS-4530/registry-client to main April 14, 2026 07:02
Copy link
Copy Markdown
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 14 out of 14 changed files in this pull request and generated 1 comment.


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

Comment thread cmd/workflow/deploy/registry_deploy_strategy_onchain.go
Comment on lines +25 to +42
func createTestBearerCredentialsHome(t *testing.T) string {
t.Helper()

homeDir := t.TempDir()
creDir := filepath.Join(homeDir, ".cre")
require.NoError(t, os.MkdirAll(creDir, 0o700), "failed to create .cre dir")

jwt := createTestJWT("test-org-id")
creConfig := "AccessToken: " + jwt + "\n" +
"IDToken: test-id-token\n" +
"RefreshToken: test-refresh-token\n" +
"ExpiresIn: 3600\n" +
"TokenType: Bearer\n"

require.NoError(t, os.WriteFile(filepath.Join(creDir, "cre.yaml"), []byte(creConfig), 0o600), "failed to write test credentials")

return homeDir
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The private registry test needs to override HOME (and consequently GOPATH) because it uses bearer token (JWT) authentication rather than the API key authentication used by the other happy-path e2e tests.

Why HOME must be overridden:

The other on-chain/EOA deploy tests authenticate by simply setting an environment variable (t.Setenv(credentials.CreApiKeyVar, "test-api")). The CLI reads that env var directly — no files on disk involved, no need to touch HOME.
The private registry flow authenticates using bearer credentials stored in a file at ~/.cre/cre.yaml. The test must fabricate a fake cre.yaml containing a synthetic JWT (with the right org_id, exp, etc.) so the CLI subprocess can read it. To make the subprocess find the fake credentials file (instead of the real user's ~/.cre/cre.yaml, or fail because none exists), HOME is redirected to a t.TempDir() where the fake .cre/cre.yaml lives.
Why GOPATH must be pinned:

When HOME is overridden to a temp directory, Go's default GOPATH becomes $HOME/go — which now points inside the temp dir (e.g. /tmp/.../go). The Go module cache under GOPATH contains read-only files. When the test finishes, t.TempDir() cleanup tries to remove the entire temp directory tree. It cannot delete the read-only module cache files, which causes the cleanup to fail and marks the test as failed even though the actual test logic succeeded. By explicitly setting GOPATH back to the real home's go directory (e.g. /Users/jnowak/go), the module cache stays outside the temp dir and cleanup succeeds cleanly.

In short: the on-chain tests inject auth via a simple env var, but the private registry test injects auth via a file on disk, which forces the HOME override, which in turn necessitates the GOPATH fix to avoid a spurious cleanup failure.

@j-nowak j-nowak marked this pull request as ready for review April 14, 2026 08:38
@j-nowak j-nowak requested a review from a team as a code owner April 14, 2026 08:38
@j-nowak j-nowak changed the title [WIP] Private workflow registry deployment feat: private workflow registry deployment behind a feature flag Apr 14, 2026
timothyF95
timothyF95 previously approved these changes Apr 15, 2026
Copy link
Copy Markdown
Contributor

@timothyF95 timothyF95 left a comment

Choose a reason for hiding this comment

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

Can address in follow up PR

Comment thread cmd/workflow/deploy/deploy.go Outdated
// resolveWorkflowOwner returns the effective owner address for workflow ID computation.
// For private registry deploys, the owner is derived from tenantID and organizationID.
// For onchain deploys, the configured WorkflowOwner address is used directly.
func (h *handler) resolveWorkflowOwner(targetWorkflowRegistry registryTarget) (string, error) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah, I was going to note this. Would we add a new resolveOwner endpoint? From what I can see this flow does not support API_KEY yet, which is fine for now but will need to be supported eventually


const (
registryTargetOnchain registryTargetType = "onchain"
registryTargetPrivate registryTargetType = "private"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we reuse the registry types already defined by tenant manifest?

func mapRegistryType(gqlType string) string {

We could hoist as an enum or const as you suggested in #371 (comment)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This part should be refactored in https://smartcontract-it.atlassian.net/browse/DEVSVCS-4634. I guess the flow control will change and use fields directly from resolved registry.

@j-nowak j-nowak added this pull request to the merge queue Apr 15, 2026
Merged via the queue into main with commit 95f28c3 Apr 15, 2026
21 checks passed
@j-nowak j-nowak deleted the DEVSVCS-4615/private-registry-deploy branch April 15, 2026 09:02
Fletch153 pushed a commit that referenced this pull request Apr 16, 2026
* registry client

* tests

* linter

* initial implementation of private workflow registry deploy

* refactoring

* fix derived owner

* init refactoring

* move workflow exists function

* merge input to usage

* remove not neeeded check

* merge registry target and adapter logic

* consolidate files

* refactor deploy inputs

* rename

* add unit tests

* init e2e test

* improve test

* remove redundant file

* rename

* linter

* fix wornflow owner

* Update cmd/workflow/deploy/artifacts_test.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update test/multi_command_flows/workflow_private_registry.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* code review fixes

* docs

* fix test

* update doc for temp feature flag

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.

3 participants