From 28b10e79262a888b6662128cdde9c35f5f9ed38e Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Mon, 2 Mar 2020 11:46:37 -0500 Subject: [PATCH] jjb: lttng-modules: Add gerrit build job Signed-off-by: Michael Jeanson --- jobs/lttng-modules.yaml | 110 +++++++++++++++++++++---- scripts/lttng-modules/master-rt.groovy | 6 +- scripts/lttng-modules/master.groovy | 15 ++-- scripts/lttng-modules/param-build.sh | 12 ++- 4 files changed, 118 insertions(+), 25 deletions(-) diff --git a/jobs/lttng-modules.yaml b/jobs/lttng-modules.yaml index f905ea5..01a0434 100644 --- a/jobs/lttng-modules.yaml +++ b/jobs/lttng-modules.yaml @@ -3,10 +3,6 @@ - lttng-modules_build_parameters_defaults: <tng-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' @@ -23,6 +19,10 @@ 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' @@ -32,13 +32,41 @@ default: 'lttng-modules_PARAM_{parambuildtype}' description: 'The parametrized job to use for child builds.' +- lttng-modules_build_parameters_gerrit: <tng-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: <tng-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' @@ -55,6 +83,10 @@ 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' @@ -71,10 +103,6 @@ - lttng-modules_build_parameters_rt: <tng-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' @@ -91,6 +119,10 @@ 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' @@ -137,7 +169,7 @@ 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 @@ -228,6 +260,46 @@ <<: *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 @@ -431,9 +503,9 @@ 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: @@ -609,3 +681,11 @@ 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 diff --git a/scripts/lttng-modules/master-rt.groovy b/scripts/lttng-modules/master-rt.groovy index 5f634ed..6479f4d 100644 --- a/scripts/lttng-modules/master-rt.groovy +++ b/scripts/lttng-modules/master-rt.groovy @@ -158,7 +158,7 @@ class RTKVersion implements Comparable { // 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) diff --git a/scripts/lttng-modules/master.groovy b/scripts/lttng-modules/master.groovy index 29ff8ce..1526681 100644 --- a/scripts/lttng-modules/master.groovy +++ b/scripts/lttng-modules/master.groovy @@ -303,12 +303,13 @@ class UbuntuKVersion implements Comparable { // 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) diff --git a/scripts/lttng-modules/param-build.sh b/scripts/lttng-modules/param-build.sh index 0ce165a..e580dd4 100644 --- a/scripts/lttng-modules/param-build.sh +++ b/scripts/lttng-modules/param-build.sh @@ -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 -- 2.34.1