dcavalca / rpms / systemd

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