Skip to content

Conversation

@jmle
Copy link
Contributor

@jmle jmle commented Dec 15, 2025

Summary by CodeRabbit

  • Chores
    • Optimized CI/CD workflow to selectively run tests based on changed files, improving pipeline efficiency and reducing feedback time for developers.

✏️ Tip: You can customize this high-level summary in your review settings.

Signed-off-by: Juan Manuel Leflet Estrada <jleflete@redhat.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 15, 2025

Walkthrough

The workflow adds a branch comparison step to identify changed rule files and tests, then conditionally runs only the changed test files instead of the full test suite. When pushing to main, all tests run. The logic deduplicates test files and provides fallback handling for missing test output data.

Changes

Cohort / File(s) Summary
CI/CD Workflow Enhancement
\.github/workflows/local-ci\.yaml
Added "Fetch main branch for comparison" step. Introduced "Find changed rule files and their tests" step that identifies changed YAML rule files and test files by comparing against origin/main, builds a deduplicated test file list, and outputs has_tests and test_files flags. Reworked "Run rule tests" step to conditionally execute all tests, changed tests only, or zero-test placeholders based on branch context. Removed commented-out PR-notification block. Adjusted artifact upload and status badge logic to accommodate new test selection flow.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify branch comparison logic correctly identifies changed rule and test files
  • Ensure deduplication logic for test files is sound
  • Check conditional branching for all three execution paths (run all, run changed, skip)
  • Validate fallback parsing for missing test output data

Poem

🐰 Our tests now run with rabbit-quick precision,
Only changed rules face the testing decision!
Main branch gets the full suite's might,
While feature branches run what's right—
A workflow so clever, it makes logic light! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: implementing selective test execution for only the changed rules, which is the core focus of this workflow modification.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 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 8a8b480 and 15ce419.

⛔ Files ignored due to path filters (3)
  • default/generated/cloud-readiness/68-jca.windup.yaml is excluded by !**/generated/**
  • default/generated/eapxp6/180-eapxp_microprofile_openapi_4.0.mta.yaml is excluded by !**/generated/**
  • default/generated/eapxp6/eapxp_microprofile_bom_renamed.mta.yaml is excluded by !**/generated/**
📒 Files selected for processing (1)
  • .github/workflows/local-ci.yaml (3 hunks)
⏰ 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). (2)
  • GitHub Check: Build tackle2-hub
  • GitHub Check: test
🔇 Additional comments (4)
.github/workflows/local-ci.yaml (4)

23-25: Graceful handling of missing main branch.

The || true ensures the workflow doesn't fail if origin/main doesn't exist (e.g., on first PR against the repo). This is a safe approach.


27-119: Comprehensive test selection logic with proper deduplication.

The step correctly:

  • Short-circuits to all tests when pushing to main (line 31).
  • Uses three-dot git diff syntax to identify changes relative to origin/main (line 44).
  • Collects both directly changed test files and test files derived from changed rules (lines 59–104).
  • Deduplicates test files before output (lines 88–94).
  • Uses proper multiline heredoc format for GitHub Actions output (lines 117–119).

The logic is sound and handles the intended use case well.


139-141: Potential fragility with unquoted variable expansion.

Line 141 expands $test_files unquoted in the kantra command:

RUN_LOCAL=1 ./kantra test $test_files --log-level 50

If any test file paths contain spaces, this would break. While unlikely in a YAML repository, a more defensive approach would be to quote the variable. However, since test files are space-separated and kantra expects individual arguments, quoting would require additional handling (e.g., eval or array-based approach), which is complex with GitHub Actions output.

Current approach is acceptable given the YAML file context, but worth noting if filename conventions change.

Can you confirm that kantra CLI correctly receives space-separated file paths as shown on line 141?


145-152: Safe fallback handling for missing test output.

When no tests run:

  • Lines 145–146 create a placeholder message with "0/0" summaries.
  • Line 149 attempts to tail output.log (which doesn't exist), fails silently due to || true, and preserves the placeholder.
  • Lines 150–152 extract pass rates from the placeholder message, with a fallback at line 150 for missing "Rules Summary:".

This fallback chain is safe and correctly handles the no-tests case.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

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