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: Fix Cypress test fail not reported for /test command #34278

Merged
merged 5 commits into from
Jul 1, 2024

Conversation

sharat87
Copy link
Member

@sharat87 sharat87 commented Jun 17, 2024

Gets common validation code for tags, for both /ok-to-test and /test commands. Currently, for invalid tags in /test command, we aren't updating the PR description with details of the tag parsing failure. This PR fixes that, after finally bringing all the logic into Javascript needed to solve this.

/test sanity

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/9715326227
Commit: 260ec18
Cypress dashboard.
Tags: ``

Summary by CodeRabbit

  • Chores
    • Updated GitHub Actions workflow to trigger on 'release' and 'pg' branches for 'ok-to-test' labeled PRs.
    • Simplified tag parsing and validation logic in automation scripts.

Copy link
Contributor

coderabbitai bot commented Jun 17, 2024

Walkthrough

These changes enhance the GitHub Actions workflow for pull requests by allowing them to trigger on multiple branches and simplifying tag parsing logic. The updates include branch listening expansion, conditional job execution, tag retrieval adjustments, and improved error handling. This results in a more streamlined and robust workflow.

Changes

File Change Summary
.github/workflows/pr-automation.yml Updated branch listening, added job conditions, renamed steps, and streamlined tag handling processes.
.../workflows/scripts/test-tag-parser.js Restructured parseTags function with stricter validation and enhanced error handling.

Sequence Diagram(s)

sequenceDiagram
    participant Developer
    participant GitHub_Actions
    participant Workflow
    participant Job_ParseTags
    participant FinalOutput

    Developer->>GitHub_Actions: Create/Update PR
    GitHub_Actions->>Workflow: Trigger on branch release/pg with label 'ok-to-test'
    Workflow->>Job_ParseTags: Execute parseTags job if label is 'ok-to-test'
    Job_ParseTags->>Workflow: Parse tags from PR description
    Workflow->>FinalOutput: Output tags in the final step
Loading

Poem

🐇

A pull request lands with gentle grace,
On branches 'release' and 'pg', its place.
'Ok-to-test', we heed the call,
Parsing tags, we handle all.
Simplified steps, in code we trust,
Robust workflows, fair and just.
🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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

This PR has not seen activitiy for a while. It will be closed in 7 days unless further activity is detected.

@github-actions github-actions bot added the Stale label Jun 24, 2024
@sharat87 sharat87 added ok-to-test Required label for CI and removed Stale labels Jun 28, 2024
@sharat87 sharat87 changed the title Move more tag handling logic into Javascript ci: Move more tag handling logic into Javascript Jun 28, 2024
@github-actions github-actions bot added skip-changelog Adding this label to a PR prevents it from being listed in the changelog CI labels Jun 28, 2024
@sharat87 sharat87 marked this pull request as ready for review June 28, 2024 11:49
Copy link
Contributor

@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

Outside diff range and nitpick comments (1)
.github/workflows/scripts/test-tag-parser.js (1)

Line range hint 23-81: Review of parseTags Function

  • Regex Usage: The use of regex for matching tags is effective. However, consider adding comments to explain complex regex patterns for maintainability.
  • Error Handling: The function throws errors for unknown tags and when no tags are found, which is good for ensuring data integrity.
  • Potential Improvement: The loops and conditions could be refactored into smaller, more testable functions to improve readability and maintainability.
+ // Refactor suggestion to improve readability
+ function validateTag(part, allTags) {
+   if (!allTags.includes(part)) {
+     throw new Error("Unknown tag: " + part);
+   }
+ }
+ // Use the new function in the loop
+ for (const part of parts) {
+   validateTag(part, allTags);
+ }
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b692083 and 260ec18.

Files selected for processing (2)
  • .github/workflows/pr-automation.yml (3 hunks)
  • .github/workflows/scripts/test-tag-parser.js (2 hunks)
Additional comments not posted (3)
.github/workflows/scripts/test-tag-parser.js (1)

1-20: Review of Main Module Export Function

  • Error Handling: The use of try-catch blocks for error handling is appropriate here, ensuring that any parsing errors are caught and handled gracefully. However, the error message could be more descriptive about what went wrong.
  • Output Settings: The function sets outputs for both success and failure cases, which is good for clarity in CI logs.
  • Comment on Line 19: The comment about removing code in a separate PR is a good practice to keep changes focused and manageable.
.github/workflows/pr-automation.yml (2)

5-7: Review of Trigger Branches in on Section

  • Branches List: The addition of the 'pg' branch alongside 'release' allows for broader trigger coverage, aligning with the PR's intent to enhance CI operations across more branches.

14-14: Review of Steps in parse-tags Job

  • Conditional Execution: The condition to only run the job if the 'ok-to-test' label is present is a good security measure to prevent unauthorized CI runs.
  • Step Renaming: Renaming the step to 'Read tags from PR description' improves clarity on what the step does.
  • Matrix Configuration: The dynamic configuration of the matrix based on the presence of '@tag.All' is a smart use of CI resources, scaling the test environment based on needs.
  • Final Output: The use of dynamic tags in the final output step ensures that the workflow is responsive to the actual tags parsed, enhancing the accuracy of the CI process.

Also applies to: 32-32, 46-46, 62-62

@sharat87 sharat87 added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Jun 28, 2024
@sharat87 sharat87 changed the title ci: Move more tag handling logic into Javascript ci: Fix Cypress test fail not reported for /test command Jun 28, 2024
@sharat87 sharat87 added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Jun 28, 2024
@sharat87 sharat87 merged commit 5eada0a into release Jul 1, 2024
112 of 140 checks passed
@sharat87 sharat87 deleted the ci/tag-logic-js branch July 1, 2024 18:02
Shivam-z pushed a commit to Shivam-z/appsmith that referenced this pull request Jul 10, 2024
…rg#34278)

Gets common validation code for tags, for both `/ok-to-test` and `/test`
commands. Currently, for invalid tags in `/test` command, we aren't
updating the PR description with details of the tag parsing failure.
This PR fixes that, after finally bringing all the logic into Javascript
needed to solve this.

**/test sanity**



<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/9715326227>
> Commit: 260ec18
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9715326227&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: ``

<!-- end of auto-generated comment: Cypress test results  -->






<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Chores**
- Updated GitHub Actions workflow to trigger on 'release' and 'pg'
branches for 'ok-to-test' labeled PRs.
  - Simplified tag parsing and validation logic in automation scripts.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants