Repository: aurora Updated Branches: refs/heads/master 4137dd246 -> 0606369e2
Update to gradle 4.2 Reviewed at https://reviews.apache.org/r/62517/ Project: http://git-wip-us.apache.org/repos/asf/aurora/repo Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/0606369e Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/0606369e Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/0606369e Branch: refs/heads/master Commit: 0606369e2b57a5d58123c31c7d701047517a9528 Parents: 4137dd2 Author: Bill Farner <[email protected]> Authored: Sat Sep 23 08:05:08 2017 -0700 Committer: Bill Farner <[email protected]> Committed: Sat Sep 23 08:05:28 2017 -0700 ---------------------------------------------------------------------- build.gradle | 51 +++++--- buildSrc/gradle.properties | 2 +- .../aurora/build/CoverageReportCheck.groovy | 131 ------------------- gradle/wrapper/gradle-wrapper.properties | 2 +- 4 files changed, 32 insertions(+), 154 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/aurora/blob/0606369e/build.gradle ---------------------------------------------------------------------- diff --git a/build.gradle b/build.gradle index 0467338..851bab5 100644 --- a/build.gradle +++ b/build.gradle @@ -11,9 +11,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import org.apache.aurora.build.CoverageReportCheck -import org.gradle.api.JavaVersion - plugins { id 'com.eriwen.gradle.js' version '1.12.1' id 'com.github.ben-manes.versions' version '0.11.3' @@ -237,20 +234,22 @@ project(':api') { apply plugin: org.apache.aurora.build.ThriftPlugin apply plugin: org.apache.aurora.build.ThriftEntitiesPlugin - task checkPython << { - def python27Executable = ['python2.7', 'python'].find { python -> - try { - def check = "import sys; sys.exit(0 if sys.version_info >= (2,7) and sys.version_info < (3,) else 1)" - return [python, "-c", check].execute().waitFor() == 0 - } catch (IOException e) { - return false + task checkPython { + doLast { + def python27Executable = ['python2.7', 'python'].find { python -> + try { + def check = "import sys; sys.exit(0 if sys.version_info >= (2,7) and sys.version_info < (3,) else 1)" + return [python, "-c", check].execute().waitFor() == 0 + } catch (IOException e) { + return false + } } - } - if (python27Executable == null) { - throw new GradleException('Build requires Python 2.7.') - } else { - thriftEntities.python = python27Executable + if (python27Executable == null) { + throw new GradleException('Build requires Python 2.7.') + } else { + thriftEntities.python = python27Executable + } } } generateThriftEntitiesJava.dependsOn checkPython @@ -621,13 +620,23 @@ jacocoTestReport { } test.finalizedBy jacocoTestReport -task analyzeReport(type: CoverageReportCheck) { - coverageReportFile = "$reportPath/jacocoTestReport.xml" - minInstructionCoverage = 0.89 - minBranchCoverage = 0.835 - legacyClassesWithoutCoverage = file('config/legacy_untested_classes.txt').readLines() +jacocoTestCoverageVerification { + violationRules { + rule { + limit { + counter = 'INSTRUCTION' + minimum = 0.87 + } + } + rule { + limit { + counter = 'BRANCH' + minimum = 0.79 + } + } + } } -jacocoTestReport.finalizedBy analyzeReport +jacocoTestReport.finalizedBy jacocoTestCoverageVerification def jmhHumanOutputPath = "$buildDir/reports/jmh/human.txt" jmh { http://git-wip-us.apache.org/repos/asf/aurora/blob/0606369e/buildSrc/gradle.properties ---------------------------------------------------------------------- diff --git a/buildSrc/gradle.properties b/buildSrc/gradle.properties index a7214d3..0c33f29 100644 --- a/buildSrc/gradle.properties +++ b/buildSrc/gradle.properties @@ -1,3 +1,3 @@ # When upgrading gradle versions, be sure to update the relevant files in the aurora-packaging # repo as well. See https://reviews.apache.org/r/39113/ for an example. -GRADLE_VERSION = 3.1 +GRADLE_VERSION = 4.2 http://git-wip-us.apache.org/repos/asf/aurora/blob/0606369e/buildSrc/src/main/groovy/org/apache/aurora/build/CoverageReportCheck.groovy ---------------------------------------------------------------------- diff --git a/buildSrc/src/main/groovy/org/apache/aurora/build/CoverageReportCheck.groovy b/buildSrc/src/main/groovy/org/apache/aurora/build/CoverageReportCheck.groovy deleted file mode 100644 index da91f39..0000000 --- a/buildSrc/src/main/groovy/org/apache/aurora/build/CoverageReportCheck.groovy +++ /dev/null @@ -1,131 +0,0 @@ -/** - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.aurora.build - -import org.gradle.api.DefaultTask -import org.gradle.api.GradleException -import org.gradle.api.tasks.TaskAction - -/** - * A task that analyzes the XML coverage report from JaCoCo and fails the build if code coverage - * metrics are not met. - */ -class CoverageReportCheck extends DefaultTask { - - // The XML coverage report file. - def coverageReportFile - - // Minimum ratio of instructions covered, [0, 1.0]. - def minInstructionCoverage - - // Minimum ratio of branches covered, [0, 1.0]. - def minBranchCoverage - - // Classes that may be allowed to have zero test coverage. - def legacyClassesWithoutCoverage - - // The amount of wiggle room when requiring min coverage be raised. - def epsilon = 0.005 - - private def computeCoverage(counterNodes, type) { - def node = counterNodes.find { it.@type == type } - def missed = [email protected]() - def covered = [email protected]() - return ((double) covered) / (missed + covered) - } - - def checkThresholds(coverage, minCoverage, type) { - if (coverage < minCoverage) { - return "$type coverage is $coverage, but must be greater than $minCoverage" - } else { - def floored = Math.floor(coverage * 100) / 100 - if (floored > (minCoverage + epsilon)) { - println("$type coverage of $floored exceeds min instruction coverage of $minCoverage" - + " by more than $epsilon, please raise the threshold!") - } else { - println("$type coverage of $coverage exceeds minimum coverage of $minCoverage.") - } - } - } - - def checkGlobalCoverage(coverageCounts) { - def coverageErrors = [ - [computeCoverage(coverageCounts, 'INSTRUCTION'), minInstructionCoverage, 'Instruction'], - [computeCoverage(coverageCounts, 'BRANCH'), minBranchCoverage, 'Branch'] - ].collect() { - return checkThresholds(*it) - }.findAll() - - if (!coverageErrors.isEmpty()) { - // We print here and don't fail the build since this metric has proven to be flaky, - // and different JVMs can produce different results. - println(coverageErrors.join('\n')) - } - } - - def checkClassCoverage(coverageReport) { - def coverageErrors = coverageReport.package.class.collect { cls -> - def matchedMethods = cls.method - // Ignore static code, it should not count as test coverage. - .findAll({ m -> m.@name != '<clinit>' }) - // Ignore classes that only have a constructor. This will avoid tripping for things like - // constant-only utility classes, and 'value' classes like TypeLiteral and Clazz. - .findAll({ m -> m.@name != '<init>' }) - - // Ignore enums that contain only default methods. - if (matchedMethods.collect { m -> m.@name } == ['values', 'valueOf']) { - return null - } - - if (matchedMethods.isEmpty()) { - if (cls.@name in legacyClassesWithoutCoverage) { - return 'Please remove ' + cls.@name + ' from the legacyClassesWithoutCoverage list' \ - + ', this check does not apply for constructor-only classes' \ - + ' or classes with only static class initialization code.' - } else { - return null - } - } - - def covered = matchedMethods.collect { m -> - m.counter.find({ c -> c.@type == 'INSTRUCTION' })[email protected]()}.sum(0) - - if (cls.@name in legacyClassesWithoutCoverage) { - if (covered != 0) { - return 'Thanks for adding the first test coverage to: ' + cls.@name \ - + ' please remove it from the legacyClassesWithoutCoverage list' - } - } else if (covered == 0) { - return 'Test coverage missing for ' + cls.@name - } - return null - }.findAll() // Filter nulls. - if (!coverageErrors.isEmpty()) { - throw new GradleException(coverageErrors.join('\n')) - } - } - - @TaskAction - def analyze() { - def parser = new XmlSlurper() - parser.setFeature("http://apache.org/xml/features/disallow-doctype-decl", false); - // Avoid trying to load the DTD for the XML document, which does not exist. - parser.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false) - - def coverageReport = parser.parse(coverageReportFile) - - checkGlobalCoverage(coverageReport.counter) - checkClassCoverage(coverageReport) - } -} http://git-wip-us.apache.org/repos/asf/aurora/blob/0606369e/gradle/wrapper/gradle-wrapper.properties ---------------------------------------------------------------------- diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b290cf6..1160a69 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.2-bin.zip
