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