|
|
36e8a3 |
From 5638e18196be1fabd9e78d4c506402bf700fe569 Mon Sep 17 00:00:00 2001
|
|
|
36e8a3 |
From: Frantisek Sumsal <fsumsal@redhat.com>
|
|
|
36e8a3 |
Date: Mon, 7 Jan 2019 15:49:45 +0100
|
|
|
36e8a3 |
Subject: [PATCH] travis: enable Travis CI on CentOS 7
|
|
|
36e8a3 |
|
|
|
36e8a3 |
(cherry picked from commit 2014cb51b6dfe1f7f0b98e62311398c2bf801c2b)
|
|
|
36e8a3 |
---
|
|
|
36e8a3 |
.travis.yml | 86 ++++++++++-----------------------------------
|
|
|
36e8a3 |
ci/travis-centos.sh | 69 ++++++++++++++++++++++++++++++++++++
|
|
|
36e8a3 |
ci/travis_wait.bash | 61 ++++++++++++++++++++++++++++++++
|
|
|
36e8a3 |
3 files changed, 149 insertions(+), 67 deletions(-)
|
|
|
36e8a3 |
create mode 100755 ci/travis-centos.sh
|
|
|
36e8a3 |
create mode 100644 ci/travis_wait.bash
|
|
|
36e8a3 |
|
|
|
36e8a3 |
diff --git a/.travis.yml b/.travis.yml
|
|
|
36e8a3 |
index d98003818..fc6388732 100644
|
|
|
36e8a3 |
--- a/.travis.yml
|
|
|
36e8a3 |
+++ b/.travis.yml
|
|
|
36e8a3 |
@@ -1,77 +1,29 @@
|
|
|
36e8a3 |
sudo: required
|
|
|
36e8a3 |
-
|
|
|
36e8a3 |
services:
|
|
|
36e8a3 |
- docker
|
|
|
36e8a3 |
|
|
|
36e8a3 |
-language: c
|
|
|
36e8a3 |
+env:
|
|
|
36e8a3 |
+ global:
|
|
|
36e8a3 |
+ - CI_ROOT="$TRAVIS_BUILD_DIR/ci/"
|
|
|
36e8a3 |
|
|
|
36e8a3 |
jobs:
|
|
|
36e8a3 |
include:
|
|
|
36e8a3 |
- - stage: coverity scan
|
|
|
36e8a3 |
- before_script:
|
|
|
36e8a3 |
- - sudo apt-get update
|
|
|
36e8a3 |
+ - stage: Build & test
|
|
|
36e8a3 |
+ name: CentOS 7
|
|
|
36e8a3 |
+ language: bash
|
|
|
36e8a3 |
+ env:
|
|
|
36e8a3 |
+ - CENTOS_RELEASE="centos7"
|
|
|
36e8a3 |
+ - CONT_NAME="systemd-centos-$CENTOS_RELEASE"
|
|
|
36e8a3 |
+ - DOCKER_EXEC="docker exec -ti $CONT_NAME"
|
|
|
36e8a3 |
+ before_install:
|
|
|
36e8a3 |
- sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce
|
|
|
36e8a3 |
- docker --version
|
|
|
36e8a3 |
- - env > .env
|
|
|
36e8a3 |
- env:
|
|
|
36e8a3 |
- - COVERITY_SCAN_PROJECT_NAME="$TRAVIS_REPO_SLUG"
|
|
|
36e8a3 |
- - COVERITY_SCAN_NOTIFICATION_EMAIL="${AUTHOR_EMAIL}"
|
|
|
36e8a3 |
- - COVERITY_SCAN_BRANCH_PATTERN="$TRAVIS_BRANCH"
|
|
|
36e8a3 |
- # Encrypted token for systemd/systemd Coverity Scan Analysis,
|
|
|
36e8a3 |
- # generated by "travis encrypt -r systemd/systemd COVERITY_SCAN_TOKEN=<TOKEN>"
|
|
|
36e8a3 |
- - secure: "lM0IVP2zOG5Ywk3YCbDCQL4WioyzzwtdtpZ+hKDy4BWCZDBJ/FVwIeBsXdMDvlTa3xi+GQ1b7kS2OmTfmG4aSlhU7isuH8SMq1Y4GR5AxfhkR+irUA1A1fntlvhbjIumDGW5wjs0Dt8KogMWS+ZD4eGE59lrVO/TrhMzIe1eHENVLFQJdNq+ZJXU8wxMfHf8lXk0xA8SJTid0XvZBNc4JN6pjJRA8LaOrMNhQYfygFmVQ598kwlu7gf5vbCKFPnIgJAxdIhz12XS9utGohV28IYj9d1DdUGUT+ar3OfADj3X8KFBP4Ymc02pcln3wVgdPtrDbFZh1R9jbmfdXGAH/6tTOJVn8aFySS2Vq9QiBiprWdPsAOLcWMNhnp0lMkASxs9/W26nU7Czo8VbAVWXM1w35plDpnDGR6lk/06dmOZpqu5p3AYr5xIKACIAdPDn0rNpnSWqC750WZ8ZWbHnKuZC5TWML7scVaPiEi7D7rbwqML2rdwx4ZoTZmCHiGByXCIWTfhf0JNQAix5WW3znl+BmDesumPgPj2mX+y6J1WYJrIz12m7qh7KhV/a1ODKM+I91A9rkOA/bPnmhmSSUR7CwgvZt1fC/VwBnaFFtAz9/70kN9Q8tDBXtXidExZwh1e3t5vDG72k3lXwNqpKRvdW3LOxK6lFvqEdMWVUJls="
|
|
|
36e8a3 |
+ install:
|
|
|
36e8a3 |
+ - $CI_ROOT/travis-centos.sh SETUP
|
|
|
36e8a3 |
script:
|
|
|
36e8a3 |
- # Copy content of CI_DIR into WORKDIR
|
|
|
36e8a3 |
- - find $CI_DIR -maxdepth 1 -type f -exec cp -t . {} +
|
|
|
36e8a3 |
- # Build container for current user
|
|
|
36e8a3 |
- - $CI_SCRIPT_DIR/build-docker-image.sh
|
|
|
36e8a3 |
-
|
|
|
36e8a3 |
- # For kernel version 4.8+
|
|
|
36e8a3 |
- - sudo sysctl vsyscall=emulate || true
|
|
|
36e8a3 |
- # Prepare environment for Coverity tool
|
|
|
36e8a3 |
- - |
|
|
|
36e8a3 |
- PLATFORM=`uname`
|
|
|
36e8a3 |
- export TOOL_BASE="/tmp/coverity-scan-analysis"
|
|
|
36e8a3 |
- export SCAN_URL="https://scan.coverity.com"
|
|
|
36e8a3 |
- export UPLOAD_URL="https://scan.coverity.com/builds"
|
|
|
36e8a3 |
- export TOOL_ARCHIVE="/tmp/cov-analysis-${PLATFORM}.tgz"
|
|
|
36e8a3 |
-
|
|
|
36e8a3 |
- # Get Coverity tool
|
|
|
36e8a3 |
- - $CI_TOOL_DIR/get-coverity.sh
|
|
|
36e8a3 |
- - TOOL_DIR="$(find $TOOL_BASE -type d -name 'cov-analysis*')"
|
|
|
36e8a3 |
-
|
|
|
36e8a3 |
- # Export env variables for Coverity scan
|
|
|
36e8a3 |
- - env | grep -E "TRAVIS|COV|TOOL|URL" > .cov-env
|
|
|
36e8a3 |
- - |
|
|
|
36e8a3 |
- docker run -dit --env-file .cov-env \
|
|
|
36e8a3 |
- -v ${TOOL_BASE}:${TOOL_BASE}:ro \
|
|
|
36e8a3 |
- --name travis_coverity_scan coverity-${TRAVIS_COMMIT}:latest bash
|
|
|
36e8a3 |
- # Make sure Coverity script is executable
|
|
|
36e8a3 |
- - docker cp tools/coverity.sh travis_coverity_scan:/usr/local/bin
|
|
|
36e8a3 |
- # Preconfigure with meson to prevent Coverity from capturing meson metadata
|
|
|
36e8a3 |
- # Set compiler flag to prevent emit failure
|
|
|
36e8a3 |
- - docker exec -it travis_coverity_scan sh -c "CFLAGS='-D_Float128=long\ double -D_Float64=double -D_Float64x=long\ double -D_Float32=float -D_Float32x=double' meson cov-build -Dman=false"
|
|
|
36e8a3 |
- # Run Coverity Analysis
|
|
|
36e8a3 |
- - docker exec -it travis_coverity_scan coverity.sh build
|
|
|
36e8a3 |
- - docker exec -it travis_coverity_scan coverity.sh upload
|
|
|
36e8a3 |
-
|
|
|
36e8a3 |
-# Specify the order of stages and conditions
|
|
|
36e8a3 |
-stages:
|
|
|
36e8a3 |
- - name: coverity scan
|
|
|
36e8a3 |
- if: type = cron
|
|
|
36e8a3 |
-
|
|
|
36e8a3 |
-env:
|
|
|
36e8a3 |
- global:
|
|
|
36e8a3 |
- - ADMIN_EMAIL=macermak@redhat.com
|
|
|
36e8a3 |
-
|
|
|
36e8a3 |
- - AUTHOR_NAME="$(git log -1 $TRAVIS_COMMIT --pretty=\"%aN\")"
|
|
|
36e8a3 |
- - AUTHOR_EMAIL="$(git log -1 $TRAVIS_COMMIT --pretty=\"%aE\")"
|
|
|
36e8a3 |
-
|
|
|
36e8a3 |
- - CI_DIR="$TRAVIS_BUILD_DIR/travis-ci"
|
|
|
36e8a3 |
- - CI_TOOL_DIR="$CI_DIR/tools"
|
|
|
36e8a3 |
- - CI_SCRIPT_DIR="$CI_DIR/scripts"
|
|
|
36e8a3 |
-
|
|
|
36e8a3 |
-notifications:
|
|
|
36e8a3 |
- email:
|
|
|
36e8a3 |
- recipients:
|
|
|
36e8a3 |
- - ${ADMIN_EMAIL}
|
|
|
36e8a3 |
+ - set -e
|
|
|
36e8a3 |
+ # Build systemd
|
|
|
36e8a3 |
+ - $CI_ROOT/travis-centos.sh RUN
|
|
|
36e8a3 |
+ - set +e
|
|
|
36e8a3 |
+ after_script:
|
|
|
36e8a3 |
+ - $CI_ROOT/travis-centos.sh CLEANUP
|
|
|
36e8a3 |
diff --git a/ci/travis-centos.sh b/ci/travis-centos.sh
|
|
|
36e8a3 |
new file mode 100755
|
|
|
36e8a3 |
index 000000000..60bbdf14c
|
|
|
36e8a3 |
--- /dev/null
|
|
|
36e8a3 |
+++ b/ci/travis-centos.sh
|
|
|
36e8a3 |
@@ -0,0 +1,69 @@
|
|
|
36e8a3 |
+#!/bin/bash
|
|
|
36e8a3 |
+
|
|
|
36e8a3 |
+# Run this script from the root of the systemd's git repository
|
|
|
36e8a3 |
+# or set REPO_ROOT to a correct path.
|
|
|
36e8a3 |
+#
|
|
|
36e8a3 |
+# Example execution on Fedora:
|
|
|
36e8a3 |
+# dnf install docker
|
|
|
36e8a3 |
+# systemctl start docker
|
|
|
36e8a3 |
+# export CONT_NAME="my-fancy-container"
|
|
|
36e8a3 |
+# ci/travis-centos.sh SETUP RUN CLEANUP
|
|
|
36e8a3 |
+
|
|
|
36e8a3 |
+PHASES=(${@:-SETUP RUN CLEANUP})
|
|
|
36e8a3 |
+CENTOS_RELEASE="${CENTOS_RELEASE:-latest}"
|
|
|
36e8a3 |
+CONT_NAME="${CONT_NAME:-centos-$CENTOS_RELEASE-$RANDOM}"
|
|
|
36e8a3 |
+DOCKER_EXEC="${DOCKER_EXEC:-docker exec -it $CONT_NAME}"
|
|
|
36e8a3 |
+DOCKER_RUN="${DOCKER_RUN:-docker run}"
|
|
|
36e8a3 |
+REPO_ROOT="${REPO_ROOT:-$PWD}"
|
|
|
36e8a3 |
+ADDITIONAL_DEPS=(yum-utils iputils hostname libasan libubsan clang llvm)
|
|
|
36e8a3 |
+
|
|
|
36e8a3 |
+function info() {
|
|
|
36e8a3 |
+ echo -e "\033[33;1m$1\033[0m"
|
|
|
36e8a3 |
+}
|
|
|
36e8a3 |
+
|
|
|
36e8a3 |
+set -e
|
|
|
36e8a3 |
+
|
|
|
36e8a3 |
+source "$(dirname $0)/travis_wait.bash"
|
|
|
36e8a3 |
+
|
|
|
36e8a3 |
+for phase in "${PHASES[@]}"; do
|
|
|
36e8a3 |
+ case $phase in
|
|
|
36e8a3 |
+ SETUP)
|
|
|
36e8a3 |
+ info "Setup phase"
|
|
|
36e8a3 |
+ info "Using Travis $CENTOS_RELEASE"
|
|
|
36e8a3 |
+ # Pull a Docker image and start a new container
|
|
|
36e8a3 |
+ docker pull centos:$CENTOS_RELEASE
|
|
|
36e8a3 |
+ info "Starting container $CONT_NAME"
|
|
|
36e8a3 |
+ $DOCKER_RUN -v $REPO_ROOT:/build:rw \
|
|
|
36e8a3 |
+ -w /build --privileged=true --name $CONT_NAME \
|
|
|
36e8a3 |
+ -dit --net=host centos:$CENTOS_RELEASE /sbin/init
|
|
|
36e8a3 |
+ # Beautiful workaround for Fedora's version of Docker
|
|
|
36e8a3 |
+ sleep 1
|
|
|
36e8a3 |
+ $DOCKER_EXEC yum makecache
|
|
|
36e8a3 |
+ # Install necessary build/test requirements
|
|
|
36e8a3 |
+ $DOCKER_EXEC yum -y --exclude selinux-policy\* upgrade
|
|
|
36e8a3 |
+ $DOCKER_EXEC yum -y install "${ADDITIONAL_DEPS[@]}"
|
|
|
36e8a3 |
+ $DOCKER_EXEC yum-builddep -y systemd
|
|
|
36e8a3 |
+ ;;
|
|
|
36e8a3 |
+ RUN)
|
|
|
36e8a3 |
+ info "Run phase"
|
|
|
36e8a3 |
+ # Build systemd
|
|
|
36e8a3 |
+ $DOCKER_EXEC ./autogen.sh
|
|
|
36e8a3 |
+ $DOCKER_EXEC ./configure --disable-timesyncd --disable-kdbus --disable-terminal \
|
|
|
36e8a3 |
+ --enable-gtk-doc --enable-compat-libs --disable-sysusers \
|
|
|
36e8a3 |
+ --disable-ldconfig --enable-lz4 --with-sysvinit-path=/etc/rc.d/init.d
|
|
|
36e8a3 |
+ $DOCKER_EXEC make
|
|
|
36e8a3 |
+ if ! $DOCKER_EXEC make check; then
|
|
|
36e8a3 |
+ $DOCKER_EXEC cat test-suite.log
|
|
|
36e8a3 |
+ exit 1
|
|
|
36e8a3 |
+ fi
|
|
|
36e8a3 |
+ ;;
|
|
|
36e8a3 |
+ CLEANUP)
|
|
|
36e8a3 |
+ info "Cleanup phase"
|
|
|
36e8a3 |
+ docker stop $CONT_NAME
|
|
|
36e8a3 |
+ docker rm -f $CONT_NAME
|
|
|
36e8a3 |
+ ;;
|
|
|
36e8a3 |
+ *)
|
|
|
36e8a3 |
+ echo >&2 "Unknown phase '$phase'"
|
|
|
36e8a3 |
+ exit 1
|
|
|
36e8a3 |
+ esac
|
|
|
36e8a3 |
+done
|
|
|
36e8a3 |
diff --git a/ci/travis_wait.bash b/ci/travis_wait.bash
|
|
|
36e8a3 |
new file mode 100644
|
|
|
36e8a3 |
index 000000000..acf6ad15e
|
|
|
36e8a3 |
--- /dev/null
|
|
|
36e8a3 |
+++ b/ci/travis_wait.bash
|
|
|
36e8a3 |
@@ -0,0 +1,61 @@
|
|
|
36e8a3 |
+# This was borrowed from https://github.com/travis-ci/travis-build/tree/master/lib/travis/build/bash
|
|
|
36e8a3 |
+# to get around https://github.com/travis-ci/travis-ci/issues/9979. It should probably be removed
|
|
|
36e8a3 |
+# as soon as Travis CI has started to provide an easy way to export the functions to bash scripts.
|
|
|
36e8a3 |
+
|
|
|
36e8a3 |
+travis_jigger() {
|
|
|
36e8a3 |
+ local cmd_pid="${1}"
|
|
|
36e8a3 |
+ shift
|
|
|
36e8a3 |
+ local timeout="${1}"
|
|
|
36e8a3 |
+ shift
|
|
|
36e8a3 |
+ local count=0
|
|
|
36e8a3 |
+
|
|
|
36e8a3 |
+ echo -e "\\n"
|
|
|
36e8a3 |
+
|
|
|
36e8a3 |
+ while [[ "${count}" -lt "${timeout}" ]]; do
|
|
|
36e8a3 |
+ count="$((count + 1))"
|
|
|
36e8a3 |
+ echo -ne "Still running (${count} of ${timeout}): ${*}\\r"
|
|
|
36e8a3 |
+ sleep 60
|
|
|
36e8a3 |
+ done
|
|
|
36e8a3 |
+
|
|
|
36e8a3 |
+ echo -e "\\n${ANSI_RED}Timeout (${timeout} minutes) reached. Terminating \"${*}\"${ANSI_RESET}\\n"
|
|
|
36e8a3 |
+ kill -9 "${cmd_pid}"
|
|
|
36e8a3 |
+}
|
|
|
36e8a3 |
+
|
|
|
36e8a3 |
+travis_wait() {
|
|
|
36e8a3 |
+ local timeout="${1}"
|
|
|
36e8a3 |
+
|
|
|
36e8a3 |
+ if [[ "${timeout}" =~ ^[0-9]+$ ]]; then
|
|
|
36e8a3 |
+ shift
|
|
|
36e8a3 |
+ else
|
|
|
36e8a3 |
+ timeout=20
|
|
|
36e8a3 |
+ fi
|
|
|
36e8a3 |
+
|
|
|
36e8a3 |
+ local cmd=("${@}")
|
|
|
36e8a3 |
+ local log_file="travis_wait_${$}.log"
|
|
|
36e8a3 |
+
|
|
|
36e8a3 |
+ "${cmd[@]}" &>"${log_file}" &
|
|
|
36e8a3 |
+ local cmd_pid="${!}"
|
|
|
36e8a3 |
+
|
|
|
36e8a3 |
+ travis_jigger "${!}" "${timeout}" "${cmd[@]}" &
|
|
|
36e8a3 |
+ local jigger_pid="${!}"
|
|
|
36e8a3 |
+ local result
|
|
|
36e8a3 |
+
|
|
|
36e8a3 |
+ {
|
|
|
36e8a3 |
+ set +e
|
|
|
36e8a3 |
+ wait "${cmd_pid}" 2>/dev/null
|
|
|
36e8a3 |
+ result="${?}"
|
|
|
36e8a3 |
+ ps -p"${jigger_pid}" &>/dev/null && kill "${jigger_pid}"
|
|
|
36e8a3 |
+ set -e
|
|
|
36e8a3 |
+ }
|
|
|
36e8a3 |
+
|
|
|
36e8a3 |
+ if [[ "${result}" -eq 0 ]]; then
|
|
|
36e8a3 |
+ echo -e "\\n${ANSI_GREEN}The command ${cmd[*]} exited with ${result}.${ANSI_RESET}"
|
|
|
36e8a3 |
+ else
|
|
|
36e8a3 |
+ echo -e "\\n${ANSI_RED}The command ${cmd[*]} exited with ${result}.${ANSI_RESET}"
|
|
|
36e8a3 |
+ fi
|
|
|
36e8a3 |
+
|
|
|
36e8a3 |
+ echo -e "\\n${ANSI_GREEN}Log:${ANSI_RESET}\\n"
|
|
|
36e8a3 |
+ cat "${log_file}"
|
|
|
36e8a3 |
+
|
|
|
36e8a3 |
+ return "${result}"
|
|
|
36e8a3 |
+}
|