SeleniumHQ / selenium

A browser automation framework and ecosystem.
https://selenium.dev
Apache License 2.0
30.42k stars 8.15k forks source link

Notify nightly failures #14049

Closed diemol closed 4 months ago

diemol commented 4 months ago

User description

Thanks for contributing to Selenium! A PR well described will help maintainers to quickly review and merge it

Before submitting your PR, please check our contributing guidelines. Avoid large PRs, help reviewers by making them as simple and short as possible.

Description

Motivation and Context

Types of changes

Checklist


PR Type

enhancement, configuration changes


Description


Changes walkthrough 📝

Relevant files
Configuration changes
nightly.yml
Add failure handling and Slack notifications for nightly builds.

.github/workflows/nightly.yml
  • Added new jobs to handle failures for Ruby, Python, Java, .NET, Grid,
    and JavaScript.
  • Configured Slack notifications for each failure job.
  • Set environment variables for Slack notifications including
    SLACK_ICON_EMOJI, SLACK_COLOR, SLACK_CHANNEL, SLACK_USERNAME,
    SLACK_TITLE, MSG_MINIMAL, and SLACK_WEBHOOK.
  • +102/-4 

    💡 PR-Agent usage: Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    codiumai-pr-agent-pro[bot] commented 4 months ago

    PR Review 🔍

    ⏱️ Estimated effort to review [1-5] 2, because the changes are primarily additions of new jobs to an existing GitHub Actions workflow. Each job follows a similar pattern, which simplifies the review process. However, the reviewer needs to ensure that the conditions and environment variables are correctly set up for each job.
    🧪 Relevant tests No
    ⚡ Possible issues Possible Bug: The `SLACK_COLOR` environment variable uses `needs..status` which might not provide meaningful color codes for Slack. Typically, Slack expects specific color codes or names (e.g., 'danger', 'good', 'warning'), and it's unclear if the status outputs from GitHub Actions jobs align with these expectations.
    🔒 Security concerns No
    codiumai-pr-agent-pro[bot] commented 4 months ago

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Maintainability
    Use a reusable workflow or composite action to avoid duplicating Slack notification steps ___ **Use a reusable workflow or composite action to avoid duplicating the Slack notification
    steps across multiple failure jobs.** [.github/workflows/nightly.yml [48-58]](https://github.com/SeleniumHQ/selenium/pull/14049/files#diff-0d5658b415099a82c11c03a06ca4ec765b4003a1f4b2f3f1943980a882cf8aa6R48-R58) ```diff - name: Slack Notification - uses: rtCamp/action-slack-notify@v2 - env: - SLACK_ICON_EMOJI: ":rotating_light:" - SLACK_COLOR: ${{ needs.ruby.status }} - SLACK_CHANNEL: selenium-tlc - SLACK_USERNAME: GitHub Workflows - SLACK_TITLE: Nightly Ruby ${{ needs.ruby.result }} - MSG_MINIMAL: actions url - SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} + uses: ./.github/actions/slack-notify + with: + status: ${{ needs.ruby.status }} + result: ${{ needs.ruby.result }} ```
    Suggestion importance[1-10]: 8 Why: Using a reusable workflow or composite action for Slack notifications would significantly reduce redundancy and improve maintainability across multiple jobs.
    8
    Possible issue
    Ensure the SLACK_WEBHOOK environment variable is always set to avoid potential issues ___ **To avoid potential issues with missing secrets, ensure that the SLACK_WEBHOOK environment
    variable is always set by adding a default value or a check before using it.** [.github/workflows/nightly.yml [58]](https://github.com/SeleniumHQ/selenium/pull/14049/files#diff-0d5658b415099a82c11c03a06ca4ec765b4003a1f4b2f3f1943980a882cf8aa6R58-R58) ```diff -SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} +SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL || 'default_webhook_url' }} ```
    Suggestion importance[1-10]: 7 Why: Ensuring that the `SLACK_WEBHOOK` is always set can prevent failures due to missing configuration, which is crucial for the reliability of the notification system.
    7
    Debugging
    Log the failure reason to the console before sending the Slack notification ___ **Add a step to log the failure reason or error message to the console before sending the
    Slack notification for easier debugging.** [.github/workflows/nightly.yml [48-50]](https://github.com/SeleniumHQ/selenium/pull/14049/files#diff-0d5658b415099a82c11c03a06ca4ec765b4003a1f4b2f3f1943980a882cf8aa6R48-R50) ```diff +- name: Log Failure Reason + run: echo "Failure reason: ${{ needs.ruby.outputs.failure_reason }}" - name: Slack Notification uses: rtCamp/action-slack-notify@v2 ```
    Suggestion importance[1-10]: 7 Why: Logging the failure reason before sending a Slack notification would aid in debugging and provide immediate context, which is beneficial for quick issue resolution.
    7
    Enhancement
    Add job name or ID to the Slack notification title for better context ___ **Consider adding a step to include the job name or ID in the Slack notification message to
    provide more context about which job failed.** [.github/workflows/nightly.yml [56]](https://github.com/SeleniumHQ/selenium/pull/14049/files#diff-0d5658b415099a82c11c03a06ca4ec765b4003a1f4b2f3f1943980a882cf8aa6R56-R56) ```diff -SLACK_TITLE: Nightly Ruby ${{ needs.ruby.result }} +SLACK_TITLE: Nightly Ruby ${{ needs.ruby.result }} - Job ${{ github.job }} ```
    Suggestion importance[1-10]: 6 Why: Adding job name or ID to the Slack notification title would provide more context about the failure, enhancing the utility of the notification.
    6