daandemeyer / rpms / systemd

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