From 8abe9f8a36c7638231dc794afa127a7728b45c87 Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Fri, 22 May 2020 15:20:38 -0400 Subject: [PATCH] jjb: babeltrace: Add release jobs Signed-off-by: Michael Jeanson --- jobs/babeltrace.yaml | 49 +++++++++ scripts/babeltrace/release.sh | 181 ++++++++++++++++++++++++++++++++++ 2 files changed, 230 insertions(+) create mode 100644 scripts/babeltrace/release.sh diff --git a/jobs/babeltrace.yaml b/jobs/babeltrace.yaml index d37d4db..b694039 100644 --- a/jobs/babeltrace.yaml +++ b/jobs/babeltrace.yaml @@ -384,6 +384,51 @@ <<: *babeltrace_build_builders_win <<: *babeltrace_build_publishers_gerrit +- job-template: + name: babeltrace_{version}_release + defaults: babeltrace + node: 'amd64' + + triggers: + - pollscm: + cron: "@daily" + + scm: + - git: + url: git://github.com/{github_user}/{github_name}.git + browser: githubweb + browser-url: https://github.com/{github_user}/{github_name} + refspec: '+refs/tags/*:refs/remotes/origin/tags/*' + branches: + - '*/tags/{version}.*' + basedir: src/babeltrace + + builders: + - shell: + !include-raw-escape: scripts/babeltrace/release.sh + + publishers: + - tap: + results: 'tap/**/*.log' + fail-if-no-results: true + failed-tests-mark-build-as-failure: true + todo-is-failure: false + - warnings: + console-log-parsers: + - 'GNU Make + GNU C Compiler (gcc)' + total-thresholds: + unstable: + total-all: 0 + total-high: 0 + total-normal: 0 + total-low: 0 + - workspace-cleanup: + clean-if: + - failure: false + - archive: + artifacts: 'out/**,tap/**' + allow-empty: false + - job-template: name: dev_gerrit_babeltrace_pylint defaults: babeltrace @@ -676,6 +721,8 @@ arch: !!python/tuple [cygwin64] build: !!python/tuple [std] conf: !!python/tuple [std] + - 'babeltrace_{version}_release': + version: v1.5 - 'babeltrace_{version}_cppcheck' - 'babeltrace_{version}_scan-build' @@ -723,6 +770,8 @@ arch: !!python/tuple [cygwin64, msys2-mingw32, msys2-mingw64] build: !!python/tuple [std] conf: !!python/tuple [std] + - 'babeltrace_{version}_release': + version: v2.0 - 'babeltrace_{version}_cppcheck' - 'babeltrace_{version}_scan-build' - 'babeltrace_{version}_pylint' diff --git a/scripts/babeltrace/release.sh b/scripts/babeltrace/release.sh new file mode 100644 index 0000000..43db8db --- /dev/null +++ b/scripts/babeltrace/release.sh @@ -0,0 +1,181 @@ +#!/bin/bash -exu +# +# Copyright (C) 2015 Jonathan Rajotte-Julien +# Copyright (C) 2020 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 +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Version compare functions +vercomp () { + set +u + if [[ "$1" == "$2" ]]; then + return 0 + fi + local IFS=. + local i ver1=($1) ver2=($2) + # fill empty fields in ver1 with zeros + for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)); do + ver1[i]=0 + done + for ((i=0; i<${#ver1[@]}; i++)); do + if [[ -z ${ver2[i]} ]]; then + # fill empty fields in ver2 with zeros + ver2[i]=0 + fi + if ((10#${ver1[i]} > 10#${ver2[i]})); then + return 1 + fi + if ((10#${ver1[i]} < 10#${ver2[i]})); then + return 2 + fi + done + set -u + return 0 +} + +verlte() { + vercomp "$1" "$2"; local res="$?" + [ "$res" -eq "0" ] || [ "$res" -eq "2" ] +} + +verlt() { + vercomp "$1" "$2"; local res="$?" + [ "$res" -eq "2" ] +} + +vergte() { + vercomp "$1" "$2"; local res="$?" + [ "$res" -eq "0" ] || [ "$res" -eq "1" ] +} + +vergt() { + vercomp "$1" "$2"; local res="$?" + [ "$res" -eq "1" ] +} + +verne() { + vercomp "$1" "$2"; local res="$?" + [ "$res" -ne "0" ] +} + +# Required variables +WORKSPACE=${WORKSPACE:-} + + +SRCDIR="$WORKSPACE/src/babeltrace" +TMPDIR="$WORKSPACE/tmp" +OUTDIR="$WORKSPACE/out" +TAPDIR="$WORKSPACE/tap" + +failed_tests=0 + +# Create build and tmp directories +rm -rf "$OUTDIR" "$TMPDIR" "$TAPDIR" +mkdir -p "$OUTDIR" "$TMPDIR" "$TAPDIR" + +export TMPDIR + + +# Enter the source directory +cd "$SRCDIR" + +# Run bootstrap in the source directory prior to configure +./bootstrap + +# Get source version from configure script +eval "$(grep '^PACKAGE_VERSION=' ./configure)" +PACKAGE_VERSION=${PACKAGE_VERSION//\-pre*/} + +# Version specific configurations +if vergte "$PACKAGE_VERSION" "2.0"; then + BASENAME="babeltrace2" + CONF_OPTS=("--enable-python-bindings" "--enable-python-bindings-doc" "--enable-python-plugins") + + # Enable dev mode by default for BT 2.0 builds + #export BABELTRACE_DEBUG_MODE=1 + #export BABELTRACE_DEV_MODE=1 + #export BABELTRACE_MINIMAL_LOG_LEVEL=TRACE +else + BASENAME="babeltrace" + CONF_OPTS=("--enable-python-bindings") +fi + + +TARBALL_FILE="$BASENAME-$PACKAGE_VERSION.tar.bz2" + + +# Make sure the reported version matches the current git tag +GIT_TAG="$(git describe --exact-match --tags $(git log -n1 --pretty='%h')|| echo 'undefined')" + +if [ "v$PACKAGE_VERSION" != "$GIT_TAG" ]; then + echo "Git checkout is not tagged or doesn't match the reported version." + exit 1 +fi + +# Generate release tarball +./configure "${CONF_OPTS[@]}" +make dist +cp "./$TARBALL_FILE" "$OUTDIR/" + +## Do an in-tree test build +mkdir "$WORKSPACE/intree" +cd "$WORKSPACE/intree" || exit 1 + +tar xvf "$OUTDIR/$TARBALL_FILE" --strip 1 +./configure --prefix="$(mktemp -d)" "${CONF_OPTS[@]}" + +# BUILD! +make -j "$(nproc)" V=1 + +make install + +# Run tests, don't fail now, we want to run the archiving steps +make --keep-going check || failed_tests=1 + +# Copy tap logs for the jenkins tap parser before cleaning the build dir +rsync -a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*' tests/ "$TAPDIR/intree" + +# Clean the build directory +make clean + + +## Do an out-of-tree test build +mkdir "$WORKSPACE/oot" +mkdir "$WORKSPACE/oot/src" +mkdir "$WORKSPACE/oot/build" +cd "$WORKSPACE/oot/src" || exit 1 + +tar xvf "$OUTDIR/$TARBALL_FILE" --strip 1 +cd "$WORKSPACE/oot/build" || exit 1 +"$WORKSPACE/oot/src/configure" --prefix="$(mktemp -d)" "${CONF_OPTS[@]}" + +# BUILD! +make -j "$(nproc)" V=1 + +make install + +# Run tests, don't fail now, we want to run the archiving steps +make --keep-going check || failed_tests=1 + +# Copy tap logs for the jenkins tap parser before cleaning the build dir +rsync -a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*' tests/ "$TAPDIR/oot" + +# Clean the build directory +make clean + + +# Exit with failure if any of the tests failed +exit $failed_tests + +# EOF -- 2.34.1