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

Feature ETP-893: Update HTML Report Publishing in Pipelines #562

Merged
merged 3 commits into from
Dec 18, 2024

Conversation

valeg-etendo
Copy link
Collaborator

No description provided.

Copy link

Passed

Analysis Details

0 Issues

  • Bug 0 Bugs
  • Vulnerability 0 Vulnerabilities
  • Code Smell 0 Code Smells

Coverage and Duplications

  • Coverage No coverage information (0.00% Estimated after merge)
  • Duplications No duplication information (13.10% Estimated after merge)

Project ID: etendosoftware_etendo_core_AYOKvQCAuJ79WHyLB97g

View in SonarQube

Copy link
Collaborator

Choose a reason for hiding this comment

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

GPT Review for Jenkinsfile

Review

  • Estimated effort to review [1-5]:
    3, because the changes involve multiple sections of the Jenkinsfile, adding conditional checks and modifying the test stages. The complexity is moderate, requiring a careful review of the logic and structure.
  • Score: 85

Code feedback

  • File:
    pipelines/unittests/Jenkinsfile
  • Language:
    groovy
  • Suggestion:
    Consider using a constant or a variable for the report directory path to avoid repetition and potential errors if the path needs to be updated in the future. This will improve maintainability and reduce the risk of inconsistencies. [medium]
  • Label:
    maintainability
  • Existing code:
if (fileExists("build/reports/tests/test/")) {
  publishHTML([
    allowMissing: true,
    alwaysLinkToLastBuild: false,
    keepAll: true,
    reportDir: 'build/reports/tests/test',
    reportFiles: '*.html',
    reportName: 'WEBSERVICES TESTS REPORT',
    reportTitles: ''
  ])
  sh "rm -rf build/reports/tests/test"
} else {
  echo "Report directory of Webservices tests does not exist. Skipping HTML report publishing."
}
  • Improved code:
def reportDirPath = "build/reports/tests/test"
if (fileExists(reportDirPath)) {
  publishHTML([
    allowMissing: true,
    alwaysLinkToLastBuild: false,
    keepAll: true,
    reportDir: reportDirPath,
    reportFiles: '*.html',
    reportName: 'WEBSERVICES TESTS REPORT',
    reportTitles: ''
  ])
  sh "rm -rf ${reportDirPath}"
} else {
  echo "Report directory of Webservices tests does not exist. Skipping HTML report publishing."
}
  • File:
    pipelines/unittests/Jenkinsfile
  • Language:
    groovy
  • Suggestion:
    Ensure that the sh "./gradlew --stop" command is necessary in all places it is used. If it is not required after every test suite, consider removing it to optimize the build process. [medium]
  • Label:
    performance
  • Existing code:
sh "./gradlew --stop"
  • Improved code:
// Evaluate if this command is necessary in all instances
sh "./gradlew --stop"

Copy link
Collaborator

Choose a reason for hiding this comment

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

GPT Review for JenkinsfileOracle

Review

  • Estimated effort to review [1-5]:
    3, because the changes involve multiple sections of the Jenkinsfile, including error handling and report generation logic, which require careful review to ensure correctness and maintainability.
  • Score: 85

Code feedback

  • File:
    pipelines/unittests/JenkinsfileOracle
  • Language:
    groovy
  • Suggestion:
    Consider using a constant or a configuration parameter for the report directory paths to avoid hardcoding them multiple times. This will improve maintainability and reduce the risk of errors if the paths need to be updated in the future. [medium]
  • Label:
    maintainability
  • Existing code:
if (fileExists('build/reports/tests/test/')) {
    publishHTML([
        allowMissing: true,
        alwaysLinkToLastBuild: false,
        keepAll: true,
        reportDir: 'build/reports/tests/test',
        reportFiles: '*.html',
        reportName: 'STANDALONE TESTS REPORT',
        reportTitles: ''
    ])
    sh "rm -rf build/reports/tests/test"
} else {
    echo "Report directory of Standalone tests does not exist. Skipping HTML report publishing."
}
  • Improved code:
def testReportDir = 'build/reports/tests/test/'

if (fileExists(testReportDir)) {
    publishHTML([
        allowMissing: true,
        alwaysLinkToLastBuild: false,
        keepAll: true,
        reportDir: testReportDir,
        reportFiles: '*.html',
        reportName: 'STANDALONE TESTS REPORT',
        reportTitles: ''
    ])
    sh "rm -rf ${testReportDir}"
} else {
    echo "Report directory of Standalone tests does not exist. Skipping HTML report publishing."
}
  • File:
    pipelines/unittests/JenkinsfileOracle
  • Language:
    groovy
  • Suggestion:
    Ensure that the sh "rm -rf ..." command is used cautiously, as it can delete files and directories recursively. Consider adding a confirmation step or logging the action before executing it to prevent accidental data loss. [important]
  • Label:
    safety
  • Existing code:
sh "rm -rf build/reports/tests/test"
  • Improved code:
echo "Cleaning up test report directory: build/reports/tests/test"
sh "rm -rf build/reports/tests/test"
  • File:
    pipelines/unittests/JenkinsfileOracle
  • Language:
    groovy
  • Suggestion:
    The finally block is used to ensure that certain actions are always executed, regardless of whether an exception is thrown. Consider adding logging at the start and end of the finally block to improve traceability and debugging. [medium]
  • Label:
    best practice
  • Existing code:
} finally {
    if (fileExists('build/reports/tests/test/')) {
        publishHTML([
            allowMissing: true,
            alwaysLinkToLastBuild: false,
            keepAll: true,
            reportDir: 'build/reports/tests/test',
            reportFiles: '*.html',
            reportName: 'STANDALONE TESTS REPORT',
            reportTitles: ''
        ])
        sh "rm -rf build/reports/tests/test"
    } else {
        echo "Report directory of Standalone tests does not exist. Skipping HTML report publishing."
    }
}
  • Improved code:
} finally {
    echo "Entering finally block for test report handling."
    if (fileExists('build/reports/tests/test/')) {
        publishHTML([
            allowMissing: true,
            alwaysLinkToLastBuild: false,
            keepAll: true,
            reportDir: 'build/reports/tests/test',
            reportFiles: '*.html',
            reportName: 'STANDALONE TESTS REPORT',
            reportTitles: ''
        ])
        sh "rm -rf build/reports/tests/test"
    } else {
        echo "Report directory of Standalone tests does not exist. Skipping HTML report publishing."
    }
    echo "Exiting finally block for test report handling."
}

@valeg-etendo valeg-etendo merged commit 9ffb195 into develop Dec 18, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants