feat: add GitHub Actions output format#56
Conversation
WalkthroughSupport for a new Changes
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15–25 minutes Assessment against linked issues
Assessment against linked issues: Out-of-scope changesNo out-of-scope changes detected. Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
🧰 Additional context used🧬 Code Graph Analysis (1)tests/src/Result/FormatTypeTest.php (1)
⏰ 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)
🔇 Additional comments (1)
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
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
📒 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 ValidationResultGitHubRendererThe
ValidationResultRendererFactoryandValidationResultGitHubRendererboth reside in theMoveElevator\ComposerTranslationValidator\Resultnamespace (line 24 in each file), so the class can be referenced directly without an additionalusestatement. 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'; |
There was a problem hiding this comment.
💡 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.phpLength 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.
| 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.
Fixes #54
Summary by CodeRabbit
New Features
Documentation
Tests