dcavalca / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone
Blob Blame History Raw
From 88ac207cc619935c64923e6f8fdef324a5b733d8 Mon Sep 17 00:00:00 2001
From: Frantisek Sumsal <frantisek@sumsal.cz>
Date: Fri, 15 Jan 2021 15:13:53 +0100
Subject: [PATCH] ci: move jobs from Travis CI to GH Actions

The OSS version of Travis CI is going to be merged with the commercial
one soon, essentially dropping the free tier, so let's move the CI jobs
to GitHub Actions to keep them up.

rhel-only
Related: #1871827
---
 .../workflows/unit_tests.sh                   | 28 +++----
 .github/workflows/unit_tests.yml              | 28 +++++++
 .travis.yml                                   | 48 ------------
 ci/travis-centos-rhel7.sh                     | 73 -------------------
 ci/travis_wait.bash                           | 61 ----------------
 5 files changed, 37 insertions(+), 201 deletions(-)
 rename ci/travis-centos-rhel8.sh => .github/workflows/unit_tests.sh (82%)
 create mode 100644 .github/workflows/unit_tests.yml
 delete mode 100644 .travis.yml
 delete mode 100755 ci/travis-centos-rhel7.sh
 delete mode 100644 ci/travis_wait.bash

diff --git a/ci/travis-centos-rhel8.sh b/.github/workflows/unit_tests.sh
similarity index 82%
rename from ci/travis-centos-rhel8.sh
rename to .github/workflows/unit_tests.sh
index ffe5813b1a..ea4f7e7592 100755
--- a/ci/travis-centos-rhel8.sh
+++ b/.github/workflows/unit_tests.sh
@@ -1,18 +1,9 @@
 #!/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"
-# ci/travis-centos.sh SETUP RUN CLEANUP
-
 PHASES=(${@:-SETUP RUN CLEANUP})
 CENTOS_RELEASE="${CENTOS_RELEASE:-latest}"
 CONT_NAME="${CONT_NAME:-centos-$CENTOS_RELEASE-$RANDOM}"
-DOCKER_EXEC="${DOCKER_EXEC:-docker exec -it $CONT_NAME}"
+DOCKER_EXEC="${DOCKER_EXEC:-docker exec $CONT_NAME}"
 DOCKER_RUN="${DOCKER_RUN:-docker run}"
 REPO_ROOT="${REPO_ROOT:-$PWD}"
 ADDITIONAL_DEPS=(libasan libubsan net-tools strace nc e2fsprogs quota dnsmasq diffutils)
@@ -71,9 +62,7 @@ function info() {
     echo -e "\033[33;1m$1\033[0m"
 }
 
-set -e
-
-source "$(dirname $0)/travis_wait.bash"
+set -ex
 
 for phase in "${PHASES[@]}"; do
     case $phase in
@@ -86,6 +75,7 @@ for phase in "${PHASES[@]}"; do
             $DOCKER_RUN -v $REPO_ROOT:/build:rw \
                         -w /build --privileged=true --name $CONT_NAME \
                         -dit --net=host quay.io/centos/centos:$CENTOS_RELEASE /sbin/init
+
             # Beautiful workaround for Fedora's version of Docker
             sleep 1
             $DOCKER_EXEC dnf makecache
@@ -97,10 +87,10 @@ for phase in "${PHASES[@]}"; do
             # Install systemd's build dependencies
             $DOCKER_EXEC dnf -q -y --enablerepo "powertools" builddep systemd
             ;;
-        RUN)
+        RUN|RUN_GCC)
             info "Run phase"
             # Build systemd
-            docker exec -it -e CFLAGS='-g -O0 -ftrapv' $CONT_NAME meson build -Dtests=unsafe -Dslow-tests=true "${CONFIGURE_OPTS[@]}"
+            docker exec -e CFLAGS='-g -O0 -ftrapv' $CONT_NAME meson build -Dtests=unsafe -Dslow-tests=true "${CONFIGURE_OPTS[@]}"
             $DOCKER_EXEC ninja -v -C build
             # Let's install the new systemd and "reboot" the container to avoid
             # unexpected fails due to incompatibilities with older systemd
@@ -108,16 +98,16 @@ for phase in "${PHASES[@]}"; do
             docker restart $CONT_NAME
             $DOCKER_EXEC ninja -C build test
             ;;
-        RUN_ASAN|RUN_CLANG_ASAN)
+        RUN_ASAN|RUN_GCC_ASAN|RUN_CLANG_ASAN)
             if [[ "$phase" = "RUN_CLANG_ASAN" ]]; then
                 ENV_VARS="-e CC=clang -e CXX=clang++"
                 MESON_ARGS="-Db_lundef=false" # See https://github.com/mesonbuild/meson/issues/764
             fi
-            docker exec $ENV_VARS -it $CONT_NAME meson build --werror -Dtests=unsafe -Db_sanitize=address,undefined $MESON_ARGS "${CONFIGURE_OPTS[@]}"
-            docker exec -it $CONT_NAME ninja -v -C build
+            docker exec $ENV_VARS $CONT_NAME meson build --werror -Dtests=unsafe -Db_sanitize=address,undefined $MESON_ARGS "${CONFIGURE_OPTS[@]}"
+            docker exec $CONT_NAME ninja -v -C build
 
             # Never remove halt_on_error from UBSAN_OPTIONS. See https://github.com/systemd/systemd/commit/2614d83aa06592aedb.
-            travis_wait docker exec --interactive=false \
+            docker exec --interactive=false \
                 -e UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1 \
                 -e ASAN_OPTIONS=strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1 \
                 -e "TRAVIS=$TRAVIS" \
diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml
new file mode 100644
index 0000000000..15f5127a75
--- /dev/null
+++ b/.github/workflows/unit_tests.yml
@@ -0,0 +1,28 @@
+---
+# vi: ts=2 sw=2 et:
+#
+name: Unit tests
+on:
+  pull_request:
+    branches:
+      - master
+
+jobs:
+  build:
+    runs-on: ubuntu-20.04
+    env:
+      CENTOS_RELEASE: "centos8"
+      CONT_NAME:      "systemd-centos8-ci"
+    strategy:
+      fail-fast: false
+      matrix:
+        run_phase: [GCC, GCC_ASAN]
+    steps:
+      - name: Repository checkout
+        uses: actions/checkout@v1
+      - name: Install build dependencies
+        run: sudo -E .github/workflows/unit_tests.sh SETUP
+      - name: Build & test (${{ matrix.run_phase }})
+        run: sudo -E .github/workflows/unit_tests.sh RUN_${{ matrix.run_phase }}
+      - name: Cleanup
+        run: sudo -E .github/workflows/unit_tests.sh CLEANUP
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 70c60cf24e..0000000000
--- a/.travis.yml
+++ /dev/null
@@ -1,48 +0,0 @@
-sudo: required
-dist: xenial
-services:
-    - docker
-
-env:
-    global:
-        - CI_ROOT="$TRAVIS_BUILD_DIR/ci/"
-
-jobs:
-    include:
-        - name: CentOS 8
-          language: bash
-          env:
-              - CENTOS_RELEASE="centos8"
-              - CONT_NAME="systemd-centos-$CENTOS_RELEASE"
-              - DOCKER_EXEC="docker exec -ti $CONT_NAME"
-          before_install:
-              - sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce
-              - docker --version
-          install:
-              - $CI_ROOT/travis-centos-rhel8.sh SETUP
-          script:
-              - set -e
-              # Build systemd
-              - $CI_ROOT/travis-centos-rhel8.sh RUN
-              - set +e
-          after_script:
-              - $CI_ROOT/travis-centos-rhel8.sh CLEANUP
-
-        - name: CentOS 8 (ASan+UBSan)
-          language: bash
-          env:
-              - CENTOS_RELEASE="centos8"
-              - CONT_NAME="systemd-centos-$CENTOS_RELEASE"
-              - DOCKER_EXEC="docker exec -ti $CONT_NAME"
-          before_install:
-              - sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce
-              - docker --version
-          install:
-              - $CI_ROOT/travis-centos-rhel8.sh SETUP
-          script:
-              - set -e
-              # Build systemd
-              - $CI_ROOT/travis-centos-rhel8.sh RUN_ASAN
-              - set +e
-          after_script:
-              - $CI_ROOT/travis-centos-rhel8.sh CLEANUP
diff --git a/ci/travis-centos-rhel7.sh b/ci/travis-centos-rhel7.sh
deleted file mode 100755
index 73416798ed..0000000000
--- a/ci/travis-centos-rhel7.sh
+++ /dev/null
@@ -1,73 +0,0 @@
-#!/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"
-# ci/travis-centos.sh SETUP RUN CLEANUP
-
-PHASES=(${@:-SETUP RUN CLEANUP})
-CENTOS_RELEASE="${CENTOS_RELEASE:-latest}"
-CONT_NAME="${CONT_NAME:-centos-$CENTOS_RELEASE-$RANDOM}"
-DOCKER_EXEC="${DOCKER_EXEC:-docker exec -it $CONT_NAME}"
-DOCKER_RUN="${DOCKER_RUN:-docker run}"
-REPO_ROOT="${REPO_ROOT:-$PWD}"
-ADDITIONAL_DEPS=(yum-utils iputils hostname libasan libubsan clang llvm)
-
-function info() {
-    echo -e "\033[33;1m$1\033[0m"
-}
-
-set -e
-
-source "$(dirname $0)/travis_wait.bash"
-
-for phase in "${PHASES[@]}"; do
-    case $phase in
-        SETUP)
-            info "Setup phase"
-            info "Using Travis $CENTOS_RELEASE"
-            # Pull a Docker image and start a new container
-            docker pull centos:$CENTOS_RELEASE
-            info "Starting container $CONT_NAME"
-            $DOCKER_RUN -v $REPO_ROOT:/build:rw \
-                        -w /build --privileged=true --name $CONT_NAME \
-                        -dit --net=host centos:$CENTOS_RELEASE /sbin/init
-            # Beautiful workaround for Fedora's version of Docker
-            sleep 1
-            $DOCKER_EXEC yum makecache
-            # Install necessary build/test requirements
-            $DOCKER_EXEC yum -y upgrade
-            $DOCKER_EXEC yum -y install "${ADDITIONAL_DEPS[@]}"
-            $DOCKER_EXEC yum-builddep -y systemd
-            ;;
-        RUN)
-            info "Run phase"
-            # Build systemd
-            $DOCKER_EXEC ./autogen.sh
-            $DOCKER_EXEC ./configure --disable-timesyncd --disable-kdbus --disable-terminal \
-                                     --enable-gtk-doc --enable-compat-libs --disable-sysusers \
-                                     --disable-ldconfig --enable-lz4 --with-sysvinit-path=/etc/rc.d/init.d
-            $DOCKER_EXEC make
-            # Let's install the new systemd and "reboot" the container to avoid
-            # unexpected fails due to incompatibilities with older systemd
-            $DOCKER_EXEC make install
-            docker restart $CONT_NAME
-            if ! $DOCKER_EXEC make check; then
-                $DOCKER_EXEC cat test-suite.log
-                exit 1
-            fi
-            ;;
-        CLEANUP)
-            info "Cleanup phase"
-            docker stop $CONT_NAME
-            docker rm -f $CONT_NAME
-            ;;
-        *)
-            echo >&2 "Unknown phase '$phase'"
-            exit 1
-    esac
-done
diff --git a/ci/travis_wait.bash b/ci/travis_wait.bash
deleted file mode 100644
index acf6ad15e4..0000000000
--- a/ci/travis_wait.bash
+++ /dev/null
@@ -1,61 +0,0 @@
-# This was borrowed from https://github.com/travis-ci/travis-build/tree/master/lib/travis/build/bash
-# to get around https://github.com/travis-ci/travis-ci/issues/9979. It should probably be removed
-# as soon as Travis CI has started to provide an easy way to export the functions to bash scripts.
-
-travis_jigger() {
-  local cmd_pid="${1}"
-  shift
-  local timeout="${1}"
-  shift
-  local count=0
-
-  echo -e "\\n"
-
-  while [[ "${count}" -lt "${timeout}" ]]; do
-    count="$((count + 1))"
-    echo -ne "Still running (${count} of ${timeout}): ${*}\\r"
-    sleep 60
-  done
-
-  echo -e "\\n${ANSI_RED}Timeout (${timeout} minutes) reached. Terminating \"${*}\"${ANSI_RESET}\\n"
-  kill -9 "${cmd_pid}"
-}
-
-travis_wait() {
-  local timeout="${1}"
-
-  if [[ "${timeout}" =~ ^[0-9]+$ ]]; then
-    shift
-  else
-    timeout=20
-  fi
-
-  local cmd=("${@}")
-  local log_file="travis_wait_${$}.log"
-
-  "${cmd[@]}" &>"${log_file}" &
-  local cmd_pid="${!}"
-
-  travis_jigger "${!}" "${timeout}" "${cmd[@]}" &
-  local jigger_pid="${!}"
-  local result
-
-  {
-    set +e
-    wait "${cmd_pid}" 2>/dev/null
-    result="${?}"
-    ps -p"${jigger_pid}" &>/dev/null && kill "${jigger_pid}"
-    set -e
-  }
-
-  if [[ "${result}" -eq 0 ]]; then
-    echo -e "\\n${ANSI_GREEN}The command ${cmd[*]} exited with ${result}.${ANSI_RESET}"
-  else
-    echo -e "\\n${ANSI_RED}The command ${cmd[*]} exited with ${result}.${ANSI_RESET}"
-  fi
-
-  echo -e "\\n${ANSI_GREEN}Log:${ANSI_RESET}\\n"
-  cat "${log_file}"
-
-  return "${result}"
-}