jjb: Pass the events to enable in lava benchmarks
[lttng-ci.git] / scripts / lttng-modules / master-vanilla.groovy
index 33c62f5424fad3888f4933b4fb05d4dae3f1d6a1..7ba8974015e18d807c04710bf50029dbbd040cbb 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2016 - Michael Jeanson <mjeanson@efficios.com>
+ * Copyright (C) 2016-2017 - Michael Jeanson <mjeanson@efficios.com>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -23,6 +23,18 @@ import org.eclipse.jgit.api.Git
 import org.eclipse.jgit.lib.Ref
 
 
+class InvalidkVersionException extends Exception {
+  public InvalidkVersionException(String message) {
+    super(message)
+  }
+}
+
+class EmptykVersionException extends Exception {
+  public EmptykVersionException(String message) {
+    super(message)
+  }
+}
+
 class kVersion implements Comparable<kVersion> {
 
   Integer major = 0;
@@ -44,9 +56,13 @@ class kVersion implements Comparable<kVersion> {
     this.patch = 0
     this.rc = Integer.MAX_VALUE
 
+    if (!version) {
+      throw new EmptykVersionException("Empty kernel version")
+    }
+
     def match = version =~ /^v(\d+)\.(\d+)(\.(\d+))?(\.(\d+))?(-rc(\d+))?$/
     if (!match) {
-      throw new Exception("Invalid kernel version: ${version}")
+      throw new InvalidkVersionException("Invalid kernel version: ${version}")
     }
 
     Integer offset = 0;
@@ -79,21 +95,36 @@ class kVersion implements Comparable<kVersion> {
     return this.rc != Integer.MAX_VALUE
   }
 
+  // Return true if both version are of the same stable branch
+  Boolean isSameStable(kVersion o) {
+    if (this.major != o.major) {
+      return false
+    }
+    if (this.majorB != o.majorB) {
+      return false
+    }
+    if (this.minor != o.minor) {
+      return false
+    }
+
+    return true
+  }
+
   @Override int compareTo(kVersion o) {
     if (this.major != o.major) {
-      return Integer.compare(this.major, o.major);
+      return Integer.compare(this.major, o.major)
     }
     if (this.majorB != o.majorB) {
-      return Integer.compare(this.majorB, o.majorB);
+      return Integer.compare(this.majorB, o.majorB)
     }
     if (this.minor != o.minor) {
-      return Integer.compare(this.minor, o.minor);
+      return Integer.compare(this.minor, o.minor)
     }
     if (this.patch != o.patch) {
-      return Integer.compare(this.patch, o.patch);
+      return Integer.compare(this.patch, o.patch)
     }
     if (this.rc != o.rc) {
-      return Integer.compare(this.rc, o.rc);
+      return Integer.compare(this.rc, o.rc)
     }
 
     // Same version
@@ -125,18 +156,28 @@ class kVersion implements Comparable<kVersion> {
 def mversion = build.buildVariableResolver.resolve('mversion')
 def maxConcurrentBuild = build.buildVariableResolver.resolve('maxConcurrentBuild')
 def kgitrepo = build.buildVariableResolver.resolve('kgitrepo')
-def kverfloor = new kVersion(build.buildVariableResolver.resolve('kverfloor'))
+def kverfloor_raw = build.buildVariableResolver.resolve('kverfloor')
+def kverceil_raw = build.buildVariableResolver.resolve('kverceil')
+def kverfilter = build.buildVariableResolver.resolve('kverfilter')
 def job = Hudson.instance.getJob(build.buildVariableResolver.resolve('kbuildjob'))
 def currentJobName = build.project.getFullDisplayName()
 
+// Parse kernel versions
+def kverfloor = new kVersion(kverfloor_raw)
+def kverceil = ""
+
+try {
+    kverceil = new kVersion(kverceil_raw)
+} catch (EmptykVersionException e) {
+    kverceil = new kVersion("v" + Integer.MAX_VALUE + ".0.0")
+}
+
 // Get the out variable
 def config = new HashMap()
 def bindings = getBinding()
 config.putAll(bindings.getVariables())
 def out = config['out']
 
-def jlc = new jenkins.model.JenkinsLocationConfiguration()
-def jenkinsUrl = jlc.url
 
 // Get tags from git repository
 def refs = Git.lsRemoteRepository().setTags(true).setRemote(kgitrepo).call();
@@ -150,7 +191,7 @@ for (ref in refs) {
   if (match) {
     def v = new kVersion(match.group(1))
 
-    if (v >= kverfloor) {
+    if ((v >= kverfloor) && (v < kverceil)) {
       if (v.isRC()) {
         kversionsRC.add(v)
       } else {
@@ -163,6 +204,30 @@ for (ref in refs) {
 kversions.sort()
 kversionsRC.sort()
 
+switch (kverfilter) {
+  case 'stable-head':
+    // Keep only the head of each stable branch
+    println('Filter kernel versions to keep only the latest point release of each stable branch.')
+
+    for (i = 0; i < kversions.size(); i++) {
+      def curr = kversions[i]
+      def next = i < kversions.size() - 1 ? kversions[i + 1] : null
+
+      if (next != null) {
+        if (curr.isSameStable(next)) {
+          kversions.remove(i)
+          i--
+        }
+      }
+    }
+    break
+
+  default:
+    // No filtering of kernel versions
+    println('No kernel versions filtering selected.')
+    break
+}
+
 // If the last RC version is newer than the last stable, add it to the build list
 if (kversionsRC.last() > kversions.last()) {
   kversions.add(kversionsRC.last())
@@ -217,8 +282,7 @@ while ( kversions.size() != 0 || ongoingBuild.size() != 0 ) {
       }
     }
 
-    // Check for queued similar job since we only want to run latest
-    // As Mathieu Desnoyers requirement
+    // If a newer instance of this job is queued, abort to let it run
     similarJobQueued = Hudson.instance.queue.items.count{it.task.getFullDisplayName() == currentJobName}
     if ( similarJobQueued > 0 ) {
         // Abort since new build is queued
@@ -265,7 +329,9 @@ for (b in allBuilds) {
   def kernelStr = b.buildVariableResolver.resolve("kversion")
   println "${b.fullDisplayName} (${kernelStr}) completed with status ${b.result}"
   // Cleanup builds
-  b.delete()
+  try {
+    b.delete()
+  } catch (all) {}
 }
 
 // Mark this build failed if any child build has failed
This page took 0.025971 seconds and 4 git commands to generate.