jjb: lttng-modules: Add gerrit build job
authorMichael Jeanson <mjeanson@efficios.com>
Mon, 2 Mar 2020 16:46:37 +0000 (11:46 -0500)
committerMichael Jeanson <mjeanson@efficios.com>
Mon, 2 Mar 2020 16:46:37 +0000 (11:46 -0500)
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
jobs/lttng-modules.yaml
scripts/lttng-modules/master-rt.groovy
scripts/lttng-modules/master.groovy
scripts/lttng-modules/param-build.sh

index f905ea5d3b3034f18b9ee075c14d1bdb05518ca8..01a04349d003d1343011c0edadd1808defc36ccd 100644 (file)
@@ -3,10 +3,6 @@
 - lttng-modules_build_parameters_defaults: &lttng-modules_build_parameters_defaults
     name: 'lttng-modules_build_parameters_defaults'
     parameters:
-      - string:
-          name: 'mversion'
-          default: '{mversion}'
-          description: 'The lttng-modules branch to build.'
       - string:
           name: 'maxConcurrentBuild'
           default: '20'
           name: 'kverfilter'
           default: '{kverfilter}'
           description: 'Kernel versions list filtering strategy.'
+      - string:
+          name: 'kverrc'
+          default: 'true'
+          description: 'Add latest RC to kernel versions list.'
       - string:
           name: 'kgitrepo'
           default: 'git://git-mirror.internal.efficios.com/git/linux-all.git'
           default: 'lttng-modules_PARAM_{parambuildtype}'
           description: 'The parametrized job to use for child builds.'
 
+- lttng-modules_build_parameters_gerrit: &lttng-modules_build_parameters_gerrit
+    name: 'lttng-modules_build_parameters_defaults'
+    parameters:
+      - string:
+          name: 'maxConcurrentBuild'
+          default: '10'
+          description: 'The maximum number of concurrent child build to run.'
+      - string:
+          name: 'kverfloor'
+          default: '{kverfloor}'
+          description: 'The lowest kernel version to build.'
+      - string:
+          name: 'kverceil'
+          default: '{kverceil}'
+          description: 'The highest kernel version to build. (excluded)'
+      - string:
+          name: 'kverfilter'
+          default: '{kverfilter}'
+          description: 'Kernel versions list filtering strategy.'
+      - string:
+          name: 'kverrc'
+          default: 'false'
+          description: 'Add latest RC to kernel versions list.'
+      - string:
+          name: 'kgitrepo'
+          default: 'git://git-mirror.internal.efficios.com/git/linux-all.git'
+          description: 'The linux kernel git repository url.'
+      - string:
+          name: 'kbuildjob'
+          default: 'lttng-modules_PARAM_build'
+          description: 'The parametrized job to use for child builds.'
+
 - lttng-modules_build_parameters_ubuntu: &lttng-modules_build_parameters_ubuntu
     name: 'lttng-modules_build_parameters_ubuntu'
     parameters:
-      - string:
-          name: 'mversion'
-          default: '{mversion}'
-          description: 'The lttng-modules branch to build.'
       - string:
           name: 'maxConcurrentBuild'
           default: '20'
           name: 'kverfilter'
           default: '{kverfilter}'
           description: 'Kernel versions list filtering strategy.'
+      - string:
+          name: 'kverrc'
+          default: 'false'
+          description: 'Add latest RC to kernel versions list.'
       - string:
           name: 'kgitrepo'
           default: 'git://git-mirror.internal.efficios.com/git/ubuntu-{uversion}.git'
 - lttng-modules_build_parameters_rt: &lttng-modules_build_parameters_rt
     name: 'lttng-modules_build_parameters_rt'
     parameters:
-      - string:
-          name: 'mversion'
-          default: '{mversion}'
-          description: 'The lttng-modules branch to build.'
       - string:
           name: 'maxConcurrentBuild'
           default: '20'
           name: 'kverfilter'
           default: '{kverfilter}'
           description: 'Kernel versions list filtering strategy.'
+      - string:
+          name: 'kverrc'
+          default: 'false'
+          description: 'Add latest RC to kernel versions list.'
       - string:
           name: 'kgitrepo'
           default: 'git://git-mirror.internal.efficios.com/kernel/rt/linux-stable-rt.git'
           browser: githubweb
           browser-url: https://github.com/{github_user}/{github_name}
           branches:
-            - "{mversion}"
+            - "refs/heads/{mversion}"
           shallow-clone: true
           fastpoll: true
           basedir: src/lttng-modules
     <<: *lttng-modules_build_parameters_defaults
     <<: *lttng-modules_build_builders_defaults
 
+- job-template:
+    name: dev_gerrit_lttng-modules_build
+    defaults: lttng-modules
+    concurrent: true
+
+    node: 'master'
+
+    scm:
+      - git:
+          url: https://review.lttng.org/lttng-modules
+          refspec: 'refs/changes/*:refs/changes/*'
+          branches:
+            - '$GERRIT_REFSPEC'
+          basedir: src/lttng-modules
+          skip-tag: true
+
+    triggers:
+      - gerrit:
+          trigger-on:
+            - comment-added-event:
+                approval-category: 'CI-Build'
+                approval-value: 1
+          projects:
+            - project-compare-type: 'PLAIN'
+              project-pattern: 'lttng-modules'
+              branches:
+                - branch-compare-type: 'ANT'
+                  branch-pattern: '**'
+          trigger-for-unreviewed-patches: true
+
+    properties:
+      - build-discarder:
+          num-to-keep: 2
+
+    <<: *lttng-modules_build_parameters_gerrit
+    <<: *lttng-modules_build_builders_defaults
+
+    publishers:
+      - workspace-cleanup
+
 - job-template:
     name: lttng-modules_{mversion}_fullbuild-vanilla
     defaults: lttng-modules
 
     builders:
       - shell: |
-         git clone --depth=1 -b v4.20 --reference $HOME/gitcache/linux-stable.git/ git://git-mirror.internal.efficios.com/kernel/stable/linux-stable.git src/linux
+         git clone --depth=1 -b v5.5 --reference $HOME/gitcache/linux-stable.git/ git://git-mirror.internal.efficios.com/kernel/stable/linux-stable.git src/linux
          cd src/linux
-         make defconfig
+         make allyesconfig
          sed -i "s/# CONFIG_KALLSYMS_ALL is not set/CONFIG_KALLSYMS_ALL=y/g" .config
          make modules_prepare
       - shell:
           mversion: master
       - 'lttng-modules_{mversion}_coverity':
           mversion: master
+
+- project:
+    name: lttng-modules-gerrit
+    jobs:
+      - 'dev_gerrit_lttng-modules_build':
+          kverfloor: v5.5
+          kverceil: v5.6
+          kverfilter: stable-head
index 5f634ed5a9e9fa4875b4103bce1f3816c427db06..6479f4d1955277546001ae9834670c00e81583af 100644 (file)
@@ -158,7 +158,7 @@ class RTKVersion implements Comparable<RTKVersion> {
 
 
 // Retrieve parameters of the current build
-def mversion = build.buildVariableResolver.resolve('mversion')
+def mbranch = build.getEnvironment(listener).get('GIT_BRANCH').minus('origin/')
 def maxConcurrentBuild = build.buildVariableResolver.resolve('maxConcurrentBuild')
 def kgitrepo = build.buildVariableResolver.resolve('kgitrepo')
 def kverfloor_raw = build.buildVariableResolver.resolve('kverfloor')
@@ -302,7 +302,7 @@ while ( kversions.size() != 0 || ongoingBuild.size() != 0 ) {
   if(ongoingBuild.size() < maxConcurrentBuild.toInteger() && kversions.size() != 0) {
     def kversion = kversions.pop()
     def job_params = [
-      new StringParameterValue('mversion', mversion),
+      new StringParameterValue('mversion', mbranch),
       new StringParameterValue('mgitrepo', mgitrepo),
       new StringParameterValue('ktag', kversion.toString()),
       new StringParameterValue('kgitrepo', kgitrepo),
@@ -310,7 +310,7 @@ while ( kversions.size() != 0 || ongoingBuild.size() != 0 ) {
 
     // Launch the parametrized build
     def param_build = job.scheduleBuild2(0, new Cause.UpstreamCause(build), new ParametersAction(job_params))
-    println "triggering ${joburl} for the ${mversion} branch on kernel ${kversion}"
+    println "triggering ${joburl} for the ${mbranch} branch on kernel ${kversion}"
 
     // Add it to the ongoing build queue
     ongoingBuild.push(param_build)
index 29ff8ce0078b70daf88f023c9bda38faee0f20b8..152668114beeab68951e8e301016a7000fad33c5 100644 (file)
@@ -303,12 +303,13 @@ class UbuntuKVersion implements Comparable<UbuntuKVersion> {
 
 
 // Retrieve parameters of the current build
-def mversion = build.buildVariableResolver.resolve('mversion')
+def mbranch = build.getEnvironment(listener).get('GIT_BRANCH').minus('origin/')
 def maxConcurrentBuild = build.buildVariableResolver.resolve('maxConcurrentBuild')
 def kgitrepo = build.buildVariableResolver.resolve('kgitrepo')
 def kverfloor_raw = build.buildVariableResolver.resolve('kverfloor')
 def kverceil_raw = build.buildVariableResolver.resolve('kverceil')
 def kverfilter = build.buildVariableResolver.resolve('kverfilter')
+def kverrc = build.buildVariableResolver.resolve('kverrc')
 def uversion = build.buildVariableResolver.resolve('uversion')
 def job = Hudson.instance.getJob(build.buildVariableResolver.resolve('kbuildjob'))
 def currentJobName = build.project.getFullDisplayName()
@@ -449,9 +450,11 @@ switch (kverfilter) {
     break
 }
 
-// If the last RC version is newer than the last stable, add it to the build list
-if (kversionsRC.size() > 0 && kversionsRC.last() > kversions.last()) {
-  kversions.add(kversionsRC.last())
+if (kverrc == "true") {
+  // If the last RC version is newer than the last stable, add it to the build list
+  if (kversionsRC.size() > 0 && kversionsRC.last() > kversions.last()) {
+    kversions.add(kversionsRC.last())
+  }
 }
 
 println "Building the following kernel versions:"
@@ -476,7 +479,7 @@ while ( kversions.size() != 0 || ongoingBuild.size() != 0 ) {
   if(ongoingBuild.size() < maxConcurrentBuild.toInteger() && kversions.size() != 0) {
     def kversion = kversions.pop()
     def job_params = [
-      new StringParameterValue('mversion', mversion),
+      new StringParameterValue('mversion', mbranch),
       new StringParameterValue('mgitrepo', mgitrepo),
       new StringParameterValue('ktag', kversion.toString()),
       new StringParameterValue('kgitrepo', kgitrepo),
@@ -484,7 +487,7 @@ while ( kversions.size() != 0 || ongoingBuild.size() != 0 ) {
 
     // Launch the parametrized build
     def param_build = job.scheduleBuild2(0, new Cause.UpstreamCause(build), new ParametersAction(job_params))
-    println "triggering ${joburl} for the ${mversion} branch on kernel ${kversion}"
+    println "triggering ${joburl} for the ${mbranch} branch on kernel ${kversion}"
 
     // Add it to the ongoing build queue
     ongoingBuild.push(param_build)
index 0ce165a7aca1d2b67a542a8868d3d1bf9d160970..e580dd41318866e0de4ab3049f580e7c6bb203de 100644 (file)
@@ -32,6 +32,7 @@ verlte() {
 }
 
 verlt() {
+    # shellcheck disable=SC2015
     [ "$1" = "$2" ] && return 1 || verlte "$1" "$2"
 }
 
@@ -40,13 +41,22 @@ vergte() {
 }
 
 vergt() {
+    # shellcheck disable=SC2015
     [ "$1" = "$2" ] && return 1 || vergte "$1" "$2"
 }
 
 
 git_clone_modules_sources() {
     mkdir -p "$MODULES_GIT_DIR"
-    git clone --depth=1 -b "${mversion}" "${mgitrepo}" "$MODULES_GIT_DIR"
+
+    # If the version starts with "refs/", checkout the specific git ref, otherwise treat it
+    # as a branch name.
+    if [ "${mversion:0:5}" = "refs/" ]; then
+        git clone --no-tags --depth=1 "${mgitrepo}" "$MODULES_GIT_DIR"
+        (cd "$MODULES_GIT_DIR" && git fetch origin "${mversion}" && git checkout FETCH_HEAD)
+    else
+        git clone --no-tags --depth=1 -b "${mversion}" "${mgitrepo}" "$MODULES_GIT_DIR"
+    fi
 }
 
 # Checkout a shallow kernel tree of the specified tag
This page took 0.027899 seconds and 4 git commands to generate.