diff options
author | Evgeny Vereshchagin <evvers@ya.ru> | 2018-11-07 05:11:02 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-07 05:11:02 +0300 |
commit | bd2125031ba9f3e0b78bf434b60f9488b012bba0 (patch) | |
tree | 7cc4534a5691abcbeaa051a104a49a5ba58a9f90 | |
parent | 5176b272ea459e1753f007e0534dba5eceec42b5 (diff) | |
parent | 9608a5944990f550e3e24d4472b941e0c2e8a8c0 (diff) | |
download | systemd-bd2125031ba9f3e0b78bf434b60f9488b012bba0.tar.gz systemd-bd2125031ba9f3e0b78bf434b60f9488b012bba0.tar.bz2 systemd-bd2125031ba9f3e0b78bf434b60f9488b012bba0.zip |
Merge pull request #10644 from mrc0mmand/travis-fix
Fix & re-enable Travis CI
-rw-r--r-- | .travis.yml | 126 | ||||
-rwxr-xr-x | travis-ci/managers/fedora.sh | 63 |
2 files changed, 127 insertions, 62 deletions
diff --git a/.travis.yml b/.travis.yml index d980038181..499e9eeb91 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,77 +1,79 @@ sudo: required - services: - docker -language: c +env: + global: + - AUTHOR_EMAIL="$(git log -1 $TRAVIS_COMMIT --pretty=\"%aE\")" + - CI_MANAGERS="$TRAVIS_BUILD_DIR/travis-ci/managers" + - CI_TOOLS="$TRAVIS_BUILD_DIR/travis-ci/tools" + - REPO_ROOT="$TRAVIS_BUILD_DIR" + +stages: + # Run Coverity periodically instead of for each commit/PR + - name: Coverity + if: type = cron jobs: include: - - stage: coverity scan - before_script: - - sudo apt-get update + - stage: Build & test + name: Fedora Rawhide + language: bash + env: + - FEDORA_RELEASE="rawhide" + - CONT_NAME="systemd-fedora-$FEDORA_RELEASE" + - DOCKER_EXEC="docker exec -ti $CONT_NAME" + before_install: - sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce - docker --version - - env > .env + install: + - $CI_MANAGERS/fedora.sh SETUP + script: + - set -e + # Build systemd + - $CI_MANAGERS/fedora.sh RUN + - set +e + after_script: + - $CI_MANAGERS/fedora.sh CLEANUP + + - stage: Coverity + language: bash env: + - FEDORA_RELEASE="latest" + - CONT_NAME="coverity-fedora-$FEDORA_RELEASE" + - DOCKER_EXEC="docker exec -ti $CONT_NAME" + - DOCKER_RUN="docker run --env-file .cov-env" + # Coverity env variables + - PLATFORM="$(uname)" + - TOOL_BASE="/var/tmp/coverity-scan-analysis" + - TOOL_ARCHIVE="/var/tmp/cov-analysis-$PLATFORM.tgz + - SCAN_URL="https://scan.coverity.com" + - UPLOAD_URL="https://scan.coverity.com/builds" - COVERITY_SCAN_PROJECT_NAME="$TRAVIS_REPO_SLUG" - COVERITY_SCAN_NOTIFICATION_EMAIL="${AUTHOR_EMAIL}" - COVERITY_SCAN_BRANCH_PATTERN="$TRAVIS_BRANCH" - # Encrypted token for systemd/systemd Coverity Scan Analysis, - # generated by "travis encrypt -r systemd/systemd COVERITY_SCAN_TOKEN=<TOKEN>" - - secure: "lM0IVP2zOG5Ywk3YCbDCQL4WioyzzwtdtpZ+hKDy4BWCZDBJ/FVwIeBsXdMDvlTa3xi+GQ1b7kS2OmTfmG4aSlhU7isuH8SMq1Y4GR5AxfhkR+irUA1A1fntlvhbjIumDGW5wjs0Dt8KogMWS+ZD4eGE59lrVO/TrhMzIe1eHENVLFQJdNq+ZJXU8wxMfHf8lXk0xA8SJTid0XvZBNc4JN6pjJRA8LaOrMNhQYfygFmVQ598kwlu7gf5vbCKFPnIgJAxdIhz12XS9utGohV28IYj9d1DdUGUT+ar3OfADj3X8KFBP4Ymc02pcln3wVgdPtrDbFZh1R9jbmfdXGAH/6tTOJVn8aFySS2Vq9QiBiprWdPsAOLcWMNhnp0lMkASxs9/W26nU7Czo8VbAVWXM1w35plDpnDGR6lk/06dmOZpqu5p3AYr5xIKACIAdPDn0rNpnSWqC750WZ8ZWbHnKuZC5TWML7scVaPiEi7D7rbwqML2rdwx4ZoTZmCHiGByXCIWTfhf0JNQAix5WW3znl+BmDesumPgPj2mX+y6J1WYJrIz12m7qh7KhV/a1ODKM+I91A9rkOA/bPnmhmSSUR7CwgvZt1fC/VwBnaFFtAz9/70kN9Q8tDBXtXidExZwh1e3t5vDG72k3lXwNqpKRvdW3LOxK6lFvqEdMWVUJls=" - script: - # Copy content of CI_DIR into WORKDIR - - find $CI_DIR -maxdepth 1 -type f -exec cp -t . {} + - # Build container for current user - - $CI_SCRIPT_DIR/build-docker-image.sh - - # For kernel version 4.8+ - - sudo sysctl vsyscall=emulate || true - # Prepare environment for Coverity tool - - | - PLATFORM=`uname` - export TOOL_BASE="/tmp/coverity-scan-analysis" - export SCAN_URL="https://scan.coverity.com" - export UPLOAD_URL="https://scan.coverity.com/builds" - export TOOL_ARCHIVE="/tmp/cov-analysis-${PLATFORM}.tgz" - - # Get Coverity tool - - $CI_TOOL_DIR/get-coverity.sh - - TOOL_DIR="$(find $TOOL_BASE -type d -name 'cov-analysis*')" - - # Export env variables for Coverity scan + # Encrypted COVERITY_SCAN_TOKEN env variable + # Generated using `travis encrypt -r systemd/systemd COVERITY_SCAN_TOKEN=xxxx` + - secure: "jKSz+Y1Mv8xMpQHh7g5lzW7E6HQGndFz/vKDJQ1CVShwFoyjV3Zu+MFS3UYKlh1236zL0Z4dvsYFx/b3Hq8nxZWCrWeZs2NdXgy/wh8LZhxwzcGYigp3sIA/cYdP5rDjFJO0MasNkl25/rml8+eZWz+8/xQic98UQHjSco/EOWtssoRcg0J0c4eDM7bGLfIQWE73NNY1Q1UtWjKmx1kekVrM8dPmHXJ9aERka7bmcbJAcKd6vabs6DQ5AfWccUPIn/EsRYqIJTRxJrFYU6XizANZ1a7Vwk/DWHZUEn2msxcZw5BbAMDTMx0TbfrNkKSHMHuvQUCu6KCBAq414i+LgkMfmQ2SWwKiIUsud1kxXX3ZPl9bxDv1HkvVdcniC/EM7lNEEVwm4meOnjuhI2lhOyOjmP3FTSlMHGP7xlK8DS2k9fqL58vn0BaSjwWgd+2+HuL2+nJmxcK1eLGzKqaostFxrk2Xs2vPZkUdV2nWY/asUrcWHml6YlWDn2eP83pfwxHYsMiEHY/rTKvxeVY+iirO/AphoO+eaYu7LvjKZU1Yx5Z4u/SnGWAiCH0yhMis0bWmgi7SCbw+sDd2uya+aoiLIGiB2ChW7hXHXCue/dif6/gLU7b+L8R00pQwnWdvKUPoIJCmZJYCluTeib4jpW+EmARB2+nR8wms2K9FGKM=" + before_install: + - sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce + - docker --version + install: + # Install Coverity on the host + - $CI_TOOLS/get-coverity.sh + # Export necessary env variables for Coverity - env | grep -E "TRAVIS|COV|TOOL|URL" > .cov-env - - | - docker run -dit --env-file .cov-env \ - -v ${TOOL_BASE}:${TOOL_BASE}:ro \ - --name travis_coverity_scan coverity-${TRAVIS_COMMIT}:latest bash - # Make sure Coverity script is executable - - docker cp tools/coverity.sh travis_coverity_scan:/usr/local/bin - # Preconfigure with meson to prevent Coverity from capturing meson metadata - # Set compiler flag to prevent emit failure - - 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" - # Run Coverity Analysis - - docker exec -it travis_coverity_scan coverity.sh build - - docker exec -it travis_coverity_scan coverity.sh upload - -# Specify the order of stages and conditions -stages: - - name: coverity scan - if: type = cron - -env: - global: - - ADMIN_EMAIL=macermak@redhat.com - - - AUTHOR_NAME="$(git log -1 $TRAVIS_COMMIT --pretty=\"%aN\")" - - AUTHOR_EMAIL="$(git log -1 $TRAVIS_COMMIT --pretty=\"%aE\")" - - - CI_DIR="$TRAVIS_BUILD_DIR/travis-ci" - - CI_TOOL_DIR="$CI_DIR/tools" - - CI_SCRIPT_DIR="$CI_DIR/scripts" + # Pull a Docker image and start a new container + - $CI_MANAGERS/fedora.sh SETUP + script: + - set -e + # Preconfigure with meson to prevent Coverity from capturing meson metadata + # Set compiler flag to prevent emit failure + - $DOCKER_EXEC 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" + # Run Coverity + - $DOCKER_EXEC tools/coverity.sh build + - $DOCKER_EXEC tools/coverity.sh upload -notifications: - email: - recipients: - - ${ADMIN_EMAIL} + - set +e + after_script: + - $CI_MANAGERS/fedora.sh CLEANUP diff --git a/travis-ci/managers/fedora.sh b/travis-ci/managers/fedora.sh new file mode 100755 index 0000000000..ab5ad154e0 --- /dev/null +++ b/travis-ci/managers/fedora.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +# Run this script from the root of the systemd's git repository +# or set REPO_ROOT to a correct path. +# +# Example execution on Fedora: +# dnf install docker +# systemctl start docker +# export CONT_NAME="my-fancy-container" +# travis-ci/managers/fedora.sh SETUP RUN CLEANUP + +PHASES=(${@:-SETUP RUN CLEANUP}) +FEDORA_RELEASE="${FEDORA_RELEASE:-rawhide}" +CONT_NAME="${CONT_NAME:-fedora-$FEDORA_RELEASE-$RANDOM}" +DOCKER_EXEC="${DOCKER_EXEC:-docker exec -it $CONT_NAME}" +DOCKER_RUN="${DOCKER_RUN:-docker run}" +REPO_ROOT="${REPO_ROOT:-$PWD}" +ADDITIONAL_DEPS=(dnf-plugins-core python2 iputils hostname libasan) + +function info() { + echo -e "\033[33;1m$1\033[0m" +} + +set -e + +for phase in "${PHASES[@]}"; do + case $phase in + SETUP) + info "Setup phase" + info "Using Fedora $FEDORA_RELEASE" + # Pull a Docker image and start a new container + docker pull fedora:$FEDORA_RELEASE + info "Starting container $CONT_NAME" + $DOCKER_RUN -v $REPO_ROOT:/build:rw \ + -w /build --privileged=true --name $CONT_NAME \ + -dit --net=host fedora:$FEDORA_RELEASE /sbin/init + # Beautiful workaround for Fedora's version of Docker + sleep 1 + $DOCKER_EXEC dnf makecache + # Install necessary build/test requirements + $DOCKER_EXEC dnf -y --exclude selinux-policy\* upgrade + $DOCKER_EXEC dnf -y install "${ADDITIONAL_DEPS[@]}" + $DOCKER_EXEC dnf -y builddep systemd + ;; + RUN) + info "Run phase" + # Build systemd + $DOCKER_EXEC meson build + $DOCKER_EXEC ninja -C build + $DOCKER_EXEC sh -c "printf '#!/bin/sh\necho The test is failing for unknown reason, skipping; exit 77' >/build/build/test-capability" + # Run 'make check' + $DOCKER_EXEC ninja -C build test + ;; + CLEANUP) + info "Cleanup phase" + docker stop $CONT_NAME + docker rm -f $CONT_NAME + ;; + *) + echo >&2 "Unknown phase '$phase'" + exit 1 + esac +done |