From: Sitsofe Wheeler Date: Sun, 26 Jul 2020 14:20:45 +0000 (+0100) Subject: ci: add CI via GitHub Actions X-Git-Tag: fio-3.29~17^2~1 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=ce1b5612ce9960e50a15ab3b80bb40ef946b47a7;hp=d3dacdc61dfe878fda0c363084c4330492e38b2b;p=fio.git ci: add CI via GitHub Actions - Add GitHub Actions CI on push and pull requests for: - Ubuntu 20.04 x86_64 gcc - Ubuntu 20.04 x86_64 clang - Ubuntu 20.04 i686 gcc - macOS 10.15 - Set the same dpkg flags as found in a default Ubuntu docker container. This has the following benefits: - Reduction in the amount of fsyncing dpkg/apt does - Installation/configuring of documentation is skipped - On macOS Speed up homewbrew by not updating on install v2: - Use macOS 10.15 rather than 11.0 because 11.0 is only private preview (https://docs.github.com/en/actions/reference/specifications-for-github-hosted-runners ). - Workaround "Could not perform immediate configuration on 'libgcc-s1:i386'." on the Ubuntu 20.04 i686 configuration (see https://bugs.launchpad.net/ubuntu-cdimage/+bug/1871268/comments/170 for details of the underlying issue). - Install i386 development zlib. Thanks to Lukasz Dorau for pointing the above out! Signed-off-by: Sitsofe Wheeler --- diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..a766cfa8 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,45 @@ +name: CI + +on: + push: + pull_request: + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + build: + - linux-gcc + - linux-clang + - macos + - linux-i686-gcc + include: + - build: linux-gcc + os: ubuntu-20.04 + cc: gcc + - build: linux-clang + os: ubuntu-20.04 + cc: clang + - build: macos + os: macos-10.15 + - build: linux-i686-gcc + os: ubuntu-20.04 + arch: i686 + + env: + CI_TARGET_ARCH: ${{ matrix.arch }} + CC: ${{ matrix.cc }} + + steps: + - name: Checkout repo + uses: actions/checkout@v2 + - name: Install dependencies + run: ./ci/actions-install.sh + - name: Build + run: ./ci/actions-build.sh + - name: Smoke test + run: ./ci/actions-smoke-test.sh + - name: Full test + run: ./ci/actions-full-test.sh diff --git a/ci/actions-build.sh b/ci/actions-build.sh new file mode 100755 index 00000000..74a6fdcb --- /dev/null +++ b/ci/actions-build.sh @@ -0,0 +1,37 @@ +#!/bin/bash +# This script expects to be invoked from the base fio directory. +set -eu + +SCRIPT_DIR=$(dirname "$0") +# shellcheck disable=SC1091 +. "${SCRIPT_DIR}/common.sh" + +main() { + local extra_cflags="-Werror" + local configure_flags=() + + set_ci_target_os + case "${CI_TARGET_OS}" in + "linux") + case "${CI_TARGET_ARCH}" in + "i686") + extra_cflags="${extra_cflags} -m32" + export LDFLAGS="-m32" + ;; + "x86_64") + configure_flags+=( + "--enable-cuda" + "--enable-libiscsi" + "--enable-libnbd" + ) + ;; + esac + ;; + esac + configure_flags+=(--extra-cflags="${extra_cflags}") + + ./configure "${configure_flags[@]}" + make -j 2 +} + +main diff --git a/ci/actions-full-test.sh b/ci/actions-full-test.sh new file mode 100755 index 00000000..4ae1dba1 --- /dev/null +++ b/ci/actions-full-test.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# This script expects to be invoked from the base fio directory. +set -eu + +main() { + echo "Running long running tests..." + export PYTHONUNBUFFERED="TRUE" + if [[ "${CI_TARGET_ARCH}" == "arm64" ]]; then + sudo python3 t/run-fio-tests.py --skip 6 1007 1008 --debug -p 1010:"--skip 15 16 17 18 19 20" + else + sudo python3 t/run-fio-tests.py --skip 6 1007 1008 --debug + fi +} + +main diff --git a/ci/actions-install.sh b/ci/actions-install.sh new file mode 100755 index 00000000..7408ccb4 --- /dev/null +++ b/ci/actions-install.sh @@ -0,0 +1,91 @@ +#!/bin/bash +# This script expects to be invoked from the base fio directory. +set -eu + +SCRIPT_DIR=$(dirname "$0") +# shellcheck disable=SC1091 +. "${SCRIPT_DIR}/common.sh" + +install_ubuntu() { + local pkgs + + cat < /dev/null +# Skip fsync +force-unsafe-io +# Don't install documentation +path-exclude=/usr/share/man/* +path-exclude=/usr/share/locale/*/LC_MESSAGES/*.mo +path-exclude=/usr/share/doc/* +DPKGCFG + # Packages available on i686 and x86_64 + pkgs=( + libaio-dev + libcunit1-dev + libcurl4-openssl-dev + libfl-dev + libibverbs-dev + libnuma-dev + librdmacm-dev + valgrind + ) + case "${CI_TARGET_ARCH}" in + "i686") + sudo dpkg --add-architecture i386 + pkgs=("${pkgs[@]/%/:i386}") + pkgs+=( + gcc-multilib + pkg-config:i386 + zlib1g-dev:i386 + ) + ;; + "x86_64") + pkgs+=( + libglusterfs-dev + libgoogle-perftools-dev + libiscsi-dev + libnbd-dev + libpmem-dev + libpmemblk-dev + librbd-dev + libtcmalloc-minimal4 + nvidia-cuda-dev + ) + ;; + esac + + # Architecture-independent packages and packages for which we don't + # care about the architecture. + pkgs+=( + python3-scipy + ) + + echo "Updating APT..." + sudo apt-get -qq update + echo "Installing packages..." + sudo apt-get install -o APT::Immediate-Configure=false --no-install-recommends -qq -y "${pkgs[@]}" +} + +install_linux() { + install_ubuntu +} + +install_macos() { + # Assumes homebrew and python3 are already installed + #echo "Updating homebrew..." + #brew update >/dev/null 2>&1 + echo "Installing packages..." + HOMEBREW_NO_AUTO_UPDATE=1 brew install cunit + pip3 install scipy six +} + +main() { + set_ci_target_os + + install_function="install_${CI_TARGET_OS}" + ${install_function} + + echo "Python3 path: $(type -p python3 2>&1)" + echo "Python3 version: $(python3 -V 2>&1)" +} + +main diff --git a/ci/actions-smoke-test.sh b/ci/actions-smoke-test.sh new file mode 100755 index 00000000..c129c89f --- /dev/null +++ b/ci/actions-smoke-test.sh @@ -0,0 +1,10 @@ +#!/bin/bash +# This script expects to be invoked from the base fio directory. +set -eu + +main() { + echo "Running smoke tests..." + make test +} + +main diff --git a/ci/common.sh b/ci/common.sh new file mode 100644 index 00000000..8861f843 --- /dev/null +++ b/ci/common.sh @@ -0,0 +1,34 @@ +# shellcheck shell=bash + +function set_ci_target_os { + # Function that exports CI_TARGET_OS to the current OS if it is not already + # set. + + # Don't override CI_TARGET_OS if already set + CI_TARGET_OS=${CI_TARGET_OS:-} + if [[ -z ${CI_TARGET_OS} ]]; then + # Detect operating system + case "${OSTYPE}" in + linux*) + CI_TARGET_OS="linux" + ;; + darwin*) + CI_TARGET_OS="macos" + ;; + msys*) + CI_TARGET_OS="windows" + ;; + bsd*) + CI_TARGET_OS="bsd" + ;; + *) + CI_TARGET_OS="" + esac + fi + + # Don't override CI_TARGET_ARCH if already set + CI_TARGET_ARCH=${CI_TARGET_ARCH:-} + if [[ -z ${CI_TARGET_ARCH} ]]; then + CI_TARGET_ARCH="$(uname -m)" + fi +}