From e47df85ed5c63dcd13f33b1597d05bf364cc0292 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Thu, 10 Mar 2022 21:41:28 +0100 Subject: [PATCH] ci: tentative to also build on FreeBSD/NetBSD/OpenBSD This could work with NetBSD, but this is far too slow. Give up on it. Also, use different jobs for Linux and MacOS. --- .github/workflows/ci.yml | 109 +++++++++++++++++++++++++++------------ configure.ac | 2 + src/lib/Makefile.am | 4 +- tests/ci/install.sh | 19 +++++++ tests/ci/run.sh | 7 ++- 5 files changed, 106 insertions(+), 35 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bbabf003..2add670c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,11 +5,10 @@ on: schedule: - cron: 0 7 1 * * jobs: - build: + build-linux: + runs-on: ubuntu-latest strategy: matrix: - os: - - ubuntu-latest config-args: - "--with-embedded-libevent" - "--disable-shared --enable-static" @@ -23,26 +22,10 @@ jobs: release: - false include: - - os: ubuntu-latest - config-args: '' + - config-args: '' release: true - - os: ubuntu-latest - compiler: clang + - compiler: clang config-args: "--with-snmp --with-xml" - - os: macos-latest - compiler: clang - config-args: "--with-snmp --with-xml" - - os: macos-latest - compiler: clang - config-args: > - --prefix=/usr/local - --localstatedir=/var - --sysconfdir=/private/etc - --with-embedded-libevent - --without-snmp - --without-xml - release: true - runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 with: @@ -60,32 +43,91 @@ jobs: LLDPD_CONFIG_ARGS: ${{ matrix.config-args }} CC: ${{ matrix.compiler }} - name: Generate release body - if: matrix.release && matrix.os == 'ubuntu-latest' + if: matrix.release run: ./tests/ci/release.sh > release.md - name: Upload release tarball uses: actions/upload-artifact@v2 - if: matrix.release && matrix.os == 'ubuntu-latest' + if: matrix.release with: name: tarball path: lldpd-*.tar.gz if-no-files-found: error + - name: Upload release summary + uses: actions/upload-artifact@v2 + if: matrix.release + with: + name: release + path: release.md + if-no-files-found: error + + build-macos: + runs-on: macos-latest + strategy: + matrix: + include: + - config-args: "--with-snmp --with-xml" + release: false + - config-args: > + --prefix=/usr/local + --localstatedir=/var + --sysconfdir=/private/etc + --with-embedded-libevent + --without-snmp + --without-xml + release: true + steps: + - uses: actions/checkout@v2 + with: + submodules: true + - name: Install stuff + run: ./tests/ci/install.sh + - name: Build and run tests + run: ./tests/ci/run.sh + env: + LLDPD_CONFIG_ARGS: ${{ matrix.config-args }} + CC: clang - name: Upload MacOS release package uses: actions/upload-artifact@v2 - if: matrix.release && matrix.os == 'macos-latest' + if: matrix.release with: name: package path: lldpd-*.pkg if-no-files-found: error - - name: Upload release summary - uses: actions/upload-artifact@v2 - if: matrix.release && matrix.os == 'ubuntu-latest' + + build-bsd: + timeout-minutes: 20 + strategy: + fail-fast: false + matrix: + os: + - name: freebsd + version: '13.0' + runner: macos-10.15 + - name: openbsd + version: '6.9' + runner: macos-10.15 + runs-on: ${{ matrix.os.runner }} + steps: + - uses: actions/checkout@v2 with: - name: release - path: release.md - if-no-files-found: error + submodules: true + - name: Test on ${{ matrix.os.name }} + uses: cross-platform-actions/action@v0.3.1 + with: + operating_system: ${{ matrix.os.name }} + version: ${{ matrix.os.version }} + environment_variables: LLDPD_CONFIG_ARGS + shell: bash + run: | + set -e + ./tests/ci/install.sh + ./tests/ci/run.sh docker: - needs: build + needs: + - build-linux + - build-macos + - build-bsd runs-on: ubuntu-latest name: Build Docker images if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') @@ -122,7 +164,10 @@ jobs: labels: ${{ steps.meta.outputs.labels }} release: - needs: build + needs: + - build-linux + - build-macos + - build-bsd runs-on: ubuntu-latest name: Publish release if: startsWith(github.ref, 'refs/tags/') diff --git a/configure.ac b/configure.ac index 7c87a55f..11ec21a8 100644 --- a/configure.ac +++ b/configure.ac @@ -48,11 +48,13 @@ AC_PROG_CC_C99 if test x"$ac_cv_prog_cc_c99" = x"no"; then AC_MSG_FAILURE([*** C99 support is mandatory]) fi +AC_PROG_CPP AM_PROG_CC_C_O LT_INIT AC_PROG_LN_S AC_PROG_EGREP AC_PROG_AWK +AC_PROG_SED # Check for pkg-config m4_ifndef([PKG_CHECK_MODULES], [ diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index 8763b4fd..f9810392 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -21,7 +21,7 @@ liblldpctl_la_LIBADD = $(top_builddir)/src/libcommon-daemon-lib.la libfixedpoin atom-glue.c: $(ATOM_FILES) Makefile $(AM_V_GEN)(for f in $(ATOM_FILES:%=$(srcdir)/%); do \ - $(CC) -E $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $$f; done | \ $(SED) -n 's+^void init_atom_builder_\([^(]*\)().*, \([0-9]*\)).*+\2 \1+p' | \ sort | \ @@ -32,7 +32,7 @@ atom-glue.c: $(ATOM_FILES) Makefile for (atom in atoms) { print " init_atom_builder_"atom"();" } \ print "}"; }' && \ for f in $(ATOM_FILES:%=$(srcdir)/%); do \ - $(CC) -E $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $$f; done | \ $(SED) -n 's+^void init_atom_map_\([^(]*\)().*, \([0-9]*\)).*+\2 \1+p' | \ sort -n | \ diff --git a/tests/ci/install.sh b/tests/ci/install.sh index 7139bdee..bf93358d 100755 --- a/tests/ci/install.sh +++ b/tests/ci/install.sh @@ -3,6 +3,25 @@ set -e case "$(uname -s)" in + OpenBSD) + sudo pkg_add -I \ + automake-1.16.3 autoconf-2.71 libtool \ + libevent libxml check \ + git + ;; + FreeBSD) + sudo env ASSUME_ALWAYS_YES=true pkg install \ + automake autoconf libtool pkgconf \ + libevent libxml2 check \ + git + ;; + NetBSD) + sudo pkgin -y update + sudo pkgin -y install \ + automake autoconf libtool pkg-config \ + libevent libxml2 check \ + git + ;; Darwin) brew update > /dev/null brew bundle --file=- <<-EOS diff --git a/tests/ci/run.sh b/tests/ci/run.sh index 5f619c04..56b781b9 100755 --- a/tests/ci/run.sh +++ b/tests/ci/run.sh @@ -16,6 +16,10 @@ case "$(uname -s)" in LLDPD_CONFIG_ARGS="$LLDPD_CONFIG_ARGS LDFLAGS=-mmacosx-version-min=10.9" MAKE_ARGS="" ;; + OpenBSD) + export AUTOCONF_VERSION=2.71 + export AUTOMAKE_VERSION=1.16 + ;; esac ./autogen.sh @@ -28,7 +32,6 @@ make check ${MAKE_ARGS-CFLAGS=-Werror} || { [ ! -f tests/test-suite.log ] || cat tests/test-suite.log exit 1 } -make distcheck case "$(uname -s)" in Darwin) @@ -37,6 +40,8 @@ case "$(uname -s)" in otool -l osx/lldpd*/usr/local/sbin/lldpd ;; Linux) + make distcheck + # Integration tests cd tests/integration sudo $(which python3) -m pytest -n 5 -vv --boxed || \ -- 2.39.5