]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
github: add build workflow
authorKarel Zak <kzak@redhat.com>
Mon, 25 Jan 2021 15:51:51 +0000 (16:51 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 25 Jan 2021 15:54:38 +0000 (16:54 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
.github/workflows/cibuild-setup-ubuntu.sh [new file with mode: 0755]
.github/workflows/cibuild.sh [new file with mode: 0755]
.github/workflows/cibuild.yml [new file with mode: 0644]

diff --git a/.github/workflows/cibuild-setup-ubuntu.sh b/.github/workflows/cibuild-setup-ubuntu.sh
new file mode 100755 (executable)
index 0000000..c928da2
--- /dev/null
@@ -0,0 +1,51 @@
+#!/bin/bash
+     
+set -ex
+     
+PACKAGES=(
+       bc
+       btrfs-tools
+       dnsutils
+       libcap-ng-dev
+       libncursesw5-dev
+       libpam-dev
+       libudev-dev
+       gtk-doc-tools
+       mdadm
+       ntp
+       socat
+)
+
+PACKAGES_OPTIONAL=(
+       libsystemd-daemon-dev
+       libsystemd-journal-dev
+)
+
+
+COMPILER="${COMPILER:?}"
+COMPILER_VERSION="${COMPILER_VERSION:?}"
+RELEASE="$(lsb_release -cs)"
+
+bash -c "echo 'deb-src http://archive.ubuntu.com/ubuntu/ $RELEASE main restricted universe multiverse' >>/etc/apt/sources.list"
+
+if [[ "$COMPILER" == clang ]]; then
+    # Latest LLVM stack deb packages provided by https://apt.llvm.org/
+    # Following snippet was borrowed from https://apt.llvm.org/llvm.sh
+    wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
+    add-apt-repository -y "deb http://apt.llvm.org/$RELEASE/   llvm-toolchain-$RELEASE-$COMPILER_VERSION  main"
+    PACKAGES+=(clang-$COMPILER_VERSION lldb-$COMPILER_VERSION lld-$COMPILER_VERSION clangd-$COMPILER_VERSION)
+elif [[ "$COMPILER" == gcc ]]; then
+    # Latest gcc stack deb packages provided by
+    # https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test
+    add-apt-repository -y ppa:ubuntu-toolchain-r/test
+    PACKAGES+=(gcc-$COMPILER_VERSION)
+else
+    fatal "Unknown compiler: $COMPILER"
+fi
+
+apt-get -y update --fix-missing
+apt-get -y build-dep util-linux
+apt-get -y install "${PACKAGES[@]}"
+apt-get -y install  "${PACKAGES_OPTIONAL[@]}" || true
+
+export PATH="$HOME/.local/bin:$PATH"
diff --git a/.github/workflows/cibuild.sh b/.github/workflows/cibuild.sh
new file mode 100755 (executable)
index 0000000..acd4046
--- /dev/null
@@ -0,0 +1,55 @@
+#!/bin/bash
+PHASES=(${@:-CONFIGURE MAKE INSTALL CHECK DISTCHECK})
+COMPILER="${COMPILER:?}"
+
+set -ex
+
+for phase in "${PHASES[@]}"; do
+    case $phase in
+       CONFIGURE)
+               opts = "--disable-use-tty-group \
+                       --disable-makeinstall-chown \
+                       --enable-all-programs \
+                       --enable-asan \
+                       --enable-ubsan \
+                       --enable-werror"
+
+               if [[ "$COMPILER" == clang ]]; then
+                       opts="$opts --enable-fuzzing-engine"
+               fi
+
+               echo "## CONFIGURE: git-clean"
+               sudo -E git clean -xdf
+
+               echo "## CONFIGURE: autogen.sh"
+               ./autogen.sh
+
+               echo "## CONFIGURE: $opts --"
+               ./configure $opts
+               ;;
+        MAKE)
+               echo "## MAKE"
+               make -j V=1
+               make -j check-programs V=1
+               ;;
+       INSTALL)
+               echo "## MAKE INSTALL"
+               make install DESTDIR=/tmp/dest
+               ;;
+       CHECK)
+               echo "## MAKE CHECK"
+               ./tests/run.h --show-diff
+               ;;
+       DISTCHECK)
+               echo "## MAKE DISTCHECK"
+               make distcheck
+               ;;
+       
+        *)
+            echo >&2 "Unknown phase '$phase'"
+            exit 1
+    esac
+done
+       
+
diff --git a/.github/workflows/cibuild.yml b/.github/workflows/cibuild.yml
new file mode 100644 (file)
index 0000000..d79e67c
--- /dev/null
@@ -0,0 +1,32 @@
+name: Build test
+on:
+  push:
+    branches:
+      - 'cibuild'
+    paths-ignore:
+      - 'Documentation/**'
+      - 'lib*/docs/**'
+
+jobs:
+  build:
+    runs-on: ubuntu-20.04
+    strategy:
+      fail-fast: false
+      matrix:
+        env:
+          - { COMPILER: "gcc",   COMPILER_VERSION: "10" }
+          - { COMPILER: "clang", COMPILER_VERSION: "10" }
+    env: ${{ matrix.env }}
+    steps:
+      - name: Repository checkout
+        uses: actions/checkout@v1
+      - name: Ubuntu setup      (${{ env.COMPILER }}-${{ env.COMPILER_VERSION }})
+        run: sudo -E .github/workflows/cibuild-setup-ubuntu.sh
+      - name: Congure & Make    (${{ env.COMPILER }}-${{ env.COMPILER_VERSION }})
+        run: .github/workflows/cibuild.sh CONFIGURE MAKE
+      - name: Make install 
+        run: .github/workflows/cibuild.sh INSTALL
+      - name: Make distcheck
+        run: .github/workflows/cibuild.sh DISTCHECK
+      - make: Check
+        run: sudo -E .github/workflows/cibuild.sh CHECK