Skip to content

Dry run before publishing - #85

Open
mabadir wants to merge 2 commits into
mainfrom
ma/publish-dry-run
Open

Dry run before publishing#85
mabadir wants to merge 2 commits into
mainfrom
ma/publish-dry-run

Conversation

@mabadir

@mabadir mabadir commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds optional Ravion API validation to publish dry runs and surfaces validation failures in the generated PR plan.

  • Adds the --validate-remote CLI option and enables it in PR and main-branch dry-run workflow steps.
  • Adds an HTTP dry-run validation request for versions of existing remote definitions.
  • Adds structured validation errors and Markdown rendering for rejected configs.
  • Extends publish and workflow tests for the new validation behavior.

Confidence Score: 4/5

The PR needs fixes before merging because new definitions bypass remote validation and mixed validation failures hide part of the publish plan.

A rejected first version can leave a newly created definition globally published without a version, while the Markdown error path omits otherwise valid changes retained in the generated plan; the HTTP-specific validation contract also lacks direct test coverage.

Files Needing Attention: tools/ravion-modules/src/publish.ts, .github/workflows/module-definitions.yml, and tools/ravion-modules/test/publish.test.ts

Important Files Changed

Filename Overview
tools/ravion-modules/src/publish.ts Adds remote version validation and validation-error formatting, but skips validation for new definitions and suppresses retained plan items when any validation fails.
tools/ravion-modules/src/cli.ts Parses and forwards the new --validate-remote option while preserving structured error output.
.github/workflows/module-definitions.yml Enables remote validation in dry-run jobs, but the apply step can still partially publish newly introduced definitions that could not be prevalidated.
tools/ravion-modules/test/publish.test.ts Covers validation orchestration through a mock client but does not test the changed HTTP request envelope or strict success-status handling.
tools/ravion-modules/test/workflows.test.ts Updates workflow assertions for the new validation flag.

Sequence Diagram

sequenceDiagram
  participant CI as GitHub Actions
  participant CLI as ravion-modules CLI
  participant API as Ravion API
  CI->>CLI: publish --validate-remote
  CLI->>API: Load remote inventory
  alt Definition already exists
    CLI->>API: "POST module version with dryRun=true"
    API-->>CLI: Validation result
  else New definition
    CLI-->>CI: Skip remote validation
  end
  CI->>CLI: publish --apply
  CLI->>API: Create definition
  CLI->>API: Mark definition globally published
  CLI->>API: Create version
  API-->>CLI: Success or config rejection
Loading
Prompt To Fix All With AI
### Issue 1
tools/ravion-modules/src/publish.ts:238-242
**New definitions bypass validation**

When a new module has config accepted locally but rejected by the Ravion API, both dry runs skip remote validation because the definition does not exist yet. The later `--apply` run creates and globally publishes the definition before version creation fails, leaving a published definition with no version and failing the main-branch publish workflow.

### Issue 2
tools/ravion-modules/src/publish.ts:340-355
**Validation errors hide plan items**

When one module fails remote validation, the result still contains planned changes for every processed definition, but this early return renders only the failure table. The workflow uses this Markdown directly for the PR comment, so reviewers cannot see the other valid releases or their diffs.

### Issue 3
tools/ravion-modules/test/publish.test.ts:56-68
**HTTP validation path remains untested**

This test uses `MockRavionClient`, so it does not exercise the changed HTTP request envelope or the strict `202` response check in `HttpRavionModuleApiClient.validateModuleVersion`. Add an HTTP-client test for the dry-run request and success status so a mismatch with the API contract does not make every validation workflow fail.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "Merge branch 'main' into ma/publish-dry-..." | Re-trigger Greptile

Greptile also left 3 inline comments on this PR.

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

Ravion Module Publish Plan

Dry run only. No Ravion API mutations were made.

No publish changes are required. All versions already exist with identical config.

Comment on lines +238 to +242
if (dryRun && options.validateRemote) {
if (!remoteDefinition) {
options.logger?.(
`Skipping remote validation for ${definition.type}@${definition.version}; the module definition does not exist remotely yet.`,
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 New definitions bypass validation

When a new module has config accepted locally but rejected by the Ravion API, both dry runs skip remote validation because the definition does not exist yet. The later --apply run creates and globally publishes the definition before version creation fails, leaving a published definition with no version and failing the main-branch publish workflow.

Prompt To Fix With AI
This is a comment left during a code review.
Path: tools/ravion-modules/src/publish.ts
Line: 238-242

Comment:
**New definitions bypass validation**

When a new module has config accepted locally but rejected by the Ravion API, both dry runs skip remote validation because the definition does not exist yet. The later `--apply` run creates and globally publishes the definition before version creation fails, leaving a published definition with no version and failing the main-branch publish workflow.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Comment on lines +340 to +355
if (result.validationErrors && result.validationErrors.length > 0) {
lines.push(
"### 🚨 Remote Validation Failures 🚨",
"",
"The Ravion API rejected these module version configs during dry-run validation. Fix the module definition config before merging.",
"",
"| Module | Release Version | Error |",
"| --- | --- | --- |",
);
for (const error of result.validationErrors) {
lines.push(
`| \`${escapeMarkdownTableCell(error.type)}\` | \`${escapeMarkdownTableCell(error.version)}\` | ${escapeMarkdownTableCell(error.message)} |`,
);
}
lines.push("");
return lines.join("\n");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Validation errors hide plan items

When one module fails remote validation, the result still contains planned changes for every processed definition, but this early return renders only the failure table. The workflow uses this Markdown directly for the PR comment, so reviewers cannot see the other valid releases or their diffs.

Prompt To Fix With AI
This is a comment left during a code review.
Path: tools/ravion-modules/src/publish.ts
Line: 340-355

Comment:
**Validation errors hide plan items**

When one module fails remote validation, the result still contains planned changes for every processed definition, but this early return renders only the failure table. The workflow uses this Markdown directly for the PR comment, so reviewers cannot see the other valid releases or their diffs.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Comment on lines +56 to +68
it("validates create-version items remotely during dry run when requested", async () => {
const client = new MockRavionClient({
definitions: [{ id: "vpc", type: "ravion-aws-vpc", name: "AWS VPC", description: "AWS VPC and subnets." }],
});

const result = await publishDefinitions([createCompiledDefinition()], client, { dryRun: true, validateRemote: true });

assert.deepEqual(result.items.map(({ action, dryRun }) => ({ action, dryRun })), [{ action: "create-version", dryRun: true }]);
assert.deepEqual(client.validatedVersions, [
{ moduleDefinitionId: "vpc", version: "1.2.3", description: "Add subnet options.", config: { inputs: [{ id: "name", type: "string", label: "Name" }] } },
]);
assert.equal(client.createdVersions.length, 0);
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 HTTP validation path remains untested

This test uses MockRavionClient, so it does not exercise the changed HTTP request envelope or the strict 202 response check in HttpRavionModuleApiClient.validateModuleVersion. Add an HTTP-client test for the dry-run request and success status so a mismatch with the API contract does not make every validation workflow fail.

Prompt To Fix With AI
This is a comment left during a code review.
Path: tools/ravion-modules/test/publish.test.ts
Line: 56-68

Comment:
**HTTP validation path remains untested**

This test uses `MockRavionClient`, so it does not exercise the changed HTTP request envelope or the strict `202` response check in `HttpRavionModuleApiClient.validateModuleVersion`. Add an HTTP-client test for the dry-run request and success status so a mismatch with the API contract does not make every validation workflow fail.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

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