From: Michael Jeanson Date: Wed, 8 Nov 2017 21:57:15 +0000 (-0500) Subject: jjb: Add version filter to lttng-modules RT X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=af3990edf0cfb000b21aca11ab1621ff0df98a07;p=lttng-ci.git jjb: Add version filter to lttng-modules RT Signed-off-by: Michael Jeanson --- diff --git a/jobs/lttng-modules.yaml b/jobs/lttng-modules.yaml index 0f12287..d124750 100644 --- a/jobs/lttng-modules.yaml +++ b/jobs/lttng-modules.yaml @@ -83,6 +83,14 @@ name: 'kverfloor' default: 'v2.6.36-rt0-rebase' 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: 'kgitrepo' default: 'git://git-mirror.internal.efficios.com/kernel/rt/linux-rt-devel.git' @@ -508,6 +516,8 @@ # RT normal builds - 'lttng-modules_{mversion}_build-rt': mversion: master + kverceil: '' + kverfilter: stable-head # Ubuntu normal builds - 'lttng-modules_{mversion}_{buildtype}-{uversion}': diff --git a/scripts/lttng-modules/master-rt.groovy b/scripts/lttng-modules/master-rt.groovy index cfcfe09..9d94be2 100644 --- a/scripts/lttng-modules/master-rt.groovy +++ b/scripts/lttng-modules/master-rt.groovy @@ -1,5 +1,5 @@ /** - * Copyright (C) 2016 - Michael Jeanson + * Copyright (C) 2016-2017 - Michael Jeanson * * 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,20 +23,44 @@ import org.eclipse.jgit.api.Git import org.eclipse.jgit.lib.Ref -class kVersion implements Comparable { +class InvalidKVersionException extends Exception { + public InvalidKVersionException(String message) { + super(message) + } +} + +class EmptyKVersionException extends Exception { + public EmptyKVersionException(String message) { + super(message) + } +} - Integer major = 0; - Integer majorB = 0; - Integer minor = 0; - Integer patch = 0; - Integer rt = 0; +class RTKVersion implements Comparable { - kVersion() {} + Integer major = 0 + Integer majorB = 0 + Integer minor = 0 + Integer patch = 0 + Integer rt = 0 - kVersion(version) { + RTKVersion() {} + + RTKVersion(version) { this.parse(version) } + static RTKVersion minKVersion() { + return new RTKVersion("v0.0.0-rt0-rebase") + } + + static RTKVersion maxKVersion() { + return new RTKVersion("v" + Integer.MAX_VALUE + ".0.0-rt0-rebase") + } + + static RTKVersion factory(version) { + return new RTKVersion(version) + } + def parse(version) { this.major = 0 this.majorB = 0 @@ -44,9 +68,13 @@ class kVersion implements Comparable { this.patch = 0 this.rt = 0 + if (!version) { + throw new EmptyKVersionException("Empty kernel version") + } + def match = version =~ /^v(\d+)\.(\d+)(\.(\d+))?(\.(\d+))?(-rt(\d+)-rebase)$/ if (!match) { - throw new Exception("Invalid kernel version: ${version}") + throw new InvalidKVersionException("Invalid kernel version: ${version}") } Integer offset = 0; @@ -72,21 +100,36 @@ class kVersion implements Comparable { this.rt = Integer.parseInt(match.group(8)) } - @Override int compareTo(kVersion o) { + // Return true if both version are of the same stable branch + Boolean isSameStable(RTKVersion o) { if (this.major != o.major) { - return Integer.compare(this.major, o.major); + return false } if (this.majorB != o.majorB) { - return Integer.compare(this.majorB, o.majorB); + return false } if (this.minor != o.minor) { - return Integer.compare(this.minor, o.minor); + return false + } + + return true + } + + @Override int compareTo(RTKVersion o) { + if (this.major != o.major) { + return Integer.compare(this.major, o.major) + } + if (this.majorB != o.majorB) { + return Integer.compare(this.majorB, o.majorB) + } + if (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.rt != o.rc) { - return Integer.compare(this.rt, o.rt); + if (this.rt != o.rt) { + return Integer.compare(this.rt, o.rt) } // Same version @@ -118,39 +161,98 @@ class kVersion implements Comparable { 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() + // 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(); // Get kernel versions to build def kversions = [] -for (ref in refs) { - def match = ref.getName() =~ /^refs\/tags\/(v[\d\.]+(-rt(\d+)-rebase))$/ +def matchStrs = [ + ~/^refs\/tags\/(v[\d\.]+(-rt(\d+)-rebase))$/, +] +def blacklist = [ + 'v4.11.8-rt5-rebase', + 'v4.11.9-rt6-rebase', + 'v4.11.9-rt7-rebase', + 'v4.11.12-rt8-rebase', + 'v4.11.12-rt9-rebase', + 'v4.11.12-rt10-rebase', + 'v4.11.12-rt11-rebase', + 'v4.11.12-rt12-rebase', + 'v4.11.12-rt13-rebase', +] + +def kversionFactory = new RTKVersion() + +// Parse kernel versions +def kverfloor = "" +try { + kverfloor = kversionFactory.factory(kverfloor_raw) +} catch (EmptyKVersionException e) { + kverfloor = kversionFactory.minKVersion() +} - if (match) { - def v = new kVersion(match.group(1)) +def kverceil = "" +try { + kverceil = kversionFactory.factory(kverceil_raw) +} catch (EmptyKVersionException e) { + kverceil = kversionFactory.maxKVersion() +} - if (v >= kverfloor) { - kversions.add(v) +// Build a sorted list of versions to build +for (ref in refs) { + for (matchStr in matchStrs) { + def match = ref.getName() =~ matchStr + if (match && !blacklist.contains(match.group(1))) { + def v = kversionFactory.factory(match.group(1)) + + if ((v >= kverfloor) && (v < kverceil)) { + kversions.add(v) + } } } } kversions.sort() -// Debug +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 +} + + println "Building the following kernel versions:" for (k in kversions) { println k @@ -165,6 +267,7 @@ def allBuilds = [] def ongoingBuild = [] def failedRuns = [] def isFailed = false +def similarJobQueued = 0; // Loop while we have kernel versions remaining or jobs running while ( kversions.size() != 0 || ongoingBuild.size() != 0 ) { @@ -188,7 +291,7 @@ while ( kversions.size() != 0 || ongoingBuild.size() != 0 ) { println "Waiting... Queued: " + kversions.size() + " Running: " + ongoingBuild.size() try { - Thread.sleep(5000) + Thread.sleep(10000) } catch(e) { if (e in InterruptedException) { build.setResult(hudson.model.Result.ABORTED) @@ -198,11 +301,9 @@ while ( kversions.size() != 0 || ongoingBuild.size() != 0 ) { } } - // Check for queued similar job since we only want to run latest - // as Mathieu Desnoyers requirement + // Abort job if a newer instance is queued similarJobQueued = Hudson.instance.queue.items.count{it.task.getFullDisplayName() == currentJobName} if ( similarJobQueued > 0 ) { - // Abort since new build is queued build.setResult(hudson.model.Result.ABORTED) throw new InterruptedException() }