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

chore: Updated error handling #36288

Merged
merged 2 commits into from
Sep 12, 2024
Merged

chore: Updated error handling #36288

merged 2 commits into from
Sep 12, 2024

Conversation

sagar-qa007
Copy link
Contributor

@sagar-qa007 sagar-qa007 commented Sep 12, 2024

Description

Added extra checks for better reporting

Fixes #Issue Number
or
Fixes Issue URL

Warning

If no issue exists, please create an issue first, and check with the maintainers if the issue is valid.

Automation

/ok-to-test tags="@tag.ImportExport"

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/10831607193
Commit: 2a5049d
Cypress dashboard.
Tags: @tag.ImportExport
Spec:


Thu, 12 Sep 2024 13:31:10 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Enhanced CI workflow to provide clearer test results through improved commenting on pull requests based on test outcomes.
    • Introduced a failure flag mechanism to explicitly record test execution status.
  • Bug Fixes

    • Improved reliability of CI process by ensuring important logs and results are preserved and uploaded even on test failures.

Copy link
Contributor

coderabbitai bot commented Sep 12, 2024

Walkthrough

The changes in this pull request improve the CI/CD workflow by enhancing the management of test results. A new mechanism for recording test statuses has been implemented through the introduction of a failure flag file. This facilitates clearer communication of test outcomes in pull requests. Additionally, the logic for evaluating test results has been centralized, ensuring that comments accurately reflect the actual status of the CI tests.

Changes

File Path Change Summary
.github/workflows/build-client-server-count.yml Introduced ci_test_failed environment variable to manage CI test results and update PR comments accordingly.
.github/workflows/ci-test-limited-with-count.yml Added ci_test_status.txt for recording test outcomes and modified step conditions to ensure logs are preserved.

Possibly related PRs

  • chore: Return failure results #36233: This PR modifies the .github/workflows/ci-test-limited-with-count.yml file to include a conditional check for test failures, which directly relates to the changes made in the main PR that also involves the same workflow file and enhances CI test result handling.

Suggested labels

Bug, Needs Triaging

In the realm of code where tests do play,
A flag was born to light the way.
With statuses clear, our PRs will sing,
Of successes and failures, the truth they bring.
Logs preserved, no data lost,
In this CI journey, we count the cost.


Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ca43f51 and 2a5049d.

Files selected for processing (1)
  • .github/workflows/build-client-server-count.yml (4 hunks)
Additional context used
actionlint
.github/workflows/build-client-server-count.yml

273-273: shellcheck reported issue in this script: SC2002:style:1:23: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead

(shellcheck)


273-273: shellcheck reported issue in this script: SC2086:info:2:44: Double quote to prevent globbing and word splitting

(shellcheck)


279-279: shellcheck reported issue in this script: SC2086:info:5:37: Double quote to prevent globbing and word splitting

(shellcheck)


279-279: shellcheck reported issue in this script: SC2086:info:8:38: Double quote to prevent globbing and word splitting

(shellcheck)


279-279: shellcheck reported issue in this script: SC2086:info:12:38: Double quote to prevent globbing and word splitting

(shellcheck)


432-432: shellcheck reported issue in this script: SC2002:style:1:23: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead

(shellcheck)


432-432: shellcheck reported issue in this script: SC2086:info:2:44: Double quote to prevent globbing and word splitting

(shellcheck)


438-438: shellcheck reported issue in this script: SC2086:info:5:37: Double quote to prevent globbing and word splitting

(shellcheck)


438-438: shellcheck reported issue in this script: SC2086:info:8:38: Double quote to prevent globbing and word splitting

(shellcheck)


438-438: shellcheck reported issue in this script: SC2086:info:12:38: Double quote to prevent globbing and word splitting

(shellcheck)

Additional comments not posted (5)
.github/workflows/build-client-server-count.yml (5)

264-269: Great job downloading the ci_test_status artifact! 👍

The code segment correctly downloads the ci_test_status artifact and saves it to the app/client directory. This will be useful for checking the CI test results in the subsequent steps.


275-276: Nicely done setting the summary_content environment variable! 🙌

The code segment correctly reads the content of app/client/cy-repeat-summary.txt file, replaces newline characters with spaces, and sets the content as an environment variable named summary_content. This will be useful for including the summary content in the PR comments.


295-307: Excellent work adding a comment on the PR with new CI failures! 🎉

The code segment correctly adds a comment on the PR when ci_test_failed is true and pr is not 0. The comment provides valuable information to the PR author, including:

  • Links to the workflow run and Cypress dashboard for easy access to the test results.
  • A list of new failures that need to be fixed before merging the PR.
  • A link to the list of identified flaky tests for reference.
  • A summary of the test results for a quick overview.

This will greatly help the PR author in identifying and fixing the new failures before merging the PR.


308-319: Great job adding a comment on the PR when all Cypress tests have passed! 🙌

The code segment correctly adds a comment on the PR when ci_test_failed is not true and pr is not 0. The comment provides valuable information to the PR author, including:

  • Links to the workflow run and Cypress dashboard for easy access to the test results.
  • A message indicating that all Cypress tests have passed, which is a great sign of a healthy PR.
  • A summary of the test results for a quick overview.

This will give the PR author confidence that their changes have not introduced any new failures and that the PR is ready to be merged.


277-292: The CI test result check step looks good, but let's consider refactoring to avoid duplication and improve shell script quality. 🤔

The step encapsulates the logic for checking the CI test results, which improves the clarity and maintainability of the workflow. Setting the ci_test_failed environment variable based on the file content is a clean approach to centralize the test result evaluation.

However, this code segment is a duplication of the one at line range 436-451, which violates the DRY (Don't Repeat Yourself) principle.

To adhere to the DRY principle, consider refactoring the duplicated code into a reusable action or job that can be called from both the ci-test-limited-result and ci-test-limited-result-existing jobs. This will make the workflow more maintainable and less error-prone.

Additionally, to prevent globbing and word splitting issues in the shell script, it's a good practice to double-quote variables. Apply this diff to fix the issues:

-if grep -q "ci_test_failed=true" app/client/ci_test_status.txt; then
+if grep -q "ci_test_failed=true" "app/client/ci_test_status.txt"; then
   echo "Tests failed. Please review the test results."
-  echo "ci_test_failed=true" >> $GITHUB_ENV
+  echo "ci_test_failed=true" >> "$GITHUB_ENV"
 else
   echo "Tests passed."  
-  echo "ci_test_failed=false" >> $GITHUB_ENV
+  echo "ci_test_failed=false" >> "$GITHUB_ENV"
 fi
else
 echo "ci_test_status.txt file not found."
- echo "ci_test_failed=unknown" >> $GITHUB_ENV 
+ echo "ci_test_failed=unknown" >> "$GITHUB_ENV"
fi
Tools
actionlint

279-279: shellcheck reported issue in this script: SC2086:info:5:37: Double quote to prevent globbing and word splitting

(shellcheck)


279-279: shellcheck reported issue in this script: SC2086:info:8:38: Double quote to prevent globbing and word splitting

(shellcheck)


279-279: shellcheck reported issue in this script: SC2086:info:12:38: Double quote to prevent globbing and word splitting

(shellcheck)


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 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 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.

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
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: 2

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7ba06c8 and ca43f51.

Files selected for processing (2)
  • .github/workflows/build-client-server-count.yml (4 hunks)
  • .github/workflows/ci-test-limited-with-count.yml (5 hunks)
Additional context used
actionlint
.github/workflows/ci-test-limited-with-count.yml

404-404: shellcheck reported issue in this script: SC2069:warning:2:22: To redirect stdout+stderr, 2>&1 must be last (or use '{ cmd > file; } 2>&1' to clarify)

(shellcheck)

.github/workflows/build-client-server-count.yml

273-273: shellcheck reported issue in this script: SC2002:style:1:23: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead

(shellcheck)


273-273: shellcheck reported issue in this script: SC2086:info:2:44: Double quote to prevent globbing and word splitting

(shellcheck)


279-279: shellcheck reported issue in this script: SC2086:info:5:37: Double quote to prevent globbing and word splitting

(shellcheck)


279-279: shellcheck reported issue in this script: SC2086:info:8:38: Double quote to prevent globbing and word splitting

(shellcheck)


279-279: shellcheck reported issue in this script: SC2086:info:12:38: Double quote to prevent globbing and word splitting

(shellcheck)


432-432: shellcheck reported issue in this script: SC2002:style:1:23: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead

(shellcheck)


432-432: shellcheck reported issue in this script: SC2086:info:2:44: Double quote to prevent globbing and word splitting

(shellcheck)


438-438: shellcheck reported issue in this script: SC2086:info:5:37: Double quote to prevent globbing and word splitting

(shellcheck)


438-438: shellcheck reported issue in this script: SC2086:info:8:38: Double quote to prevent globbing and word splitting

(shellcheck)


438-438: shellcheck reported issue in this script: SC2086:info:12:38: Double quote to prevent globbing and word splitting

(shellcheck)

Additional comments not posted (6)
.github/workflows/ci-test-limited-with-count.yml (4)

353-363: Great job on enhancing the test result handling!

I really like how you've introduced a dedicated file to store the test status. This improves the clarity and makes it easier to determine the outcome of the tests.

The logic for checking the presence of "Total Failed: 0" in the summary file and setting the appropriate status is spot on. The code is well-structured, uses meaningful variable names, and includes helpful comments.

Keep up the excellent work!


365-365: Excellent addition for managing the cypress log files!

Trimming the number of log files is a great practice to prevent the logs from consuming too much disk space over time. By keeping only the last 10 files, you strike a good balance between retaining enough history for debugging purposes and avoiding unnecessary clutter.

The find command with the appropriate options is an efficient way to locate and delete the older log files. Well done!


377-383: Uploading the test status file as an artifact is a great idea!

By uploading the ci_test_status.txt file as an artifact, you make it accessible to other jobs or steps in the workflow. This allows them to make decisions or perform actions based on the test outcome.

Using the actions/upload-artifact@v4 action is the recommended approach for uploading artifacts in GitHub Actions. It's reliable and easy to use.

Overwriting the artifact with the same name ensures that the latest status is always available, which is exactly what we want.

Nicely done!


386-386: Uploading the cypress console logs as an artifact is a valuable addition!

Having access to the cypress console logs is crucial for debugging and investigating test failures. By uploading them as an artifact, you make it easy for developers to access and analyze the logs when needed.

Using the actions/upload-artifact@v4 action is the recommended approach for uploading artifacts in GitHub Actions. It's reliable and straightforward to use.

Overwriting the artifact with the same name ensures that the latest logs are always available, which is helpful for troubleshooting.

The if: always() condition is a smart choice. It guarantees that the logs are uploaded regardless of the success or failure of previous steps. This is especially important when tests fail, as the logs can provide valuable insights into what went wrong.

Great work on this addition!

.github/workflows/build-client-server-count.yml (2)

264-269: Great job adding the step to download the ci_test_status artifact! 👍

Downloading this artifact is essential for evaluating the CI test results in the following steps. Storing it in the app/client directory is a sensible choice.


277-292: Excellent work encapsulating the CI test result check in a separate step! 🙌

Reading the ci_test_status.txt file and setting the ci_test_failed environment variable based on its content is a clean and maintainable approach. It centralizes the test result evaluation and allows the subsequent steps to rely on the ci_test_failed variable.

Handling the case when the file is not found by setting ci_test_failed to "unknown" is a nice touch to ensure the workflow can proceed gracefully.

Tools
actionlint

279-279: shellcheck reported issue in this script: SC2086:info:5:37: Double quote to prevent globbing and word splitting

(shellcheck)


279-279: shellcheck reported issue in this script: SC2086:info:8:38: Double quote to prevent globbing and word splitting

(shellcheck)


279-279: shellcheck reported issue in this script: SC2086:info:12:38: Double quote to prevent globbing and word splitting

(shellcheck)

@sagar-qa007 sagar-qa007 added the ok-to-test Required label for CI label Sep 12, 2024
@ashit-rath ashit-rath changed the title Updated error handling chore: Updated error handling Sep 12, 2024
@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Sep 12, 2024
@sagar-qa007 sagar-qa007 merged commit 71b44a1 into release Sep 12, 2024
51 checks passed
@sagar-qa007 sagar-qa007 deleted the chore/errorhandling branch September 12, 2024 15:29
Shivam-z pushed a commit to Shivam-z/appsmith that referenced this pull request Sep 26, 2024
## Description
Added extra checks for better reporting


Fixes #`Issue Number`  
_or_  
Fixes `Issue URL`
> [!WARNING]  
> _If no issue exists, please create an issue first, and check with the
maintainers if the issue is valid._

## Automation

/ok-to-test tags="@tag.ImportExport"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/10831607193>
> Commit: 2a5049d
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=10831607193&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.ImportExport`
> Spec:
> <hr>Thu, 12 Sep 2024 13:31:10 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [x] No


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

- **New Features**
- Enhanced CI workflow to provide clearer test results through improved
commenting on pull requests based on test outcomes.
- Introduced a failure flag mechanism to explicitly record test
execution status.

- **Bug Fixes**
- Improved reliability of CI process by ensuring important logs and
results are preserved and uploaded even on test failures.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@coderabbitai coderabbitai bot mentioned this pull request Oct 11, 2024
2 tasks
@coderabbitai coderabbitai bot mentioned this pull request Nov 26, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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