swig/.github/workflows/ci.yml
Vadim Zeitlin 55dfa99e49 Define CC and CXX environment variables correctly
They are supposed to be set to gcc-$GCC and g++-$GCC respectively, if
the suffix is defined, so do it.

Also use "compiler", rather than "CC", in the matrix for consistency
with .travis.yml and to avoid confusion between this property, which may
be empty, and CC environment variable, which is supposed to be always
defined.

Finally, show the path and the version of the compiler being used: this
was also done under Travis CI and there doesn't seem to be any reason
not to do it here.
2021-09-30 18:17:24 +02:00

157 lines
5.2 KiB
YAML

name: CI
on:
push:
branches: master
paths-ignore:
- 'CHANGES*'
- 'Doc/**'
pull_request:
branches: master
paths-ignore:
- 'CHANGES*'
- 'Doc/**'
jobs:
build:
runs-on: ${{ matrix.os || 'ubuntu-20.04' }}
# By default, the name of the build is just the language used, but matrix
# entries can define the additional "desc" field with any additional
# information to include in the name.
name: ${{ matrix.SWIGLANG || 'none' }}${{ matrix.PY3 }} ${{ matrix.desc }}
strategy:
matrix:
include:
- SWIGLANG: ""
desc: gcc
- SWIGLANG: ""
GCC: 7
desc: gcc7
- SWIGLANG: ""
GCC: 8
desc: gcc8
- SWIGLANG: ""
GCC: 9
desc: gcc9
- SWIGLANG: ""
GCC: 10
desc: gcc10
- SWIGLANG: ""
compiler: clang
desc: clang
- CPP11: 1
SWIGLANG: python
- CPP11: 1
SWIGLANG: python
PY3: 3
- CPP11: 1
SWIGLANG: tcl
# let's run all of them, as opposed to aborting when one fails
fail-fast: false
env:
SWIGLANG: ${{ matrix.SWIGLANG }}
SWIG_FEATURES: ${{ matrix.SWIG_FEATURES }}
CONFIGOPTS: ${{ matrix.CONFIGOPTS }}
CSTD: ${{ matrix.CSTD }}
CPP11: ${{ matrix.CPP11 }}
CPP14: ${{ matrix.CPP14 }}
CPP17: ${{ matrix.CPP17 }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: recursive
- name: Install CCache
uses: hendrikmuhs/ccache-action@v1
with:
key: ${{ matrix.os || 'ubuntu-20.04' }}-${{ matrix.compiler || 'gcc' }}${{ matrix.GCC }}
- name: Configure
run: |
set -x
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
echo PATH="$PATH" >> $GITHUB_ENV
source Tools/GHA-linux-install.sh
if test '${{ matrix.compiler }}' = 'clang'; then
CC="clang"
CXX="clang++"
elif test -n "$GCC"; then
CC="gcc-$GCC"
CXX="g++-$GCC"
else
CC="gcc"
CXX="g++"
fi
export CC CXX
echo CC="$CC" >> $GITHUB_ENV
echo CXX="$CXX" >> $GITHUB_ENV
echo "Compiler used:"
ls -la $(which $CC) $(which $CXX)
$CC --version
$CXX --version
if test -n "$CPP11"; then CONFIGOPTS+=(--enable-cpp11-testing "CXXFLAGS=-std=c++11 $CXXFLAGS" "CFLAGS=-std=c11 $CFLAGS") && export CSTD=c11 && export CPPSTD=c++11; fi
if test -n "$CPP14"; then CONFIGOPTS+=(--enable-cpp11-testing "CXXFLAGS=-std=c++14 $CXXFLAGS" "CFLAGS=-std=c11 $CFLAGS") && export CSTD=c11 && export CPPSTD=c++14; fi
if test -n "$CPP17"; then CONFIGOPTS+=(--enable-cpp11-testing "CXXFLAGS=-std=c++17 $CXXFLAGS" "CFLAGS=-std=c17 $CFLAGS") && export CSTD=c17 && export CPPSTD=c++17; fi
if test -n "$SWIGLANG"; then CONFIGOPTS+=(--without-alllang --with-$WITHLANG); fi
echo "${CONFIGOPTS[@]}"
./autogen.sh && mkdir -p build/build && cd build/build && ../../configure "${CONFIGOPTS[@]}"
case $(uname) in
Linux)
cpu_count=$(nproc)
;;
Darwin)
cpu_count=$(sysctl -n hw.ncpu)
;;
*)
cpu_count=0
;;
esac
((cpu_count++))
echo SWIGJOBS=-j$cpu_count >> $GITHUB_ENV
- name: Build
working-directory: build/build
run: |
set -x
make $SWIGJOBS
./swig -version && ./swig -pcreversion
if test -z "$SWIGLANG"; then make $SWIGJOBS check-ccache; fi
if test -z "$SWIGLANG"; then make $SWIGJOBS check-errors-test-suite; fi
echo 'Installing...'
if test -z "$SWIGLANG"; then sudo make install && swig -version && ccache-swig -V; fi
- name: Test
working-directory: build/build
run: |
set -x
if test -n "$CPP11"; then export CPPSTD=c++11; fi
if test -n "$CPP14"; then export CPPSTD=c++14; fi
if test -n "$CPP17"; then export CPPSTD=c++17; fi
# Stricter compile flags for examples. Various headers and SWIG generated code prevents full use of -pedantic.
if test -n "$SWIGLANG"; then cflags=$($GITHUB_WORKSPACE/Tools/testflags.py --language $SWIGLANG --cflags --std=$CSTD --compiler=$CC) && echo $cflags; fi
if test -n "$SWIGLANG"; then cxxflags=$($GITHUB_WORKSPACE/Tools/testflags.py --language $SWIGLANG --cxxflags --std=$CPPSTD --compiler=$CC) && echo $cxxflags; fi
if test -n "$SWIGLANG"; then make check-$SWIGLANG-version; fi
if test -n "$SWIGLANG"; then make check-$SWIGLANG-enabled; fi
if test -n "$SWIGLANG"; then make $SWIGJOBS check-$SWIGLANG-examples CFLAGS="$cflags" CXXFLAGS="$cxxflags"; fi
if test -n "$SWIGLANG"; then make $SWIGJOBS check-$SWIGLANG-test-suite CFLAGS="$cflags" CXXFLAGS="$cxxflags"; fi
- name: Clean
working-directory: build/build
run: |
set -x
make check-maintainer-clean && ../../configure $CONFIGOPTS