Skip to content

refactor: extract pipeline logic into shared pkg/pipeline package#180

Closed
alexvcodesphere wants to merge 2 commits intocodesphere-cloud:mainfrom
alexvcodesphere:feat/pipeline-refactor
Closed

refactor: extract pipeline logic into shared pkg/pipeline package#180
alexvcodesphere wants to merge 2 commits intocodesphere-cloud:mainfrom
alexvcodesphere:feat/pipeline-refactor

Conversation

@alexvcodesphere
Copy link
Member

Summary

Extracts the duplicated pipeline polling logic from cli/cmd/start_pipeline.go into a shared pkg/pipeline package. Both start_pipeline.go and pkg/deploy now use pipeline.Runner, eliminating duplicated and incorrect polling code.

Important

Depends on #178 — merge that first.

Changes

  • [NEW] pkg/pipeline/pipeline.go — shared Runner, polling (IDE server checks), stage validation, landscape sync before run
  • cli/cmd/start_pipeline.go — delegates to pipeline.Runner
  • cli/cmd/start_pipeline_test.go — updated error assertions + DeployLandscape mocks
  • pkg/deploy/deploy.goClient embeds pipeline.Client, RunPipeline uses pipeline.Runner
  • pkg/deploy/mocks.go — regenerated

Pipeline flow

prepare → test (if present) → sync landscape → run

Testing

  • make lint: 0 issues
  • make test: all tests pass (69/69)
  • make build: compiles cleanly
  • Live-tested against Codesphere workspace

Signed-off-by: Alex 132889147+alexvcodesphere@users.noreply.github.com

Refactor the standalone gh-action-deploy binary into two layers:

- pkg/deploy/: generic, provider-agnostic deployment engine
  (find, create, update, delete workspace + run pipeline)
- cli/cmd/deploy_github.go: GitHub-specific subcommand that reads
  GitHub Actions env vars and delegates to pkg/deploy

New commands:
  cs deploy          - parent command for CI/CD deployments
  cs deploy github   - GitHub Actions integration

The generic engine in pkg/deploy/ can be reused by future providers
(e.g. cs deploy gitlab).

Signed-off-by: Alex <132889147+alexvcodesphere@users.noreply.github.com>
Moves the pipeline polling logic (stage validation, IDE server checks,
allRunning, shouldAbort, deploy landscape sync) from cli/cmd/start_pipeline.go
into a shared pkg/pipeline package. Both start_pipeline.go and pkg/deploy
now use pipeline.Runner, eliminating duplicated and incorrect polling logic.

The deploy.Client interface now embeds pipeline.Client for shared pipeline
operations (StartPipelineStage, GetPipelineState, DeployLandscape).

The pipeline flow is: prepare → test (if present) → sync landscape → run.

Signed-off-by: Alex <132889147+alexvcodesphere@users.noreply.github.com>
@alexvcodesphere
Copy link
Member Author

Reorganizing into cleaner PRs

@alexvcodesphere alexvcodesphere deleted the feat/pipeline-refactor branch February 20, 2026 18:26
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.

1 participant