From 30a3526b01fd0c1d4f85cb71ce4ad0979aaa19ae Mon Sep 17 00:00:00 2001 From: Srikanta Date: Tue, 7 Jan 2020 02:53:00 -0800 Subject: [PATCH 1/4] Enable build failure when code coverage is below threshold --- .../templates/jobs/archetype-sdk-client.yml | 38 ++++++++++++++++++- pom.client.xml | 29 ++++++++++++++ 2 files changed, 65 insertions(+), 2 deletions(-) diff --git a/eng/pipelines/templates/jobs/archetype-sdk-client.yml b/eng/pipelines/templates/jobs/archetype-sdk-client.yml index 595aea3352e9..714746c6cf82 100644 --- a/eng/pipelines/templates/jobs/archetype-sdk-client.yml +++ b/eng/pipelines/templates/jobs/archetype-sdk-client.yml @@ -2,7 +2,7 @@ parameters: ServiceDirectory: not-specified # Set a default that breaks in obvious ways. PreTestSteps: [] TestOptions: '$(DefaultOptions)' - TestGoals: test + TestGoals: verify TestMatrix: Linux - Java 8: OSName: 'Linux' @@ -329,7 +329,7 @@ jobs: jdkArchitectureOption: 'x64' publishJUnitResults: false goals: ${{ parameters.TestGoals }} - # we want to run this when TestFromSource isn't true (which covers normal running when it isn't set) + # we want to run this when TestFromSource isn't true (which covers normal running when it isn't set) # OR when ShouldRunSourceTests is true condition: and(succeeded(), or(ne(variables['TestFromSource'],'true'), eq(variables['ShouldRunSourceTests'],'true'))) @@ -338,3 +338,37 @@ jobs: inputs: mergeTestResults: true testRunTitle: $(RunTitle) + + # Generate JaCoCo code coverage report on Java 11, Linux builds if the build reason is not PR. + - task: Maven@3 + displayName: 'Generate aggregate code coverage report' + condition: and(eq(variables['OsName'], 'Linux'), eq(variables['JavaVersion'], '1.11'), ne(variables['Build.Reason'], 'PullRequest')) + inputs: + # Aggregate reports for non-PR builds will use pom.client.xml and include non-shipping modules + mavenPomFile: pom.client.xml + options: '$(DefaultOptions) -Dinclude-non-shipping-modules -Dgpg.skip -Dmaven.javadoc.skip=true -Dcheckstyle.skip=true -Dspotbugs.skip=true' + mavenOptions: '-Xmx3072m $(LoggingOptions)' + javaHomeOption: 'JDKVersion' + jdkVersionOption: $(JavaVersion) + jdkArchitectureOption: 'x64' + publishJUnitResults: false + goals: 'verify' + + # Azure DevOps only seems to respect the last code coverage result published, so only do this for Linux + Java LTS. + # Code coverage reporting is setup only for Track 2 modules. + - task: PublishCodeCoverageResults@1 + condition: and(eq(variables['OsName'], 'Linux'), eq(variables['JavaVersion'], '1.11'), ne(variables['Build.Reason'], 'PullRequest')) + inputs: + codeCoverageTool: JaCoCo + summaryFileLocation: eng/jacoco-test-coverage/target/site/test-coverage/jacoco.xml + reportDirectory: eng/jacoco-test-coverage/target/site/test-coverage/ + failIfCoverageEmpty: true + + # Publish code coverage to an artifact so it can be uploaded to the Maven site. + # Do this for track 2 modules only. Code coverage from previous step is only published for Linux + Java LTS. + - task: PublishPipelineArtifact@0 + displayName: 'Publish coverage artifact' + condition: and(eq(variables['OsName'], 'Linux'), eq(variables['JavaVersion'], '1.11'), ne(variables['Build.Reason'], 'PullRequest')) + inputs: + artifactName: coverage + targetPath: eng/jacoco-test-coverage/target/site/ diff --git a/pom.client.xml b/pom.client.xml index fb966de07912..cf24448bcf3e 100644 --- a/pom.client.xml +++ b/pom.client.xml @@ -333,6 +333,35 @@ ${project.reporting.outputDirectory}/test-coverage + + check + + check + + + + + BUNDLE + + + LINE + COVEREDRATIO + 0.18 + + + BRANCH + COVEREDRATIO + 0.09 + + + + + + + + + + From 2713bf95589a5f486dfa22cecb704be31693283b Mon Sep 17 00:00:00 2001 From: Srikanta Date: Tue, 7 Jan 2020 02:57:20 -0800 Subject: [PATCH 2/4] Remove comment --- pom.client.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pom.client.xml b/pom.client.xml index cf24448bcf3e..405ad68797d3 100644 --- a/pom.client.xml +++ b/pom.client.xml @@ -354,10 +354,6 @@ 0.09 - - - - From df95a45d7ca40cd745f0fc5a7397ebbc787bb31f Mon Sep 17 00:00:00 2001 From: Srikanta Date: Tue, 7 Jan 2020 11:21:25 -0800 Subject: [PATCH 3/4] Install reporting tools for verify goal --- eng/pipelines/templates/jobs/archetype-sdk-client.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/eng/pipelines/templates/jobs/archetype-sdk-client.yml b/eng/pipelines/templates/jobs/archetype-sdk-client.yml index 714746c6cf82..173f938eccef 100644 --- a/eng/pipelines/templates/jobs/archetype-sdk-client.yml +++ b/eng/pipelines/templates/jobs/archetype-sdk-client.yml @@ -274,6 +274,11 @@ jobs: - template: ../steps/cache-maven-repository.yml + - template: ../steps/install-reporting-tools.yml + parameters: + Options: --batch-mode + MavenOptions: $(MemoryOptions) $(LoggingOptions) + - task: Maven@3 displayName: 'Start Jetty' condition: ne(variables['SdkType'], 'client') From 444c9166a08f2748b415be9c6a0c7bfe6e3f9b84 Mon Sep 17 00:00:00 2001 From: Srikanta Date: Tue, 7 Jan 2020 18:31:35 -0800 Subject: [PATCH 4/4] Configurable coverage threshold --- pom.client.xml | 6 ++++-- sdk/storage/azure-storage-blob-cryptography/pom.xml | 5 +++++ sdk/storage/azure-storage-common/pom.xml | 5 +++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/pom.client.xml b/pom.client.xml index 405ad68797d3..438c163f4e4d 100644 --- a/pom.client.xml +++ b/pom.client.xml @@ -104,6 +104,8 @@ https://azuresdkartifacts.blob.core.windows.net/azure-sdk-for-java https://github.com/Azure/azure-sdk-for-java/issues azure-client-sdk-parent + 0.40 + 0.30 @@ -346,12 +348,12 @@ LINE COVEREDRATIO - 0.18 + ${jacoco.min.linecoverage} BRANCH COVEREDRATIO - 0.09 + ${jacoco.min.branchcoverage} diff --git a/sdk/storage/azure-storage-blob-cryptography/pom.xml b/sdk/storage/azure-storage-blob-cryptography/pom.xml index 99992896009c..8d4cde29759b 100644 --- a/sdk/storage/azure-storage-blob-cryptography/pom.xml +++ b/sdk/storage/azure-storage-blob-cryptography/pom.xml @@ -32,6 +32,11 @@ HEAD + + 0.18 + 0.09 + + com.azure diff --git a/sdk/storage/azure-storage-common/pom.xml b/sdk/storage/azure-storage-common/pom.xml index fd21c5b3c90d..5f93fb133ba5 100644 --- a/sdk/storage/azure-storage-common/pom.xml +++ b/sdk/storage/azure-storage-common/pom.xml @@ -32,6 +32,11 @@ HEAD + + 0.20 + 0.18 + + com.azure