feat(cli): add compile command to emit GitHub/GitLab CI YAML from a single TS plan - #35
Conversation
🤖 CodeAnt AI — Review Status
|
MergerWaiting for CI and review to complete. Commit |
|
Important Review skippedReview was skipped due to path filters ⛔ Files ignored due to path filters (1)
CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe SDK now exposes canonical plans through ChangesPlan compilation
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant CLI as compileCommand
participant SDK as Sverka.toPlan
participant GitHub as `@sverka/compiler-github`
participant GitLab as `@sverka/compiler-gitlab`
participant Output as stdout_or_output_file
CLI->>SDK: Build canonical Plan
alt target is github
CLI->>GitHub: Compile Plan to GitHub Actions YAML
GitHub-->>CLI: Return YAML
else target is gitlab
CLI->>GitLab: Compile Plan to GitLab CI YAML
GitLab-->>CLI: Return YAML
end
CLI->>Output: Write or emit YAML
Possibly related PRs
Suggested labels: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
This PR successfully adds the compile command functionality to transform Sverka workflows into CI YAML for GitHub Actions and GitLab CI. The implementation follows existing patterns and includes appropriate validation and testing. The code is ready to merge.
You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 13 |
| Duplication | 3 |
AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.
TIP This summary will be updated as you push new changes.
PR Summary by QodoAdd
AI Description
Diagram
High-Level Assessment
Files changed (9)
|
There was a problem hiding this comment.
Pull Request Overview
This PR introduces the compile command to the CLI and extends the SDK to support workflow plan generation. Although Codacy indicates the PR is up to standards, there are critical logic errors: specifically, packages/sdk/src/sverka.ts is missing required imports for Plan and validatePlan, which will cause runtime failures. Furthermore, the Plan type is not exported from the SDK's public API, breaking compatibility for external consumers.
From a requirements perspective, while most acceptance criteria are met, there is a total lack of integration tests for the --format json output option in the CLI. The file packages/sdk/src/sverka.ts is flagged as both complex and uncovered by tests, making the logic duplication identified there particularly risky. These issues should be addressed before merging.
About this PR
- The implementation of
--format jsonlacks corresponding integration tests incompile.test.ts. Please add test cases to verify the JSON structure for both terminal output and file-based output. - Please update the PR title to reflect the implementation of the CLI compile command and SDK IR exposure.
Test suggestions
- Compile a workflow to GitHub Actions YAML and output to stdout
- Compile a workflow to GitLab CI YAML and output to stdout
- Save compiled YAML to a file path and verify parent directory creation
- Verify usage error is returned for an unsupported target (e.g., 'azure')
- Verify JSON output format when compiling to stdout includes the generated YAML
- Verify JSON output format when saving to a file includes the target path
- Verify SDK
toPlan()correctly synthesizes and validates the workflow IR - Unit tests for uncovered logic in complex file
packages/sdk/src/sverka.ts
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Verify JSON output format when compiling to stdout includes the generated YAML
2. Verify JSON output format when saving to a file includes the target path
3. Unit tests for uncovered logic in complex file `packages/sdk/src/sverka.ts`
TIP Improve review quality by adding custom instructions
TIP How was this review? Give us feedback
Code Review by Qodo
1.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/sdk/src/sverka.ts`:
- Around line 122-130: Update the plan validation flow in toPlan so validatePlan
is invoked even when operations is empty; remove the operations.length
conditional and preserve the existing SdkError handling for invalid plans.
Ensure empty auto-discovered plans are rejected before being returned to
compileCommand.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: e625ceb1-1d42-41f0-9e28-e6abdf5fc1f9
⛔ Files ignored due to path filters (1)
bun.lockis excluded by!**/*.lock
📒 Files selected for processing (8)
packages/cli/package.jsonpackages/cli/src/__tests__/compile.test.tspackages/cli/src/commands/compile.tspackages/cli/src/main.tspackages/sdk/src/__tests__/public-api.test.tspackages/sdk/src/index.tspackages/sdk/src/sverka.tspackages/sdk/src/types.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
- GitHub Check: Codacy Static Code Analysis
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx}: - Noany: Useunknownand narrow. Strict TypeScript.
- Error handling: Custom error classes per package.
Files:
packages/sdk/src/__tests__/public-api.test.tspackages/sdk/src/index.tspackages/cli/src/main.tspackages/cli/src/commands/compile.tspackages/cli/src/__tests__/compile.test.tspackages/sdk/src/types.tspackages/sdk/src/sverka.ts
**/src/index.ts
📄 CodeRabbit inference engine (AGENTS.md)
- Public API: Everything public is exported from
src/index.ts.
Files:
packages/sdk/src/index.ts
🪛 GitHub Check: SonarCloud Code Analysis
packages/cli/src/commands/compile.ts
[warning] 67-67: 'If' statement should not be the only statement in 'else' block
🔇 Additional comments (8)
packages/cli/package.json (1)
25-26: LGTM!packages/cli/src/commands/compile.ts (1)
1-81: LGTM!packages/cli/src/main.ts (1)
15-15: LGTM!Also applies to: 69-83, 115-115, 146-147, 192-208
packages/cli/src/__tests__/compile.test.ts (1)
1-94: LGTM!packages/sdk/src/types.ts (1)
5-5: LGTM!Also applies to: 42-42, 54-55
packages/sdk/src/sverka.ts (1)
44-46: LGTM!Also applies to: 58-62
packages/sdk/src/index.ts (1)
100-100: LGTM!packages/sdk/src/__tests__/public-api.test.ts (1)
10-10: LGTM!Also applies to: 54-54
0e11711 to
bcf86bb
Compare
- Add toPlan() to SDK to build canonical Plan IR from sverka.config.ts. - Wire compiler-github and compiler-gitlab into CLI deps. - Add compile command: sverka compile --target github|gitlab [--output <path>]. - Output YAML to stdout or file, with JSON format support. - Add CLI tests for github/gitlab output and --output. Relates-to: sverka design - compile single TS plan to multiple CI targets. Co-Authored-By: Petr Plenkov <petr.plenkov@gmail.com>
bcf86bb to
698f38d
Compare
|



Summary
Adds
sverka compile --target github|gitlabso the samesverka.config.tscan be turned into either GitHub Actions or GitLab CI YAML through the existing canonicalPlanIR.What changed
@sverka/sdknow builds the canonicalPlanIR during planning:PlanResultgainsplan: PlanSverka.toPlan()and top-leveltoPlan()return the validatedPlanIR directly@sverka/clidepends on@sverka/compiler-githuband@sverka/compiler-gitlabsverka compilecommand:--target github|gitlab(required)--output <path>/-o <path>to write the YAML to a file--format jsonfor tool integrationpackages/cli/src/__tests__/compile.test.tsfor both targets and--outputExample
This keeps the thin-wrapper compiler design from ADR-004: the generated CI config runs
sverka executeinside the CI runner, using the same Plan derivation as local runs.Verification
bunx nx run-many --target=typecheck --allpassesbunx nx run-many --target=lint --allpassesbunx nx run-many --target=test --allpasses