Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: ensure PR testing runs correctly based on conditions #1486

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ssala034
Copy link
Contributor

@ssala034 ssala034 commented Apr 10, 2025

Description
Removed wrong equality check on different data types. Now should_test variable should be giving the needed value.

Related issue(s)
Related to #1345

Summary by CodeRabbit

  • Chores
    • Refined internal testing workflow configuration to improve how automated tests are triggered during development.

Copy link

changeset-bot bot commented Apr 10, 2025

⚠️ No Changeset found

Latest commit: 6ab90d7

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

coderabbitai bot commented Apr 10, 2025

Walkthrough

The pull request modifies the GitHub Actions workflow file to change the output assignment in the changes job. Instead of evaluating whether the modified_files output is non-empty, the workflow now assigns the modified_files output directly to should_test. The conditions in the test job have also been simplified, removing the dependency on the should_test output and adjusting the logic for determining if tests should run.

Changes

File Change Summary
.github/workflows/pr-testing-with-test-project.yml Updated the should_test output assignment in the changes job from a boolean check (!= '[]') to a direct assignment of modified_files output. Simplified the if condition in the test job by removing the dependency on should_test and modified the condition for determining if tests should run to include needs.changes.outputs.should_test == 'true'.

Sequence Diagram(s)

sequenceDiagram
    participant Filter as Filter Step
    participant Changes as Changes Job
    participant Test as Test Job
    Filter->>Changes: Provides modified_files output
    Changes->>Test: Passes should_test (array or empty array)
    Test->>Test: Checks if pull request is not a draft
    Test->>Test: Determines if tests should run based on should_test
Loading

Poem

In the realm of code where rabbits play,
I hopped through workflows in a clever way.
Changing booleans to lists with glee,
A tiny tweak, yet clear to see.
With twitching nose and a joyful heart,
I celebrate the changes—code magic, smart!
🐇✨

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.

🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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

@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: 1

🔭 Outside diff range comments (2)
.github/workflows/pr-testing-with-test-project.yml (2)

32-32: 🛠️ Refactor suggestion

⚠️ Potential issue

Adjust test job condition for proper evaluation

With the updated output type of should_test, the current condition:

if: ${{ needs.changes.outputs.should_test == 'true' && github.event.pull_request.draft == false }}

no longer correctly evaluates whether there are modified files. Consider modifying the condition to check that the modified files array is non-empty. For example:

-    if: ${{ needs.changes.outputs.should_test == 'true' && github.event.pull_request.draft == false }}
+    if: ${{ needs.changes.outputs.should_test != '[]' && github.event.pull_request.draft == false }}

This change ensures that tests run only when there are modified files.


15-16: 💡 Verification agent

❓ Verification inconclusive

Add missing step identifier for the paths-filter action

The workflow later references steps.filter.outputs.modified_files (line 12), but the corresponding step (using the rohansingh/paths-filter action) does not have an id assigned. To ensure the outputs can be properly referenced, add an identifier (for example, id: filter) to that step.

-      - uses: rohansingh/paths-filter@084ca29929a4e7e708a4aa8b790347facfd830c9 # fork with predicate-quantifier fix
+      - id: filter
+        uses: rohansingh/paths-filter@084ca29929a4e7e708a4aa8b790347facfd830c9 # fork with predicate-quantifier fix

Action Required: Add Missing Step Identifier in Workflow

To correctly reference the output from the paths-filter action via steps.filter.outputs.modified_files, please add an identifier to that step. For example, update the changes as shown below:

-      - uses: rohansingh/paths-filter@084ca29929a4e7e708a4aa8b790347facfd830c9 # fork with predicate-quantifier fix
+      - id: filter
+        uses: rohansingh/paths-filter@084ca29929a4e7e708a4aa8b790347facfd830c9 # fork with predicate-quantifier fix

This change ensures that the workflow can correctly reference the outputs of the paths-filter action.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f02dc4d and ff21e6d.

📒 Files selected for processing (1)
  • .github/workflows/pr-testing-with-test-project.yml (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/pr-testing-with-test-project.yml

12-12: property "filter" is not defined in object type {}

(expression)

derberg
derberg previously approved these changes Apr 10, 2025
@derberg
Copy link
Member

derberg commented Apr 10, 2025

Screenshot 2025-04-10 at 20 27 22

so the issue of "hanging" tests is still there, because we have if: ${{ needs.changes.outputs.should_test == 'true' && github.event.pull_request.draft == false }} at the job level.

part needs.changes.outputs.should_test == 'true' should be moved to Determine if tests should run step. Can you extend the if statement that is there already for bots and other beasts?

@ssala034
Copy link
Contributor Author

I'll look into updating the logic. Thanks for the feedback.

Copy link

@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: 0

🧹 Nitpick comments (1)
.github/workflows/pr-testing-with-test-project.yml (1)

41-58: Verify comprehensive conditions in "Determine if tests should run" step.
The step now uses a compound condition that:

  • Checks that needs.changes.outputs.should_test == 'true' (ensuring the paths-filter detected relevant changes),
  • Reaffirms that the PR is not a draft, and
  • Excludes test runs initiated by specific bot-generated pull requests.

This structure is clear and aligns with the objective to trigger tests only when there are meaningful file changes and the PR qualifies for testing. One minor point to consider: the non-draft check appears both at the job level (line 32) and here; while redundant, this may be intentional for increased robustness. If desired, you could refactor to remove the redundancy, but it is acceptable as-is.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ff21e6d and 6ab90d7.

📒 Files selected for processing (1)
  • .github/workflows/pr-testing-with-test-project.yml (3 hunks)
🧰 Additional context used
🧠 Learnings (1)
.github/workflows/pr-testing-with-test-project.yml (1)
Learnt from: derberg
PR: asyncapi/generator#1486
File: .github/workflows/pr-testing-with-test-project.yml:12-12
Timestamp: 2025-04-10T18:27:09.717Z
Learning: The paths-filter GitHub Action (like dorny/paths-filter or its fork rohansingh/paths-filter) outputs the string 'true' when files match a filter pattern, not an array. When using these outputs in workflow conditions, they should be checked with `== 'true'`, not compared against '[]'.
🪛 actionlint (1.7.4)
.github/workflows/pr-testing-with-test-project.yml

12-12: property "filter" is not defined in object type {}

(expression)

🔇 Additional comments (2)
.github/workflows/pr-testing-with-test-project.yml (2)

12-12: Validate output reference for should_test.
The output should_test is now assigned directly using ${{ steps.filter.outputs.modified_files }}, which correctly leverages the string output ('true') provided by the rohansingh/paths-filter action. However, ensure that the corresponding paths-filter step explicitly defines an id (e.g., id: filter) so that referencing it via steps.filter.outputs.modified_files is valid and avoids potential static analysis issues.

🧰 Tools
🪛 actionlint (1.7.4)

12-12: property "filter" is not defined in object type {}

(expression)


31-32: Simplify job-level condition check for non-draft PRs.
The job-level condition has been simplified to if: ${{ github.event.pull_request.draft == false }}, removing the direct dependency on should_test. This is acceptable since the detailed file-change check is now deferred to the "Determine if tests should run" step. Please confirm that this separation of concerns (global job execution controlled by draft status and step execution controlled by file changes and additional conditions) is the intended behavior.

@ssala034
Copy link
Contributor Author

@derberg The "hanging" tests quickly passed. Please lmk about any changes that should be made.

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.

3 participants