From: Michael Tremer Date: Thu, 28 Nov 2024 11:32:14 +0000 (+0000) Subject: jenkins: Run build and tests before running coverage tests X-Git-Tag: 0.9.30~781 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=691c5ebdd058a071ceac0a93aaffb64c7d2006e6;p=pakfire.git jenkins: Run build and tests before running coverage tests Signed-off-by: Michael Tremer --- diff --git a/Jenkinsfile b/Jenkinsfile index 1ddd4e387..2074de4cb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,6 +2,117 @@ pipeline { agent none stages { + /* + Run the build and test suite on various distributions... + */ + stage("Run Tests on Multiple Distributions") { + matrix { + axes { + axis { + name "DISTRO" + values \ + "archlinux:base-devel", \ + "debian:trixie", \ + "debian:bookworm-backports", \ + "fedora:latest", \ + "fedora:rawhide", \ + "ubuntu:24.10", \ + "ubuntu:24.04" + } + + axis { + name "COMPILER" + values "gcc", "clang" + } + } + + agent { + docker { + image "${DISTRO}" + + // Run as root inside the containers to install dependencies + args "--privileged -u root" + + customWorkspace "${JOB_NAME}/${BUILD_ID}/${env.DISTRO.replace(":", "-")}/${env.COMPILER}" + } + } + + stages { + stage("Install Dependencies") { + steps { + script { + // Arch Linux + if (env.DISTRO.contains("archlinux")) { + installBuildDepsArchLinux(env.DISTRO, env.COMPILER) + + // Fedora, Alma Linux, etc. + } else if (env.DISTRO.contains("fedora") || env.DISTRO.contains("almalinux")) { + installBuildDepsRedHat(env.DISTRO, env.COMPILER) + + // Debian & Ubuntu + } else if (env.DISTRO.contains("debian") || env.DISTRO.contains("ubuntu")) { + installBuildDepsDebian(env.DISTRO, env.COMPILER) + } + } + } + } + + stage("Configure") { + steps { + // Run autogen + sh "./autogen.sh" + + // Run ./configure... + sh "CC=${env.COMPILER} ./configure --prefix=/usr --enable-debug" + } + + post { + failure { + archiveArtifacts artifacts: "config.log", + allowEmptyArchive: true + + echo "config.log has been archived" + } + } + } + + stage("Build") { + steps { + sh "make" + } + } + + stage("Check") { + steps { + script { + try { + sh "make check" + } catch (Exception e) { + unstable("Failed on ${env.DISTRO} with ${env.COMPILER}...") + } + } + } + + post { + always { + // Copy test logs into a special directory + sh """ + mkdir -pv tests/${DISTRO}/${COMPILER} + find tests -name "*.log" | xargs --no-run-if-empty \ + cp --verbose --parents --target-directory=tests/${DISTRO}/${COMPILER}/ + """ + + // Archive the logs only if the stage fails + archiveArtifacts artifacts: "tests/${DISTRO}/${COMPILER}/**/*" + + echo "The test logs have been archived" + } + } + } + } + } + } + stage("Coverage Tests") { parallel { /* @@ -128,117 +239,6 @@ pipeline { } } - /* - Run the build and test suite on various distributions... - */ - stage("Run Tests on Multiple Distributions") { - matrix { - axes { - axis { - name "DISTRO" - values \ - "archlinux:base-devel", \ - "debian:trixie", \ - "debian:bookworm-backports", \ - "fedora:latest", \ - "fedora:rawhide", \ - "ubuntu:24.10", \ - "ubuntu:24.04" - } - - axis { - name "COMPILER" - values "gcc", "clang" - } - } - - agent { - docker { - image "${DISTRO}" - - // Run as root inside the containers to install dependencies - args "--privileged -u root" - - customWorkspace "${JOB_NAME}/${BUILD_ID}/${env.DISTRO.replace(":", "-")}/${env.COMPILER}" - } - } - - stages { - stage("Install Dependencies") { - steps { - script { - // Arch Linux - if (env.DISTRO.contains("archlinux")) { - installBuildDepsArchLinux(env.DISTRO, env.COMPILER) - - // Fedora, Alma Linux, etc. - } else if (env.DISTRO.contains("fedora") || env.DISTRO.contains("almalinux")) { - installBuildDepsRedHat(env.DISTRO, env.COMPILER) - - // Debian & Ubuntu - } else if (env.DISTRO.contains("debian") || env.DISTRO.contains("ubuntu")) { - installBuildDepsDebian(env.DISTRO, env.COMPILER) - } - } - } - } - - stage("Configure") { - steps { - // Run autogen - sh "./autogen.sh" - - // Run ./configure... - sh "CC=${env.COMPILER} ./configure --prefix=/usr --enable-debug" - } - - post { - failure { - archiveArtifacts artifacts: "config.log", - allowEmptyArchive: true - - echo "config.log has been archived" - } - } - } - - stage("Build") { - steps { - sh "make" - } - } - - stage("Check") { - steps { - script { - try { - sh "make check" - } catch (Exception e) { - unstable("Failed on ${env.DISTRO} with ${env.COMPILER}...") - } - } - } - - post { - always { - // Copy test logs into a special directory - sh """ - mkdir -pv tests/${DISTRO}/${COMPILER} - find tests -name "*.log" | xargs --no-run-if-empty \ - cp --verbose --parents --target-directory=tests/${DISTRO}/${COMPILER}/ - """ - - // Archive the logs only if the stage fails - archiveArtifacts artifacts: "tests/${DISTRO}/${COMPILER}/**/*" - - echo "The test logs have been archived" - } - } - } - } - } - } - stage("Debian Packages") { stages { stage("Build Debian Packages") {