diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml new file mode 100644 index 0000000..7540655 --- /dev/null +++ b/.github/workflows/ci-build.yml @@ -0,0 +1,97 @@ +# If Github does not properly accept this YAML file, try +# https://rhysd.github.io/actionlint/ from +# https://github.com/rhysd/actionlint. + +name: 'CI build' + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +env: + LC_ALL: C + COMMON_CONFIGURE_FLAGS: >- + --disable-silent-rules + +jobs: + ix-build: + + runs-on: ${{ matrix.os }} + + name: '${{ matrix.os }}' + + strategy: + fail-fast: true + matrix: + os: [ubuntu-latest, macos-latest] + + steps: + - uses: actions/checkout@v3 + + - name: 'Determine number of cores to build on (Linux)' + if: runner.os == 'Linux' + run: echo NPROC=$(nproc) >> $GITHUB_ENV + + - name: 'Determine number of cores to build on (macOS)' + if: runner.os == 'macOS' + run: echo NPROC=$(sysctl -n hw.logicalcpu) >> $GITHUB_ENV + + # Setting MAKE interferes with Makefile{,.in,.am} using $(MAKE) internally + - name: 'Prepare concurrent make' + run: if test "x$NPROC" = x; then echo ci_MAKE="make" >> $GITHUB_ENV; echo "NPROC must be set"; exit 1; else echo ci_MAKE="make -j${NPROC} -l${NPROC}" >> $GITHUB_ENV; fi + + - name: 'Update software database (Linux)' + if: runner.os == 'Linux' + run: sudo apt-get update + + - name: 'Update software database (macOS)' + if: runner.os == 'macOS' + run: brew update + + - name: 'Install build requirements (Linux)' + if: runner.os == 'Linux' + run: sudo apt-get install -y automake + + - name: 'Install build requirements (macOS)' + if: runner.os == 'macOS' + run: brew install automake + + - name: 'OS specific build flags (Linux)' + if: runner.os == 'Linux' + run: echo OS_SPECIFIC_CPPFLAGS="" >> $GITHUB_ENV + + - name: 'OS specific build flags (macOS)' + if: runner.os == 'macOS' + run: echo OS_SPECIFIC_CPPFLAGS="" >> $GITHUB_ENV + + - name: 'autoreconf' + run: autoreconf -i -f + + - name: 'configure' + run: ./configure ${COMMON_CONFIGURE_FLAGS} --prefix=$PWD/__prefix + + - name: 'make' + run: set -x; ${ci_MAKE} CPPFLAGS="${OS_SPECIFIC_CPPFLAGS}" + + - name: 'make check' + # FIXME: macOS grep has issues with \{,50\} + if: runner.os != 'macOS' + run: set -x; if ${ci_MAKE} CPPFLAGS="${OS_SPECIFIC_CPPFLAGS}" check; then :; else s="$?"; cat test-suite.log; exit "$s"; fi + + - name: 'make install' + run: set -x; ${ci_MAKE} CPPFLAGS="${OS_SPECIFIC_CPPFLAGS}" install + + - name: 'make installcheck' + run: set -x; ${ci_MAKE} CPPFLAGS="${OS_SPECIFIC_CPPFLAGS}" installcheck + + - name: 'make distcheck' + if: false + # if: runner.os != 'macOS' + run: set -x; ${ci_MAKE} CPPFLAGS="${OS_SPECIFIC_CPPFLAGS}" DISTCHECK_CONFIGURE_FLAGS="${COMMON_CONFIGURE_FLAGS}" distcheck + + - name: 'dist tarball content' + if: false + run: for tarball in *.tar.*; do tar tf "$tarball" | sort; break; done +