]> git.ipfire.org Git - collecty.git/commitdiff
Add a Jenkinsfile
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 29 Sep 2025 16:01:23 +0000 (16:01 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 29 Sep 2025 16:12:50 +0000 (16:12 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Jenkinsfile [new file with mode: 0644]

diff --git a/Jenkinsfile b/Jenkinsfile
new file mode 100644 (file)
index 0000000..6b522ed
--- /dev/null
@@ -0,0 +1,273 @@
+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:forky", \
+                                                       "debian:trixie", \
+                                                       "fedora:43", \
+                                                       "fedora:42", \
+                                                       "ubuntu:25.10", \
+                                                       "ubuntu:25.04"
+                                       }
+
+                                       axis {
+                                               name "COMPILER"
+                                               values "gcc", "clang"
+                                       }
+                               }
+
+                               agent {
+                                       docker {
+                                               image "${DISTRO}"
+
+                                               // Run as root inside the containers to install dependencies
+                                               args "-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, etc.
+                                                               } else if (env.DISTRO.contains("fedora")) {
+                                                                       installBuildDepsRedHat(env.DISTRO, env.COMPILER)
+
+                                                               // Debian & Ubuntu
+                                                               } else if (env.DISTRO.contains("debian") || env.DISTRO.contains("ubuntu")) {
+                                                                       installBuildDepsDebian(env.DISTRO, env.COMPILER, "amd64")
+                                                               }
+                                                       }
+                                               }
+                                       }
+
+                                       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") {
+                                               // XXX Completely disabled, because we don't have any tests (yet)
+                                               when {
+                                                       expression { return false }
+                                               }
+
+                                               steps {
+                                                       script {
+                                                               sh "make check"
+                                                       }
+                                               }
+
+                                               post {
+                                                       always {
+                                                               // Copy test logs into a special directory
+                                                               sh """
+                                                                       mkdir -pv tests/${DISTRO}/${COMPILER}
+                                                                       find src 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"
+                                                       }
+                                               }
+                                       }
+                               }
+
+                               // Cleanup the workspace afterwards
+                               post {
+                                       always {
+                                               cleanWs()
+                                       }
+                               }
+                       }
+               }
+
+               stage("Coverage Tests") {
+                       parallel {
+                               /*
+                                       Run through Clang's Static Analyzer...
+                               */
+                               stage("Clang Static Analyzer") {
+                                       agent {
+                                               docker {
+                                                       image "debian:trixie"
+
+                                                       // Run as root inside the containers to install dependencies
+                                                       args "-u root"
+
+                                                       customWorkspace "${JOB_NAME}/${BUILD_ID}/clang-static-analyzer"
+                                               }
+                                       }
+
+                                       stages {
+                                               stage("Install Dependencies") {
+                                                       steps {
+                                                               script {
+                                                                       installBuildDepsDebian("trixie", "clang", "amd64")
+
+                                                                       // Install Clang Tools
+                                                                       sh "apt-get install -y clang-tools"
+                                                               }
+                                                       }
+                                               }
+
+                                               stage("Configure") {
+                                                       steps {
+                                                               sh "./autogen.sh"
+                                                               sh """
+                                                                       scan-build \
+                                                                       ./configure \
+                                                                               --prefix=/usr \
+                                                                               --enable-debug
+                                                               """
+                                                       }
+                                               }
+
+                                               stage("Build") {
+                                                       steps {
+                                                               sh "scan-build -o scan-build-output make -j\$(nproc)"
+                                                       }
+                                               }
+
+                                               stage("Publish Report") {
+                                                       steps {
+                                                               archiveArtifacts artifacts: "scan-build-output/**/*"
+                                                       }
+                                               }
+                                       }
+
+                                       // Cleanup the workspace afterwards
+                                       post {
+                                               always {
+                                                       cleanWs()
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+}
+
+// Installs everything we need on RHEL/Fedora/etc.
+def installBuildDepsRedHat(distro, compier) {
+       sh "dnf group install -y development-tools"
+
+       // Install our own build and runtime dependencies
+       sh """
+               dnf install -y \
+                       asciidoc \
+                       autoconf \
+                       automake \
+                       gawk \
+                       gettext \
+                       intltool \
+                       libtool \
+                       pkg-config \
+                       ${compiler} \
+                       \
+                       libatasmart-devel \
+                       liboping-devel \
+                       lm_sensors-devel \
+                       python3-devel \
+                       python3-pydbus \
+                       python3-rrdtool \
+                       rrdtool-devel \
+                       systemd-devel
+       """
+}
+
+// Installs everything we need on Arch Linux
+def installBuildDepsArchLinux(distro, compiler) {
+       sh "pacman -Syu --noconfirm"
+       sh """
+               pacman -Sy \
+                       --needed \
+                       --noconfirm \
+                       asciidoc \
+                       autoconf \
+                       automake \
+                       gettext \
+                       intltool \
+                       libtool \
+                       pkg-config \
+                       ${compiler} \
+                       \
+                       libatasmart \
+                       lm_sensors \
+                       python3 \
+                       python-pydbus \
+                       rrdtool \
+                       systemd
+       """
+}
+
+// Installs everything we need on Debian
+def installBuildDepsDebian(distro, compiler, arch) {
+       sh "apt-get update"
+       sh """
+               apt-get install -y \
+                       --no-install-recommends \
+                       asciidoc \
+                       autoconf \
+                       automake \
+                       autopoint \
+                       build-essential \
+                       intltool \
+                       libtool \
+                       pkg-config \
+                       ${compiler} \
+                       \
+                       libatasmart-dev \
+                       liboping-dev \
+                       libpython3-dev \
+                       libsensors-dev \
+                       librrd-dev \
+                       libsystemd-dev \
+                       python3-pydbus \
+                       python3-rrdtool
+       """
+}