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

Update ghpr_mysql_test.groovy #3026

Merged
merged 2 commits into from
Jul 12, 2024
Merged

Conversation

lance6716
Copy link
Contributor

@lance6716 lance6716 commented Jul 11, 2024

PR Type

enhancement


Description

  • Enhanced the Jenkins pipeline script to archive artifacts upon test failure.
  • Added an unsuccessful post condition to ensure tidb-test/mysql_test/mysql-test.out is archived with fingerprinting.

Changes walkthrough 📝

Relevant files
Enhancement
ghpr_mysql_test.groovy
Add artifact archiving on test failure                                     

pipelines/PingCAP-QE/tidb-test/latest/ghpr_mysql_test.groovy

  • Added unsuccessful post condition to archive artifacts.
  • Archives tidb-test/mysql_test/mysql-test.out with fingerprinting.
  • +3/-0     

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

    @ti-chi-bot ti-chi-bot bot requested review from purelind and wuhuizuo July 11, 2024 10:41
    Copy link

    ti-chi-bot bot commented Jul 11, 2024

    I have already done a preliminary review for you, and I hope to help you do a better job.

    Based on the diff, it seems that the key change in this pull request is the addition of an archiveArtifacts step in case the test pipeline is unsuccessful. This step archives the mysql-test.out file.

    One potential problem is that the archiveArtifacts step may not be necessary or may not be the best solution for archiving test artifacts. It's important to consider if this step is needed and if there are better alternatives, such as using an artifact repository like Nexus or Artifactory.

    If the archiveArtifacts step is deemed necessary, then one suggestion for improvement would be to specify a more specific path for archiving the artifacts, rather than just the mysql-test.out file. This can help ensure that all relevant test artifacts are captured.

    Overall, it's important to carefully consider the necessity and implementation of the archiveArtifacts step in this pull request.

    @qodo-merge-pro qodo-merge-pro bot added the enhancement New feature or request label Jul 11, 2024
    @ti-chi-bot ti-chi-bot bot added the size/XS label Jul 11, 2024
    Copy link
    Contributor

    PR Reviewer Guide 🔍

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Key issues to review

    Enhancement Validation
    Ensure that the added 'unsuccessful' post condition for archiving artifacts is correctly implemented and triggers as expected on test failures.

    Copy link
    Contributor

    qodo-merge-pro bot commented Jul 11, 2024

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Best practice
    ✅ Add a file existence check before archiving artifacts to prevent errors

    Consider adding a condition to check if the file
    "tidb-test/mysql_test/mysql-test.out" exists before attempting to archive it. This
    can prevent potential errors if the file is not generated due to test failures or
    other reasons.

    pipelines/PingCAP-QE/tidb-test/latest/ghpr_mysql_test.groovy [116-118]

     unsuccessful {
    -    archiveArtifacts artifacts: "tidb-test/mysql_test/mysql-test.out", fingerprint: true 
    +    if (fileExists('tidb-test/mysql_test/mysql-test.out')) {
    +        archiveArtifacts artifacts: "tidb-test/mysql_test/mysql-test.out", fingerprint: true 
    +    }
     }
     

    [Suggestion has been applied]

    Suggestion importance[1-10]: 9

    Why: The suggestion to add a file existence check before archiving artifacts is a good practice to prevent potential errors if the file is not generated. This improves the robustness of the pipeline.

    9

    Comment on lines 116 to 118
    unsuccessful {
    archiveArtifacts artifacts: "tidb-test/mysql_test/mysql-test.out", fingerprint: true
    }
    Copy link
    Contributor

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Suggestion: Add a file existence check before archiving artifacts to prevent errors [Best practice, importance: 9]

    Suggested change
    unsuccessful {
    archiveArtifacts artifacts: "tidb-test/mysql_test/mysql-test.out", fingerprint: true
    }
    unsuccessful {
    if (fileExists('tidb-test/mysql_test/mysql-test.out')) {
    archiveArtifacts artifacts: "tidb-test/mysql_test/mysql-test.out", fingerprint: true
    }
    }

    Co-authored-by: Purelind <purelind@users.noreply.github.com>
    Copy link

    ti-chi-bot bot commented Jul 11, 2024

    I have already done a preliminary review for you, and I hope to help you do a better job.

    Based on the pull request description and diff, the key changes are:

    • Added an unsuccessful post condition to archive artifacts upon test failure.
    • Archives tidb-test/mysql_test/mysql-test.out with fingerprinting.

    Overall, the changes seem reasonable and will enhance the Jenkins pipeline script. However, there are a few potential problems to consider:

    • It's not clear what happens if the tidb-test/mysql_test/mysql-test.out file is not present. In this case, the archiveArtifacts step may fail, causing the pipeline to fail.
    • The allowEmptyArchive option is set to true, which means that the archive will be created even if the file is not found. This may create empty archives that could potentially clutter the workspace or artifact repository.

    To address these potential issues, I suggest the following fixes:

    • Add a check to ensure that the tidb-test/mysql_test/mysql-test.out file exists before attempting to archive it. This can be done using a fileExists step.
    • Consider setting allowEmptyArchive to false, to prevent empty archives from being created.

    Copy link
    Collaborator

    @purelind purelind left a comment

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    /lgtm

    Copy link

    ti-chi-bot bot commented Jul 12, 2024

    [APPROVALNOTIFIER] This PR is APPROVED

    This pull-request has been approved by: purelind

    The full list of commands accepted by this bot can be found here.

    The pull request process is described here

    Needs approval from an approver in each of these files:

    Approvers can indicate their approval by writing /approve in a comment
    Approvers can cancel approval by writing /approve cancel in a comment

    @ti-chi-bot ti-chi-bot bot added the lgtm label Jul 12, 2024
    Copy link

    ti-chi-bot bot commented Jul 12, 2024

    [LGTM Timeline notifier]

    Timeline:

    • 2024-07-12 02:10:34.934269589 +0000 UTC m=+582732.169503695: ☑️ agreed by purelind.

    @ti-chi-bot ti-chi-bot bot added the approved label Jul 12, 2024
    @ti-chi-bot ti-chi-bot bot merged commit e2f7aa6 into PingCAP-QE:main Jul 12, 2024
    2 checks passed
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    Status: Done
    Development

    Successfully merging this pull request may close these issues.

    2 participants