From c0cda58f5244dfc3d583bb7bfe417e3b45cc504f Mon Sep 17 00:00:00 2001 From: Francesco Chemolli <5175948+kinkie@users.noreply.github.com> Date: Mon, 29 Apr 2024 21:28:23 +0000 Subject: [PATCH] Add MacOS to Github Actions CI tests (#1785) Add MacOS/homebrew as a target platform for the GitHub CI tests. Also improve detection of the number of available cores in buildtests.sh --- .github/workflows/default.yaml | 32 ++++++++++++++++++++++++++++++-- test-suite/buildtest.sh | 8 ++++++-- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/.github/workflows/default.yaml b/.github/workflows/default.yaml index d926161d6e..898db8b979 100644 --- a/.github/workflows/default.yaml +++ b/.github/workflows/default.yaml @@ -94,7 +94,7 @@ jobs: strategy: fail-fast: true matrix: - os: [ ubuntu-22.04 ] + os: [ ubuntu-22.04, macos-14 ] runs-on: ${{ matrix.os }} @@ -109,10 +109,38 @@ jobs: sudo apt-get --quiet=2 build-dep squid sudo apt-get --quiet=2 install linuxdoc-tools libtool-bin + - name: Install prerequisite MacOS packages + if: runner.os == 'macOS' + run: | + brew install \ + automake coreutils cppunit gawk \ + gnu-getopt gnu-sed grep libtool \ + make openldap openssl cyrus-sasl + - name: Checkout sources uses: actions/checkout@v4 - - run: ./test-builds.sh + - name: Run build on Linux + if: runner.os == 'Linux' + run: ./test-builds.sh + + - name: Run build on MacOS + if: runner.os == 'macOS' + run: | + eval `brew shellenv` + PKG_CONFIG_PATH="$HOMEBREW_PREFIX/lib/pkgconfig" + PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$HOMEBREW_PREFIX/opt/openldap/lib/pkgconfig" + PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$HOMEBREW_PREFIX/opt/cyrus-sasl/lib/pkgconfig" + export PKG_CONFIG_PATH + export GETOPT="$HOMEBREW_PREFIX/opt/gnu-getopt/bin/getopt" + export MAKE="$HOMEBREW_PREFIX/bin/gmake" + # ensure we use Homebrew headers and libraries + # this is needed because pkg-config --libs openssl points to the wrong directory + # in version openssl@3: stable 3.3.0 + export CPPFLAGS="-I$HOMEBREW_PREFIX/include${CPPFLAGS:+ $CPPFLAGS}" + export LDFLAGS="-L$HOMEBREW_PREFIX/lib${LDFLAGS:+ $LDFLAGS}" + export CFLAGS="-Wno-compound-token-split-by-macro${CFLAGS:+ $CFLAGS}" # needed fir ltdl with Xcode + ./test-builds.sh - name: Publish build logs if: success() || failure() diff --git a/test-suite/buildtest.sh b/test-suite/buildtest.sh index 089cbc7829..0c3ab21b56 100755 --- a/test-suite/buildtest.sh +++ b/test-suite/buildtest.sh @@ -22,19 +22,23 @@ if [ -n "$cache_file" ]; then configcache="--cache-file=$cache_file" fi -#if we are on Linux, let's try parallelizing +# let's try parallelizing +if [ -z "$pjobs" ] && nproc > /dev/null 2>&1 ; then + ncpus=`nproc` + pjobs="-j${ncpus}" +fi if [ -z "$pjobs" -a -e /proc/cpuinfo ]; then ncpus=`grep '^processor' /proc/cpuinfo | tail -1|awk '{print $3}'` ncpus=`expr ${ncpus} + 1` pjobs="-j${ncpus}" fi -#if we are on FreeBSD, let's try parallelizing if [ -z "$pjobs" -a -x /sbin/sysctl ]; then ncpus=`sysctl kern.smp.cpus | cut -f2 -d" "` if [ $? -eq 0 -a -n "$ncpus" -a "$ncpus" -gt 1 ]; then pjobs="-j${ncpus}" fi fi +echo "pjobs: $pjobs" if test -e ${config} ; then echo "BUILD: ${config}" -- 2.47.2