Skip to content

feat: add GitHub Actions output format#56

Merged
konradmichalik merged 3 commits intomainfrom
format-github
Jul 28, 2025
Merged

feat: add GitHub Actions output format#56
konradmichalik merged 3 commits intomainfrom
format-github

Conversation

@konradmichalik
Copy link
Copy Markdown
Contributor

@konradmichalik konradmichalik commented Jul 28, 2025

Fixes #54

Summary by CodeRabbit

  • New Features

    • Added support for a new output format, "github", to the translation validation command. This enables validation results to be output as GitHub Actions workflow annotations for improved CI integration.
  • Documentation

    • Updated documentation to reflect the new "github" output format option and improved formatting for command options.
  • Tests

    • Introduced comprehensive tests for the new GitHub Actions output format to ensure correct annotation rendering and statistics reporting.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jul 28, 2025

Walkthrough

Support for a new github output format was added across the translation validator tool, including documentation, schema, command-line options, and the renderer factory. A dedicated renderer for GitHub Actions workflow annotations was implemented, accompanied by comprehensive tests. The schema and documentation were updated to reflect the new format.

Changes

Cohort / File(s) Change Summary
Documentation Updates
docs/console-command.md
Updated documentation to include the new github output format in the --format option and adjusted whitespace for option descriptions.
Schema Update
schema/translation-validator.schema.json
Modified allowed values for the format property to include github and updated example usage accordingly.
Command Option and Help
src/Command/ValidateTranslationCommand.php
Added github as a valid value for the --format option and updated help text accordingly.
Format Enum Extension
src/Result/FormatType.php
Added new enum case GITHUB to support the new output format.
GitHub Renderer Implementation
src/Result/ValidationResultGitHubRenderer.php
Introduced a new renderer class for formatting validation results as GitHub Actions workflow annotations.
Renderer Factory Update
src/Result/ValidationResultRendererFactory.php
Extended the factory to instantiate the new GitHub renderer when the github format is selected.
Renderer Tests
tests/src/Result/ValidationResultGitHubRendererTest.php
Added a test suite for the new GitHub renderer, covering various scenarios and output validations.
Factory Tests
tests/src/Result/ValidationResultRendererFactoryTest.php
Added tests to verify that the factory correctly creates the GitHub renderer in different modes.
Enum Tests Update
tests/src/Result/FormatTypeTest.php
Extended enum test to include the new GITHUB case in the list of valid format types.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI_Command
    participant RendererFactory
    participant GitHubRenderer

    User->>CLI_Command: Run validate-translations --format=github
    CLI_Command->>RendererFactory: create(format=GITHUB, ...)
    RendererFactory->>GitHubRenderer: Instantiate
    CLI_Command->>GitHubRenderer: render(validationResult)
    GitHubRenderer->>CLI_Command: Output GitHub Actions annotations
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15–25 minutes

Assessment against linked issues

Objective Addressed Explanation
Implement a github output format for CI usage (#54)
Update documentation and schema to reflect new format (#54)
Ensure renderer outputs GitHub Actions workflow annotations (#54)
Provide tests for the new GitHub renderer (#54)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes detected.

Possibly related PRs

Poem

🐇✨
A new format hops into view,
For GitHub Actions, shiny and new!
Annotations leap with every test,
CI pipelines now work their best.
With docs and schema all aligned,
The rabbit’s work is well-defined!
📝🚀


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5669532 and d7b5905.

📒 Files selected for processing (2)
  • schema/translation-validator.schema.json (2 hunks)
  • tests/src/Result/FormatTypeTest.php (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • schema/translation-validator.schema.json
🧰 Additional context used
🧬 Code Graph Analysis (1)
tests/src/Result/FormatTypeTest.php (1)
src/Result/FormatType.php (1)
  • enum (26-30)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Test (PHP 8.1, Symfony 5.x, Composer 2.2)
  • GitHub Check: Test (PHP 8.1, Symfony 6.x, Composer 2.2)
  • GitHub Check: Test (PHP 8.3, Symfony 7.x, Composer 2.8)
  • GitHub Check: Test (PHP 8.2, Symfony 6.x, Composer 2.2)
🔇 Additional comments (1)
tests/src/Result/FormatTypeTest.php (1)

43-43: LGTM! Proper test coverage for the new enum case.

The addition of the FormatType::GITHUB assertion correctly extends the test coverage to include the new GitHub output format enum case, maintaining consistency with the existing test pattern for CLI and JSON cases.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch format-github

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🔭 Outside diff range comments (1)
src/Command/ValidateTranslationCommand.php (1)

214-214: Update error message to include GitHub format.

The error message is inconsistent with the new format support - it should mention all three supported formats.

Apply this diff to fix the inconsistent error message:

-            $this->io?->error('Invalid output format specified. Use "cli" or "json".');
+            $this->io?->error('Invalid output format specified. Use "cli", "json", or "github".');
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d1de972 and 5669532.

📒 Files selected for processing (8)
  • docs/console-command.md (1 hunks)
  • schema/translation-validator.schema.json (2 hunks)
  • src/Command/ValidateTranslationCommand.php (3 hunks)
  • src/Result/FormatType.php (1 hunks)
  • src/Result/ValidationResultGitHubRenderer.php (1 hunks)
  • src/Result/ValidationResultRendererFactory.php (1 hunks)
  • tests/src/Result/ValidationResultGitHubRendererTest.php (1 hunks)
  • tests/src/Result/ValidationResultRendererFactoryTest.php (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/Result/FormatType.php (1)
tests/src/Result/FormatTypeTest.php (2)
  • FormatTypeTest (30-44)
  • testEnumCases (38-43)
src/Command/ValidateTranslationCommand.php (2)
tests/src/Command/ValidateTranslationCommandTest.php (3)
  • testExecuteWithInvalidFormat (208-223)
  • testExecuteWithJsonFormat (142-164)
  • ValidateTranslationCommandTest (34-316)
tests/src/Command/ValidateTranslationCommandConfigTestSimple.php (2)
  • ValidateTranslationCommandConfigTestSimple (30-42)
  • testCommandHasConfigOption (33-41)
🔇 Additional comments (26)
docs/console-command.md (2)

10-10: Documentation correctly updated for new GitHub format.

The format option description now includes all three supported output formats.


13-13: Minor formatting improvement.

Whitespace adjustment improves consistency in the documentation table.

src/Command/ValidateTranslationCommand.php (3)

88-88: Command option description updated correctly.

The format option now includes all three supported formats.


127-127: Good addition of GitHub format usage example.

The help text now includes a practical example of using the new GitHub format.


152-154: Excellent documentation of output formats.

Clear and descriptive explanations for each output format, especially highlighting the CI integration purpose of the GitHub format.

schema/translation-validator.schema.json (1)

155-155: Example configuration updated appropriately.

The example now demonstrates usage of the new GitHub format.

src/Result/ValidationResultRendererFactory.php (1)

41-41: No missing import needed for ValidationResultGitHubRenderer

The ValidationResultRendererFactory and ValidationResultGitHubRenderer both reside in the MoveElevator\ComposerTranslationValidator\Result namespace (line 24 in each file), so the class can be referenced directly without an additional use statement. You can ignore the import suggestion and consider this resolved.

Likely an incorrect or invalid review comment.

tests/src/Result/ValidationResultRendererFactoryTest.php (4)

28-28: LGTM!

The import is correctly added and necessary for the new GitHub renderer tests.


133-147: LGTM!

The test method follows the established pattern and correctly verifies that the factory creates a GitHub renderer instance for the default configuration.


149-163: LGTM!

The test properly verifies GitHub renderer creation in dry run mode, maintaining consistency with the existing test patterns.


165-179: LGTM!

The test properly verifies GitHub renderer creation in strict mode, completing the test coverage for all configuration combinations.

src/Result/ValidationResultGitHubRenderer.php (6)

30-41: LGTM!

The render method has a clean structure with proper separation of concerns, delegating to specialized methods for issue and summary rendering.


43-56: LGTM!

The issue rendering logic properly groups issues by file and validator, providing organized output for GitHub Actions.


58-89: LGTM!

The GitHub annotation rendering correctly implements the GitHub Actions workflow command format with proper parameter handling and escaping.


91-116: LGTM!

The summary rendering provides appropriate GitHub annotation types based on validation results and includes useful statistics for CI feedback.


118-129: LGTM!

The property escaping correctly implements GitHub Actions annotation requirements with proper percent-encoding for special characters.


131-142: LGTM!

The data escaping correctly implements GitHub Actions requirements, appropriately handling fewer special characters than properties since data doesn't require comma/space escaping.

tests/src/Result/ValidationResultGitHubRendererTest.php (9)

42-46: LGTM!

The test setup properly initializes BufferedOutput for capturing renderer output, enabling precise output verification.


48-57: LGTM!

The test properly verifies successful validation rendering with correct exit code and notice message format.


59-81: LGTM!

The test comprehensively validates error rendering with proper GitHub annotation format, including all issue details and correct exit code.


83-103: LGTM!

The test properly validates warning rendering in normal mode with correct exit code (0) and notice-level summary.


105-127: LGTM!

The test properly validates strict mode behavior where warnings cause failure (exit code 1) with appropriate error summary message.


129-150: LGTM!

The test thoroughly validates special character escaping for GitHub Actions annotations, covering file paths, titles, and messages with various special characters.


152-162: LGTM!

The test properly validates statistics rendering with formatted execution time and validation metrics.


164-182: LGTM!

The test properly validates dry run mode behavior where validation errors don't cause failure (exit code 0) with appropriate notice message.


184-213: LGTM!

The helper method comprehensively creates ValidationResult test data with properly mocked validators and flexible configuration for different test scenarios.

{
case CLI = 'cli';
case JSON = 'json';
case GITHUB = 'github';
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

LGTM! New GitHub format enum case added correctly.

The addition follows the existing pattern and naming convention for enum cases.

Verify that the test file tests/src/Result/FormatTypeTest.php includes the new GITHUB case:


🏁 Script executed:

#!/bin/bash
# Description: Check if FormatTypeTest includes the new GITHUB enum case
# Expected: Test should verify GITHUB case is included in enum cases

rg -A 10 -B 5 "testEnumCases|assertContains.*FormatType::" tests/src/Result/FormatTypeTest.php

Length of output: 404


Add GITHUB to enum test cases

The test for FormatType::cases() needs to include the new GITHUB case:

• File: tests/src/Result/FormatTypeTest.php
• In testEnumCases(), add an assertion for FormatType::GITHUB

Suggested diff:

--- a/tests/src/Result/FormatTypeTest.php
+++ b/tests/src/Result/FormatTypeTest.php
@@ public function testEnumCases(): void
-        $this->assertContains(FormatType::CLI, $cases);
-        $this->assertContains(FormatType::JSON, $cases);
+        $this->assertContains(FormatType::CLI, $cases);
+        $this->assertContains(FormatType::JSON, $cases);
+        $this->assertContains(FormatType::GITHUB, $cases);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
case GITHUB = 'github';
$this->assertContains(FormatType::CLI, $cases);
$this->assertContains(FormatType::JSON, $cases);
$this->assertContains(FormatType::GITHUB, $cases);
🤖 Prompt for AI Agents
In src/Result/FormatType.php at line 30, the new enum case GITHUB has been added
but the test coverage is missing. To fix this, open
tests/src/Result/FormatTypeTest.php and locate the testEnumCases() method. Add
an assertion to verify that FormatType::GITHUB is included in the array returned
by FormatType::cases(), ensuring the new enum case is properly tested.

@konradmichalik konradmichalik merged commit 0fe5e2f into main Jul 28, 2025
28 checks passed
@konradmichalik konradmichalik deleted the format-github branch September 7, 2025 13:17
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.

Output Format Github

1 participant