diff --git a/.github/dependabot.yml b/.github/dependabot.yml index bfeb9086..2c2e3ad2 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -13,3 +13,6 @@ updates: - dependency-name: com.github.spotbugs versions: - 4.6.2 + - dependency-name: org.scalatest:scalatest_2.13 + versions: + - "3.3.0-SNAP+" \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile index 39aefcf1..de775191 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -53,7 +53,7 @@ void setJavaVersion(javaVersionId) { String featureBranchName = "" //// gradle tasks that are executed -def gradleTasks = "--refresh-dependencies clean spotlessCheck pmdMain pmdTest spotbugsMain spotbugsTest allTests" // the gradle tasks that are executed on ALL projects +def gradleTasks = "--refresh-dependencies clean spotlessCheck pmdMain pmdTest spotbugsMain spotbugsTest test" // the gradle tasks that are executed on ALL projects def mainProjectGradleTasks = "jacocoTestReport jacocoTestCoverageVerification reportScoverage checkScoverage" // additional tasks that are only executed on project 0 (== main project) // if you need additional tasks for deployment add them here // NOTE: artifactory task with credentials will be added below @@ -99,15 +99,15 @@ if (env.BRANCH_NAME == "master") { } // test the project - stage("gradle allTests ${projects.get(0)}") { + stage("gradle test ${projects.get(0)}") { // build and test the project gradle("${gradleTasks} ${mainProjectGradleTasks}") } // execute sonarqube code analysis stage('SonarQube analysis') { - withSonarQubeEnv() { // Will pick the global server connection from jenkins for sonarqube, TODO: Remove exclusion, when removing deprecated quantity package - gradle("sonarqube -Dsonar.branch.name=master -Dsonar.projectKey=$sonarqubeProjectKey ") + withSonarQubeEnv() { // Will pick the global server connection from jenkins for sonarqube + gradle("sonarqube -Dsonar.branch.name=master -Dsonar.projectKey=$sonarqubeProjectKey") } } @@ -141,7 +141,7 @@ if (env.BRANCH_NAME == "master") { withCredentials([usernamePassword(credentialsId: mavenCentralCredentialsId, usernameVariable: 'mavencentral_username', passwordVariable: 'mavencentral_password'), file(credentialsId: mavenCentralSignKeyFileId, variable: 'mavenCentralKeyFile'), usernamePassword(credentialsId: mavenCentralSignKeyId, passwordVariable: 'signingPassword', usernameVariable: 'signingKeyId')]) { - deployGradleTasks = "--refresh-dependencies clean allTests " + deployGradleTasks + "publish -Puser=${env.mavencentral_username} -Ppassword=${env.mavencentral_password} -Psigning.keyId=${env.signingKeyId} -Psigning.password=${env.signingPassword} -Psigning.secretKeyRingFile=${env.mavenCentralKeyFile}" + deployGradleTasks = "--refresh-dependencies clean test " + deployGradleTasks + "publish -Puser=${env.mavencentral_username} -Ppassword=${env.mavencentral_password} -Psigning.keyId=${env.signingKeyId} -Psigning.password=${env.signingPassword} -Psigning.secretKeyRingFile=${env.mavenCentralKeyFile}" // see https://docs.gradle.org/6.0.1/release-notes.html "Publication of SHA256 and SHA512 checksums" def preventSHACheckSums = "-Dorg.gradle.internal.publish.checksums.insecure=true" @@ -220,15 +220,15 @@ if (env.BRANCH_NAME == "master") { // test the project - stage("gradle allTests ${projects.get(0)}") { + stage("gradle test ${projects.get(0)}") { // build and test the project gradle("${gradleTasks} ${mainProjectGradleTasks}") } // execute sonarqube code analysis stage('SonarQube analysis') { - withSonarQubeEnv() { // Will pick the global server connection from jenkins for sonarqube, TODO: Remove exclusion, when removing deprecated quantity package - gradle("sonarqube -Dsonar.branch.name=master -Dsonar.projectKey=$sonarqubeProjectKey") + withSonarQubeEnv() { // Will pick the global server connection from jenkins for sonarqube + gradle("sonarqube -Dsonar.branch.name=master -Dsonar.projectKey=$sonarqubeProjectKey ") } } @@ -264,7 +264,7 @@ if (env.BRANCH_NAME == "master") { withCredentials([usernamePassword(credentialsId: mavenCentralCredentialsId, usernameVariable: 'mavencentral_username', passwordVariable: 'mavencentral_password'), file(credentialsId: mavenCentralSignKeyFileId, variable: 'mavenCentralKeyFile'), usernamePassword(credentialsId: mavenCentralSignKeyId, passwordVariable: 'signingPassword', usernameVariable: 'signingKeyId')]) { - deployGradleTasks = "--refresh-dependencies clean allTests " + deployGradleTasks + "publish -Puser=${env.mavencentral_username} -Ppassword=${env.mavencentral_password} -Psigning.keyId=${env.signingKeyId} -Psigning.password=${env.signingPassword} -Psigning.secretKeyRingFile=${env.mavenCentralKeyFile}" + deployGradleTasks = "--refresh-dependencies clean test " + deployGradleTasks + "publish -Puser=${env.mavencentral_username} -Ppassword=${env.mavencentral_password} -Psigning.keyId=${env.signingKeyId} -Psigning.password=${env.signingPassword} -Psigning.secretKeyRingFile=${env.mavenCentralKeyFile}" gradle("${deployGradleTasks}") @@ -358,7 +358,7 @@ if (env.BRANCH_NAME == "master") { } // test the project - stage("gradle allTests ${projects.get(0)}") { + stage("gradle test ${projects.get(0)}") { // build and test the project gradle("${gradleTasks} ${mainProjectGradleTasks}") @@ -368,7 +368,6 @@ if (env.BRANCH_NAME == "master") { stage('SonarQube analysis') { withSonarQubeEnv() { // Will pick the global server connection from jenkins for sonarqube - // do we have a PR?, TODO: Remove with removal of deprecated quantity package String gradleCommand = "sonarqube -Dsonar.projectKey=$sonarqubeProjectKey" if (env.CHANGE_ID != null) { @@ -475,7 +474,7 @@ def gitCheckout(String relativeTargetDir, String baseUrl, String branch, String ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// def publishReports() { // publish test reports - publishHTML([allowMissing: true, alwaysLinkToLastBuild: true, escapeUnderscores: false, keepAll: true, reportDir: projects.get(0) + '/build/reports/tests/allTests', reportFiles: 'index.html', reportName: "${projects.get(0)}_java_tests_report", reportTitles: '']) + publishHTML([allowMissing: true, alwaysLinkToLastBuild: true, escapeUnderscores: false, keepAll: true, reportDir: projects.get(0) + '/build/reports/tests/test', reportFiles: 'index.html', reportName: "${projects.get(0)}_java_tests_report", reportTitles: '']) // publish jacoco report for main project only publishHTML([allowMissing: true, alwaysLinkToLastBuild: true, escapeUnderscores: false, keepAll: true, reportDir: projects.get(0) + '/build/reports/jacoco', reportFiles: 'index.html', reportName: "${projects.get(0)}_jacoco_report", reportTitles: '']) @@ -487,7 +486,7 @@ def publishReports() { publishHTML([allowMissing: true, alwaysLinkToLastBuild: true, escapeUnderscores: false, keepAll: true, reportDir: projects.get(0) + '/build/reports/spotbugs', reportFiles: 'main.html', reportName: "${projects.get(0)}_spotbugs_report", reportTitles: '']) // scoverage report dir - publishHTML([allowMissing: false, alwaysLinkToLastBuild: true, escapeUnderscores: false, keepAll: true, reportDir: projects.get(0) + '/build/reports/scoverageAllTests', reportFiles: 'scoverage.xml', reportName: "${projects.get(0)}_scoverage_report", reportTitles: '']) + publishHTML([allowMissing: false, alwaysLinkToLastBuild: true, escapeUnderscores: false, keepAll: true, reportDir: projects.get(0) + '/build/reports/scoverageTest', reportFiles: 'scoverage.xml', reportName: "${projects.get(0)}_scoverage_report", reportTitles: '']) } diff --git a/build.gradle b/build.gradle index 283af83b..a7488e95 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ plugins { id 'signing' id 'pmd' //code check, working on source code id 'com.github.spotbugs' version '4.8.0' //code check, working on byte code - id 'com.diffplug.spotless' version '6.0.0'//code format + id 'com.diffplug.spotless' version '6.0.1'//code format id 'jacoco' // java code coverage plugin id "org.sonarqube" version "3.3" // sonarqube id "com.github.maiflai.scalatest" version "0.31" // run scalatest without specific spec task @@ -27,7 +27,6 @@ description = 'PowerSystemUtils' sourceCompatibility = javaVersion targetCompatibility = javaVersion -apply from: scriptsLocation + 'tests.gradle' apply from: scriptsLocation + 'pmd.gradle' apply from: scriptsLocation + 'spotbugs.gradle' apply from: scriptsLocation + 'spotless.gradle' @@ -35,7 +34,7 @@ apply from: scriptsLocation + 'checkJavaVersion.gradle' apply from: scriptsLocation + 'jacoco.gradle' // jacoco java code coverage apply from: scriptsLocation + 'mavenCentralPublish.gradle' apply from: scriptsLocation + 'scoverage.gradle' - +apply from: scriptsLocation + 'sonarqube.gradle' repositories { mavenCentral() diff --git a/gradle/scripts/jacoco.gradle b/gradle/scripts/jacoco.gradle index 25739dc4..5f9629b4 100644 --- a/gradle/scripts/jacoco.gradle +++ b/gradle/scripts/jacoco.gradle @@ -1,24 +1,12 @@ // see https://docs.gradle.org/current/userguide/jacoco_plugin.html for details // and http://vgaidarji.me/blog/2017/12/20/how-to-configure-jacoco-for-kotlin-and-java-project/ for exclude explanation -//ext { -// // jacoco java code coverage source dir -// coverageSourceDirs = 'src/test/java' -//} - // general configuration jacoco { - toolVersion = "0.8.4" + toolVersion = "0.8.7" reportsDir = file("$buildDir/reports/jacoco") } -//test { -// jacoco { -// enabled = true -// -// } -//} - jacocoTestReport { reports { xml.enabled true @@ -45,7 +33,7 @@ jacocoTestReport { )) // sourceSets sourceSets.main - executionData allTests // include integration tests in jacoco reports + executionData test // include integration tests in jacoco reports } jacocoTestCoverageVerification { diff --git a/gradle/scripts/pmd.gradle b/gradle/scripts/pmd.gradle index 3c71e374..38420f74 100644 --- a/gradle/scripts/pmd.gradle +++ b/gradle/scripts/pmd.gradle @@ -2,8 +2,8 @@ pmd { ignoreFailures = true // dont let the build fail on rule violations - - toolVersion = "6.21.0" + consoleOutput = true + toolVersion = "6.36.0" // pmd rule priority is a range from 1 to 5, with 1 being the highest priority // the default rule priority is 5 rulesMinimumPriority = 2 diff --git a/gradle/scripts/sonarqube.gradle b/gradle/scripts/sonarqube.gradle index 2f0e7075..f51a6224 100644 --- a/gradle/scripts/sonarqube.gradle +++ b/gradle/scripts/sonarqube.gradle @@ -6,7 +6,6 @@ sonarqube { property 'sonar.verbose', 'true' // verbose mode property 'sonar.sourceEncoding', 'UTF-8' // encoding property 'sonar.sources', [ - 'src/main/resources', 'src/main/java', 'src/main/scala'] // src dirs property "sonar.tests", [ @@ -35,17 +34,20 @@ sonarqube { property 'sonar.groovy.binaries', 'build/classes/groovy' // groovy binaries // scala specific stuff property 'sonar.scala.coverage.reportPaths', 'build/reports/scoverage/scoverage.xml' - } } // forces sonarqube to execute integration tests -project.tasks["sonarqube"].dependsOn "pmdMain" -project.tasks["sonarqube"].dependsOn "pmdTest" -project.tasks["sonarqube"].dependsOn "spotbugsMain" -project.tasks["sonarqube"].dependsOn "spotbugsTest" -project.tasks["sonarqube"].dependsOn "allTests" +project.tasks["sonarqube"].dependsOn "check" +// Check itself depends on +// - pmdMain +// - spotBugsMain +// - pmdTest +// - spotBugsTest +// - test + project.tasks["sonarqube"].dependsOn "jacocoTestReport" project.tasks["sonarqube"].dependsOn "jacocoTestCoverageVerification" + project.tasks["sonarqube"].dependsOn "reportScoverage" project.tasks["sonarqube"].dependsOn "checkScoverage" diff --git a/gradle/scripts/tests.gradle b/gradle/scripts/tests.gradle deleted file mode 100644 index ba180e42..00000000 --- a/gradle/scripts/tests.gradle +++ /dev/null @@ -1,17 +0,0 @@ -test { - // by default we don't want to run integration tests - filter { - excludeTestsMatching '*IT' - } -} -test.dependsOn(scalatest) - -task allTests(type: Test) { - description 'executes all tests' - filter { - includeTestsMatching '*Test*.*' - includeTestsMatching '*IT' - } - mustRunAfter test -} -allTests.dependsOn(test)