You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2018/06/04 20:07:54 UTC

[GitHub] sijie closed pull request #1475: Improve precommit CI jobs on handling PRs made to branches

sijie closed pull request #1475:  Improve precommit CI jobs on handling PRs made to branches
URL: https://github.com/apache/bookkeeper/pull/1475
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/.test-infra/jenkins/common_job_properties.groovy b/.test-infra/jenkins/common_job_properties.groovy
index 2b51f4266..86162a8c7 100644
--- a/.test-infra/jenkins/common_job_properties.groovy
+++ b/.test-infra/jenkins/common_job_properties.groovy
@@ -43,7 +43,8 @@ class common_job_properties {
                                            String branch = 'master',
                                            String jdkVersion = 'JDK 1.8 (latest)',
                                            int timeout = 200,
-                                           String jenkinsExecutorLabel = 'ubuntu') {
+                                           String jenkinsExecutorLabel = 'ubuntu',
+                                           String branchVarName = '${sha1}') {
     // GitHub project.
     context.properties {
       githubProjectUrl('https://github.com/apache/bookkeeper/')
@@ -55,7 +56,9 @@ class common_job_properties {
             'https://github.com/apache/bookkeeper.git',
             branch,
             jenkinsExecutorLabel,
-            timeout)
+            timeout,
+            jdkVersion,
+            branchVarName)
   }
 
   // Sets common top-level job properties. Accessed through one of the above
@@ -65,7 +68,8 @@ class common_job_properties {
                                                String defaultBranch,
                                                String jenkinsExecutorLabel,
                                                int defaultTimeout,
-                                               String jdkVersion = 'JDK 1.8 (latest)') {
+                                               String jdkVersion = 'JDK 1.8 (latest)',
+                                               String branchVarName = '${sha1}') {
     // Set JDK version.
     context.jdk(jdkVersion)
 
@@ -85,20 +89,23 @@ class common_job_properties {
           refspec('+refs/heads/*:refs/remotes/origin/* ' +
                   '+refs/pull/${ghprbPullId}/*:refs/remotes/origin/pr/${ghprbPullId}/*')
         }
-        branch('${sha1}')
+        branch(branchVarName)
         extensions {
           cleanAfterCheckout()
         }
       }
     }
 
-    context.parameters {
-      // This is a recommended setup if you want to run the job manually. The
-      // ${sha1} parameter needs to be provided, and defaults to the main branch.
-      stringParam(
-          'sha1',
-          defaultBranch,
-          'Commit id or refname (eg: origin/pr/9/head) you want to build.')
+    // add the parameter when branch var name is `sha1`
+    if (branchVarName == '${sha1}') {
+      context.parameters {
+        // This is a recommended setup if you want to run the job manually. The
+        // ${sha1} parameter needs to be provided, and defaults to the main branch.
+        stringParam(
+            'sha1',
+            defaultBranch,
+            'Commit id or refname (eg: origin/pr/9/head) you want to build.')
+      }
     }
 
     context.wrappers {
@@ -120,7 +127,8 @@ class common_job_properties {
   private static void setPullRequestBuildTrigger(context,
                                                  String commitStatusContext,
                                                  String successComment = '--none--',
-                                                 String prTriggerPhrase = '') {
+                                                 String prTriggerPhrase = '',
+                                                 boolean onlyMaster = false) {
     context.triggers {
       githubPullRequest {
         admins(['asfbot'])
@@ -137,6 +145,9 @@ class common_job_properties {
           triggerPhrase(prTriggerPhrase)
           onlyTriggerPhrase()
         }
+        if (onlyMaster) {
+          whiteListTargetBranches(['master'])
+        }
 
         extensions {
           commitStatus {
@@ -202,9 +213,10 @@ class common_job_properties {
   // Sets common config for PreCommit jobs.
   static void setPreCommit(context,
                            String commitStatusName,
-                           String successComment = '--none--') {
+                           String successComment = '--none--',
+                           boolean onlyMaster = false) {
     // Set pull request build trigger.
-    setPullRequestBuildTrigger(context, commitStatusName, successComment)
+    setPullRequestBuildTrigger(context, commitStatusName, successComment, '', onlyMaster)
   }
 
   // Enable triggering postcommit runs against pull requests. Users can comment the trigger phrase
diff --git a/.test-infra/jenkins/job_bookkeeper_postcommit_master_java8.groovy b/.test-infra/jenkins/job_bookkeeper_postcommit_master_java8.groovy
index ed13b8cdf..cb15c3f20 100644
--- a/.test-infra/jenkins/job_bookkeeper_postcommit_master_java8.groovy
+++ b/.test-infra/jenkins/job_bookkeeper_postcommit_master_java8.groovy
@@ -42,5 +42,5 @@ mavenJob('bookkeeper_postcommit_master_java8') {
   common_job_properties.setMavenConfig(delegate)
 
   // Maven build project.
-  goals('clean apache-rat:check checkstyle:check package spotbugs:check -Ddistributedlog -Dstream -DstreamTests')
+  goals('clean package spotbugs:check -Ddistributedlog -Dstream -DstreamTests')
 }
diff --git a/.test-infra/jenkins/job_bookkeeper_postcommit_master_java9.groovy b/.test-infra/jenkins/job_bookkeeper_postcommit_master_java9.groovy
index 006255f63..942fd092c 100644
--- a/.test-infra/jenkins/job_bookkeeper_postcommit_master_java9.groovy
+++ b/.test-infra/jenkins/job_bookkeeper_postcommit_master_java9.groovy
@@ -42,5 +42,5 @@ mavenJob('bookkeeper_postcommit_master_java9') {
   common_job_properties.setMavenConfig(delegate)
 
   // Maven build project.
-  goals('clean apache-rat:check checkstyle:check package spotbugs:check -Ddistributedlog -Dstream -DstreamTests')
+  goals('clean package spotbugs:check -Ddistributedlog -Dstream -DstreamTests')
 }
diff --git a/.test-infra/jenkins/job_bookkeeper_postcommit_validation_master.groovy b/.test-infra/jenkins/job_bookkeeper_postcommit_validation_master.groovy
new file mode 100644
index 000000000..f914f4474
--- /dev/null
+++ b/.test-infra/jenkins/job_bookkeeper_postcommit_validation_master.groovy
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+import common_job_properties
+
+// This job runs the Java postcommit validation on master branch
+mavenJob('bookkeeper_postcommit_validation_master') {
+  description('Runs postcommit validation nightly for bookkeeper.')
+
+  // Set common parameters.
+  common_job_properties.setTopLevelMainJobProperties(
+    delegate, 'master', 'JDK 1.8 (latest)')
+
+  // Sets that this is a PostCommit job.
+  common_job_properties.setPostCommit(
+      delegate,
+      'H 12 * * *',
+      false)
+
+  // Allows triggering this build against pull requests.
+  common_job_properties.enablePhraseTriggeringFromPullRequest(
+      delegate,
+      'Postcommit Validation',
+      '/postcommit-validation')
+
+  // Set maven parameters.
+  common_job_properties.setMavenConfig(delegate)
+
+  // Maven build project.
+  goals('clean apache-rat:check checkstyle:check package -Ddistributedlog -Dstream -DskipTests')
+}
diff --git a/.test-infra/jenkins/job_bookkeeper_precommit_integrationtests.groovy b/.test-infra/jenkins/job_bookkeeper_precommit_integrationtests.groovy
index 8cd5c9a4c..9cd7635c5 100644
--- a/.test-infra/jenkins/job_bookkeeper_precommit_integrationtests.groovy
+++ b/.test-infra/jenkins/job_bookkeeper_precommit_integrationtests.groovy
@@ -27,7 +27,9 @@ freeStyleJob('bookkeeper_precommit_integrationtests') {
         delegate,
         'master',
         'JDK 1.8 (latest)',
-        120)
+        120,
+        'ubuntu',
+        '${ghprbTargetBranch}')
 
     // Execute concurrent builds if necessary.
     concurrentBuild()
diff --git a/.test-infra/jenkins/job_bookkeeper_precommit_java8.groovy b/.test-infra/jenkins/job_bookkeeper_precommit_java8.groovy
index 3586b358a..28e7214e1 100644
--- a/.test-infra/jenkins/job_bookkeeper_precommit_java8.groovy
+++ b/.test-infra/jenkins/job_bookkeeper_precommit_java8.groovy
@@ -39,7 +39,9 @@ mavenJob('bookkeeper_precommit_pullrequest_java8') {
     delegate,
     'master',
     'JDK 1.8 (latest)',
-    200)
+    200,
+    'ubuntu',
+    '${ghprbTargetBranch}')
 
   // Sets that this is a PreCommit job.
   common_job_properties.setPreCommit(delegate, 'Maven clean install (Java 8)')
@@ -48,5 +50,5 @@ mavenJob('bookkeeper_precommit_pullrequest_java8') {
   common_job_properties.setMavenConfig(delegate)
 
   // Maven build project
-  goals('clean apache-rat:check checkstyle:check package spotbugs:check -Dstream')
+  goals('clean apache-rat:check package spotbugs:check -Dstream')
 }
diff --git a/.test-infra/jenkins/job_bookkeeper_precommit_java9.groovy b/.test-infra/jenkins/job_bookkeeper_precommit_java9.groovy
index 16a8449bd..120144e14 100644
--- a/.test-infra/jenkins/job_bookkeeper_precommit_java9.groovy
+++ b/.test-infra/jenkins/job_bookkeeper_precommit_java9.groovy
@@ -39,7 +39,9 @@ mavenJob('bookkeeper_precommit_pullrequest_java9') {
     delegate,
     'master',
     'JDK 1.9 (latest)',
-    200)
+    200,
+    'ubuntu',
+    '${ghprbTargetBranch}')
 
   // Sets that this is a PreCommit job.
   common_job_properties.setPreCommit(delegate, 'Maven clean install (Java 9)')
@@ -48,5 +50,5 @@ mavenJob('bookkeeper_precommit_pullrequest_java9') {
   common_job_properties.setMavenConfig(delegate)
 
   // Maven build project
-  goals('clean apache-rat:check checkstyle:check package spotbugs:check -Dstream')
+  goals('clean apache-rat:check package spotbugs:check -Dstream')
 }
diff --git a/.test-infra/jenkins/job_bookkeeper_precommit_validation.groovy b/.test-infra/jenkins/job_bookkeeper_precommit_validation.groovy
new file mode 100644
index 000000000..48d6c3a88
--- /dev/null
+++ b/.test-infra/jenkins/job_bookkeeper_precommit_validation.groovy
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+import common_job_properties
+
+// This is the Java precommit validation job that validates pull requests (e.g. checkstyle)
+mavenJob('bookkeeper_precommit_pullrequest_validation') {
+  description('precommit validation for pull requests of <a href="http://bookkeeper.apache.org">Apache BookKeeper</a>.')
+
+  // Execute concurrent builds if necessary.
+  concurrentBuild()
+
+  // Set common parameters.
+  common_job_properties.setTopLevelMainJobProperties(
+    delegate,
+    'master',
+    'JDK 1.8 (latest)',
+    200,
+    'ubuntu',
+    '${ghprbTargetBranch}')
+
+  // Sets that this is a PreCommit job.
+  common_job_properties.setPreCommit(delegate, 'Pull Request Validation', '--none--', true)
+
+  // Set Maven parameters.
+  common_job_properties.setMavenConfig(delegate)
+
+  // Maven build project
+  goals('clean apache-rat:check checkstyle:check package -Ddistributedlog -Dstream -DskipTests')
+}
diff --git a/.test-infra/jenkins/job_bookkeeper_release_nightly_snapshot.groovy b/.test-infra/jenkins/job_bookkeeper_release_nightly_snapshot.groovy
index 1a8144418..fa2dd61aa 100644
--- a/.test-infra/jenkins/job_bookkeeper_release_nightly_snapshot.groovy
+++ b/.test-infra/jenkins/job_bookkeeper_release_nightly_snapshot.groovy
@@ -64,7 +64,7 @@ export MAVEN_OPTS=-Xmx2048m
       common_job_properties.setMavenConfig(delegate)
 
       // Maven build project.
-      goals('clean apache-rat:check checkstyle:check package spotbugs:check -Dmaven.test.failure.ignore=true deploy -Ddistributedlog -Dstream -DstreamTests -Pdocker')
+      goals('clean package -Dmaven.test.failure.ignore=true deploy -Ddistributedlog -Dstream -DstreamTests -Pdocker')
     }
 
     // publish the docker images


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services